diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs index 6b0b83d2cb5..27bce60df2b 100644 --- a/compiler/rustc_resolve/src/late/diagnostics.rs +++ b/compiler/rustc_resolve/src/late/diagnostics.rs @@ -1807,7 +1807,7 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> { path: &[Segment], ) -> Option<(Span, &'static str, String, Applicability)> { let (ident, span) = match path { - [segment] if !segment.has_generic_args => { + [segment] if !segment.has_generic_args && segment.ident.name != kw::SelfUpper => { (segment.ident.to_string(), segment.ident.span) } _ => return None, diff --git a/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr b/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr index 6063512e294..7e15e42e3cc 100644 --- a/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr +++ b/src/test/ui/type-alias/issue-62364-self-ty-arg.stderr @@ -2,9 +2,8 @@ error[E0411]: cannot find type `Self` in this scope --> $DIR/issue-62364-self-ty-arg.rs:5:29 | LL | type Alias<'a> = Struct<&'a Self>; - | ----- - ^^^^ `Self` is only available in impls, traits, and type definitions - | | | - | | help: you might be missing a type parameter: `, Self` + | ----- ^^^^ `Self` is only available in impls, traits, and type definitions + | | | `Self` not allowed in a type alias error: aborting due to previous error