Skip to content

Commit

Permalink
Rollup merge of rust-lang#111557 - cjgillot:revert-111020, r=petroche…
Browse files Browse the repository at this point in the history
…nkov

Revert "Validate resolution for SelfCtor too."

This reverts commit 8345340.

That PR introduced a breaking change.

Fixes rust-lang#111541
Reopens rust-lang#89868

r? `@petrochenkov`
  • Loading branch information
Dylan-DPC committed May 17, 2023
2 parents 828caa8 + 33ec632 commit ff364b0
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 55 deletions.
2 changes: 1 addition & 1 deletion compiler/rustc_resolve/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {

let sm = self.tcx.sess.source_map();
let def_id = match outer_res {
Res::SelfTyParam { .. } | Res::SelfCtor(_) => {
Res::SelfTyParam { .. } => {
err.span_label(span, "can't use `Self` here");
return err;
}
Expand Down
5 changes: 1 addition & 4 deletions compiler/rustc_resolve/src/ident.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1174,10 +1174,7 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
return Res::Err;
}
}
Res::Def(DefKind::TyParam, _)
| Res::SelfTyParam { .. }
| Res::SelfTyAlias { .. }
| Res::SelfCtor(_) => {
Res::Def(DefKind::TyParam, _) | Res::SelfTyParam { .. } | Res::SelfTyAlias { .. } => {
for rib in ribs {
let has_generic_params: HasGenericParams = match rib.kind {
RibKind::Normal
Expand Down
17 changes: 0 additions & 17 deletions tests/ui/self/self-ctor-inner-const.rs

This file was deleted.

33 changes: 0 additions & 33 deletions tests/ui/self/self-ctor-inner-const.stderr

This file was deleted.

15 changes: 15 additions & 0 deletions tests/ui/self/self-ctor-nongeneric.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// `Self` as a constructor is currently allowed when the outer item is not generic.
// check-pass

struct S0(usize);

impl S0 {
fn foo() {
const C: S0 = Self(0);
fn bar() -> S0 {
Self(0)
}
}
}

fn main() {}

0 comments on commit ff364b0

Please sign in to comment.