Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "Validate resolution for SelfCtor too." #111557

Merged
merged 2 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() {}