about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state.rs93
-rw-r--r--compiler/rustc_ast_pretty/src/pprust/state/item.rs28
-rw-r--r--compiler/rustc_parse/src/parser/diagnostics.rs5
-rw-r--r--compiler/rustc_resolve/src/diagnostics.rs2
-rw-r--r--compiler/rustc_resolve/src/late/diagnostics.rs21
-rw-r--r--compiler/rustc_trait_selection/src/lib.rs2
-rw-r--r--compiler/rustc_typeck/src/astconv/mod.rs4
-rw-r--r--library/std/src/collections/hash/map.rs2
-rw-r--r--src/test/pretty/where-clauses.rs3
-rw-r--r--src/test/ui/derives/issue-97343.stderr2
-rw-r--r--src/test/ui/error-codes/E0109.stderr2
-rw-r--r--src/test/ui/error-codes/E0110.stderr2
-rw-r--r--src/test/ui/error-codes/E0411.stderr2
-rw-r--r--src/test/ui/issues/issue-22706.stderr2
-rw-r--r--src/test/ui/issues/issue-57924.stderr2
-rw-r--r--src/test/ui/issues/issue-60989.stderr4
-rw-r--r--src/test/ui/lifetimes/issue-97194.rs2
-rw-r--r--src/test/ui/lifetimes/issue-97194.stderr4
-rw-r--r--src/test/ui/mod-subitem-as-enum-variant.stderr2
-rw-r--r--src/test/ui/resolve/issue-24968.rs25
-rw-r--r--src/test/ui/resolve/issue-24968.stderr56
-rw-r--r--src/test/ui/structs/struct-path-associated-type.stderr4
-rw-r--r--src/test/ui/structs/struct-path-self.stderr6
-rw-r--r--src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr54
-rw-r--r--src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr2
-rw-r--r--src/test/ui/type-alias/issue-62263-self-in-atb.rs2
-rw-r--r--src/test/ui/type-alias/issue-62263-self-in-atb.stderr4
-rw-r--r--src/test/ui/type-alias/issue-62305-self-assoc-ty.rs2
-rw-r--r--src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr4
-rw-r--r--src/test/ui/type-alias/issue-62364-self-ty-arg.stderr6
-rw-r--r--src/test/ui/type/issue-91268.stderr2
-rw-r--r--src/test/ui/typeck/prim-with-args.stderr44
-rw-r--r--src/test/ui/use/use-self-type.rs2
-rw-r--r--src/test/ui/use/use-self-type.stderr6
-rw-r--r--src/test/ui/usize-generic-argument-parent.stderr2
35 files changed, 265 insertions, 140 deletions
diff --git a/compiler/rustc_ast_pretty/src/pprust/state.rs b/compiler/rustc_ast_pretty/src/pprust/state.rs
index b80a553b418..ad8dbfd506d 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state.rs
@@ -814,7 +814,7 @@ pub trait PrintState<'a>: std::ops::Deref<Target = pp::Printer> + std::ops::Dere
     }
 
     fn bounds_to_string(&self, bounds: &[ast::GenericBound]) -> String {
-        Self::to_string(|s| s.print_type_bounds("", bounds))
+        Self::to_string(|s| s.print_type_bounds(bounds))
     }
 
     fn pat_to_string(&self, pat: &ast::Pat) -> String {
@@ -991,7 +991,12 @@ impl<'a> State<'a> {
                     Term::Const(c) => self.print_expr_anon_const(c, &[]),
                 }
             }
-            ast::AssocConstraintKind::Bound { bounds } => self.print_type_bounds(":", &*bounds),
+            ast::AssocConstraintKind::Bound { bounds } => {
+                if !bounds.is_empty() {
+                    self.word_nbsp(":");
+                    self.print_type_bounds(&bounds);
+                }
+            }
         }
     }
 
@@ -1045,11 +1050,14 @@ impl<'a> State<'a> {
             }
             ast::TyKind::Path(Some(ref qself), ref path) => self.print_qpath(path, qself, false),
             ast::TyKind::TraitObject(ref bounds, syntax) => {
-                let prefix = if syntax == ast::TraitObjectSyntax::Dyn { "dyn" } else { "" };
-                self.print_type_bounds(prefix, &bounds);
+                if syntax == ast::TraitObjectSyntax::Dyn {
+                    self.word_nbsp("dyn");
+                }
+                self.print_type_bounds(bounds);
             }
             ast::TyKind::ImplTrait(_, ref bounds) => {
-                self.print_type_bounds("impl", &bounds);
+                self.word_nbsp("impl");
+                self.print_type_bounds(bounds);
             }
             ast::TyKind::Array(ref ty, ref length) => {
                 self.word("[");
@@ -1549,29 +1557,24 @@ impl<'a> State<'a> {
         }
     }
 
-    pub fn print_type_bounds(&mut self, prefix: &'static str, bounds: &[ast::GenericBound]) {
-        if !bounds.is_empty() {
-            self.word(prefix);
-            let mut first = true;
-            for bound in bounds {
-                if !(first && prefix.is_empty()) {
-                    self.nbsp();
-                }
-                if first {
-                    first = false;
-                } else {
-                    self.word_space("+");
-                }
+    pub fn print_type_bounds(&mut self, bounds: &[ast::GenericBound]) {
+        let mut first = true;
+        for bound in bounds {
+            if first {
+                first = false;
+            } else {
+                self.nbsp();
+                self.word_space("+");
+            }
 
-                match bound {
-                    GenericBound::Trait(tref, modifier) => {
-                        if modifier == &TraitBoundModifier::Maybe {
-                            self.word("?");
-                        }
-                        self.print_poly_trait_ref(tref);
+            match bound {
+                GenericBound::Trait(tref, modifier) => {
+                    if modifier == &TraitBoundModifier::Maybe {
+                        self.word("?");
                     }
-                    GenericBound::Outlives(lt) => self.print_lifetime(*lt),
+                    self.print_poly_trait_ref(tref);
                 }
+                GenericBound::Outlives(lt) => self.print_lifetime(*lt),
             }
         }
     }
@@ -1580,22 +1583,14 @@ impl<'a> State<'a> {
         self.print_name(lifetime.ident.name)
     }
 
-    pub(crate) fn print_lifetime_bounds(
-        &mut self,
-        lifetime: ast::Lifetime,
-        bounds: &ast::GenericBounds,
-    ) {
-        self.print_lifetime(lifetime);
-        if !bounds.is_empty() {
-            self.word(": ");
-            for (i, bound) in bounds.iter().enumerate() {
-                if i != 0 {
-                    self.word(" + ");
-                }
-                match bound {
-                    ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
-                    _ => panic!(),
-                }
+    pub(crate) fn print_lifetime_bounds(&mut self, bounds: &ast::GenericBounds) {
+        for (i, bound) in bounds.iter().enumerate() {
+            if i != 0 {
+                self.word(" + ");
+            }
+            match bound {
+                ast::GenericBound::Outlives(lt) => self.print_lifetime(*lt),
+                _ => panic!(),
             }
         }
     }
@@ -1613,11 +1608,18 @@ impl<'a> State<'a> {
             match param.kind {
                 ast::GenericParamKind::Lifetime => {
                     let lt = ast::Lifetime { id: param.id, ident: param.ident };
-                    s.print_lifetime_bounds(lt, &param.bounds)
+                    s.print_lifetime(lt);
+                    if !param.bounds.is_empty() {
+                        s.word_nbsp(":");
+                        s.print_lifetime_bounds(&param.bounds)
+                    }
                 }
                 ast::GenericParamKind::Type { ref default } => {
                     s.print_ident(param.ident);
-                    s.print_type_bounds(":", &param.bounds);
+                    if !param.bounds.is_empty() {
+                        s.word_nbsp(":");
+                        s.print_type_bounds(&param.bounds);
+                    }
                     if let Some(ref default) = default {
                         s.space();
                         s.word_space("=");
@@ -1630,7 +1632,10 @@ impl<'a> State<'a> {
                     s.space();
                     s.word_space(":");
                     s.print_type(ty);
-                    s.print_type_bounds(":", &param.bounds);
+                    if !param.bounds.is_empty() {
+                        s.word_nbsp(":");
+                        s.print_type_bounds(&param.bounds);
+                    }
                     if let Some(ref default) = default {
                         s.space();
                         s.word_space("=");
diff --git a/compiler/rustc_ast_pretty/src/pprust/state/item.rs b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
index 67b539a7ad4..f1caf22f364 100644
--- a/compiler/rustc_ast_pretty/src/pprust/state/item.rs
+++ b/compiler/rustc_ast_pretty/src/pprust/state/item.rs
@@ -114,7 +114,10 @@ impl<'a> State<'a> {
         self.word_space("type");
         self.print_ident(ident);
         self.print_generic_params(&generics.params);
-        self.print_type_bounds(":", bounds);
+        if !bounds.is_empty() {
+            self.word_nbsp(":");
+            self.print_type_bounds(bounds);
+        }
         self.print_where_clause_parts(where_clauses.0.0, before_predicates);
         if let Some(ty) = ty {
             self.space();
@@ -320,7 +323,10 @@ impl<'a> State<'a> {
                         real_bounds.push(b.clone());
                     }
                 }
-                self.print_type_bounds(":", &real_bounds);
+                if !real_bounds.is_empty() {
+                    self.word_nbsp(":");
+                    self.print_type_bounds(&real_bounds);
+                }
                 self.print_where_clause(&generics.where_clause);
                 self.word(" ");
                 self.bopen();
@@ -347,7 +353,10 @@ impl<'a> State<'a> {
                     }
                 }
                 self.nbsp();
-                self.print_type_bounds("=", &real_bounds);
+                if !real_bounds.is_empty() {
+                    self.word_nbsp("=");
+                    self.print_type_bounds(&real_bounds);
+                }
                 self.print_where_clause(&generics.where_clause);
                 self.word(";");
                 self.end(); // end inner head-block
@@ -618,14 +627,23 @@ impl<'a> State<'a> {
             }) => {
                 self.print_formal_generic_params(bound_generic_params);
                 self.print_type(bounded_ty);
-                self.print_type_bounds(":", bounds);
+                self.word(":");
+                if !bounds.is_empty() {
+                    self.nbsp();
+                    self.print_type_bounds(bounds);
+                }
             }
             ast::WherePredicate::RegionPredicate(ast::WhereRegionPredicate {
                 lifetime,
                 bounds,
                 ..
             }) => {
-                self.print_lifetime_bounds(*lifetime, bounds);
+                self.print_lifetime(*lifetime);
+                self.word(":");
+                if !bounds.is_empty() {
+                    self.nbsp();
+                    self.print_lifetime_bounds(bounds);
+                }
             }
             ast::WherePredicate::EqPredicate(ast::WhereEqPredicate { lhs_ty, rhs_ty, .. }) => {
                 self.print_type(lhs_ty);
diff --git a/compiler/rustc_parse/src/parser/diagnostics.rs b/compiler/rustc_parse/src/parser/diagnostics.rs
index acf892cec53..ba325d70422 100644
--- a/compiler/rustc_parse/src/parser/diagnostics.rs
+++ b/compiler/rustc_parse/src/parser/diagnostics.rs
@@ -1355,7 +1355,10 @@ impl<'a> Parser<'a> {
                     s.print_mutability(mut_ty.mutbl, false);
                     s.popen();
                     s.print_type(&mut_ty.ty);
-                    s.print_type_bounds(" +", &bounds);
+                    if !bounds.is_empty() {
+                        s.word(" + ");
+                        s.print_type_bounds(&bounds);
+                    }
                     s.pclose()
                 });
 
diff --git a/compiler/rustc_resolve/src/diagnostics.rs b/compiler/rustc_resolve/src/diagnostics.rs
index e7c8886f054..86dbcba6c0d 100644
--- a/compiler/rustc_resolve/src/diagnostics.rs
+++ b/compiler/rustc_resolve/src/diagnostics.rs
@@ -1914,6 +1914,8 @@ impl<'a> Resolver<'a> {
                 };
             }
             (msg, None)
+        } else if ident.name == kw::SelfUpper {
+            ("`Self` is only available in impls, traits, and type definitions".to_string(), None)
         } else if ident.name.as_str().chars().next().map_or(false, |c| c.is_ascii_uppercase()) {
             // Check whether the name refers to an item in the value namespace.
             let binding = if let Some(ribs) = ribs {
diff --git a/compiler/rustc_resolve/src/late/diagnostics.rs b/compiler/rustc_resolve/src/late/diagnostics.rs
index 1a99bff610a..27bce60df2b 100644
--- a/compiler/rustc_resolve/src/late/diagnostics.rs
+++ b/compiler/rustc_resolve/src/late/diagnostics.rs
@@ -332,6 +332,16 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
                 span,
                 "`Self` is only available in impls, traits, and type definitions".to_string(),
             );
+            if let Some(item_kind) = self.diagnostic_metadata.current_item {
+                err.span_label(
+                    item_kind.ident.span,
+                    format!(
+                        "`Self` not allowed in {} {}",
+                        item_kind.kind.article(),
+                        item_kind.kind.descr()
+                    ),
+                );
+            }
             return (err, Vec::new());
         }
         if is_self_value(path, ns) {
@@ -389,6 +399,15 @@ impl<'a: 'ast, 'ast> LateResolutionVisitor<'a, '_, 'ast> {
                         );
                     }
                 }
+            } else if let Some(item_kind) = self.diagnostic_metadata.current_item {
+                err.span_label(
+                    item_kind.ident.span,
+                    format!(
+                        "`self` not allowed in {} {}",
+                        item_kind.kind.article(),
+                        item_kind.kind.descr()
+                    ),
+                );
             }
             return (err, Vec::new());
         }
@@ -1788,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/compiler/rustc_trait_selection/src/lib.rs b/compiler/rustc_trait_selection/src/lib.rs
index e4da6172916..44ff3fd7306 100644
--- a/compiler/rustc_trait_selection/src/lib.rs
+++ b/compiler/rustc_trait_selection/src/lib.rs
@@ -1,4 +1,4 @@
-//! This crates defines the trait resolution method.
+//! This crate defines the trait resolution method.
 //!
 //! - **Traits.** Trait resolution is implemented in the `traits` module.
 //!
diff --git a/compiler/rustc_typeck/src/astconv/mod.rs b/compiler/rustc_typeck/src/astconv/mod.rs
index 32bbfd7e332..4641b36aad1 100644
--- a/compiler/rustc_typeck/src/astconv/mod.rs
+++ b/compiler/rustc_typeck/src/astconv/mod.rs
@@ -2195,8 +2195,8 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
                 "{kind} arguments are not allowed on {this_type}",
             );
             err.span_label(last_span, format!("{kind} argument{s} not allowed"));
-            for (_, span) in types_and_spans {
-                err.span_label(span, "not allowed on this");
+            for (what, span) in types_and_spans {
+                err.span_label(span, format!("not allowed on {what}"));
             }
             extend(&mut err);
             err.emit();
diff --git a/library/std/src/collections/hash/map.rs b/library/std/src/collections/hash/map.rs
index 192a21f2ffc..237c5ee7340 100644
--- a/library/std/src/collections/hash/map.rs
+++ b/library/std/src/collections/hash/map.rs
@@ -588,7 +588,7 @@ impl<K, V, S> HashMap<K, V, S> {
     ///
     /// If the returned iterator is dropped before being fully consumed, it
     /// drops the remaining key-value pairs. The returned iterator keeps a
-    /// mutable borrow on the vector to optimize its implementation.
+    /// mutable borrow on the map to optimize its implementation.
     ///
     /// # Examples
     ///
diff --git a/src/test/pretty/where-clauses.rs b/src/test/pretty/where-clauses.rs
index 5614a81b0eb..4183799457b 100644
--- a/src/test/pretty/where-clauses.rs
+++ b/src/test/pretty/where-clauses.rs
@@ -2,4 +2,7 @@
 
 fn f<'a, 'b, T>(t: T) -> isize where T: 'a, 'a: 'b, T: Eq { 0 }
 
+// This is legal syntax, sometimes generated by macros. `where T: $($bound+)*`
+fn zero_bounds<'a, T>() where 'a:, T: {}
+
 fn main() {}
diff --git a/src/test/ui/derives/issue-97343.stderr b/src/test/ui/derives/issue-97343.stderr
index ac797a8f501..e83bbb5b60d 100644
--- a/src/test/ui/derives/issue-97343.stderr
+++ b/src/test/ui/derives/issue-97343.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on type parameter `Irrelevant`
 LL | #[derive(Debug)]
    |          -----
    |          |
-   |          not allowed on this
+   |          not allowed on type parameter `Irrelevant`
    |          in this derive macro expansion
 LL | pub struct Irrelevant<Irrelevant> {
    |                       ^^^^^^^^^^ type argument not allowed
diff --git a/src/test/ui/error-codes/E0109.stderr b/src/test/ui/error-codes/E0109.stderr
index 7858a9e3028..da00fdde6bd 100644
--- a/src/test/ui/error-codes/E0109.stderr
+++ b/src/test/ui/error-codes/E0109.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | type X = u32<i32>;
    |          --- ^^^ type argument not allowed
    |          |
-   |          not allowed on this
+   |          not allowed on this type
    |
 help: primitive type `u32` doesn't have generic parameters
    |
diff --git a/src/test/ui/error-codes/E0110.stderr b/src/test/ui/error-codes/E0110.stderr
index 68f98b6f17d..5babb5c2961 100644
--- a/src/test/ui/error-codes/E0110.stderr
+++ b/src/test/ui/error-codes/E0110.stderr
@@ -4,7 +4,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | type X = u32<'static>;
    |          --- ^^^^^^^ lifetime argument not allowed
    |          |
-   |          not allowed on this
+   |          not allowed on this type
    |
 help: primitive type `u32` doesn't have generic parameters
    |
diff --git a/src/test/ui/error-codes/E0411.stderr b/src/test/ui/error-codes/E0411.stderr
index c1c25e835c1..4c99f9fcbf1 100644
--- a/src/test/ui/error-codes/E0411.stderr
+++ b/src/test/ui/error-codes/E0411.stderr
@@ -1,6 +1,8 @@
 error[E0411]: cannot find type `Self` in this scope
   --> $DIR/E0411.rs:2:6
    |
+LL | fn main() {
+   |    ---- `Self` not allowed in a function
 LL |     <Self>::foo;
    |      ^^^^ `Self` is only available in impls, traits, and type definitions
 
diff --git a/src/test/ui/issues/issue-22706.stderr b/src/test/ui/issues/issue-22706.stderr
index 66911f081d7..5366a36b1a6 100644
--- a/src/test/ui/issues/issue-22706.stderr
+++ b/src/test/ui/issues/issue-22706.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on module `marker`
 LL | fn is_copy<T: ::std::marker<i32>::Copy>() {}
    |                      ------ ^^^ type argument not allowed
    |                      |
-   |                      not allowed on this
+   |                      not allowed on module `marker`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-57924.stderr b/src/test/ui/issues/issue-57924.stderr
index 211b0dde48c..0323a4dfb8a 100644
--- a/src/test/ui/issues/issue-57924.stderr
+++ b/src/test/ui/issues/issue-57924.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on self constructor
 LL |         Self::<E>(e)
    |         ----   ^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self constructor
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/issues/issue-60989.stderr b/src/test/ui/issues/issue-60989.stderr
index 9076f4f9385..e0236567b2f 100644
--- a/src/test/ui/issues/issue-60989.stderr
+++ b/src/test/ui/issues/issue-60989.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on local variable
 LL |     c1::<()>;
    |     --   ^^ type argument not allowed
    |     |
-   |     not allowed on this
+   |     not allowed on local variable
 
 error[E0109]: type arguments are not allowed on local variable
   --> $DIR/issue-60989.rs:16:10
@@ -12,7 +12,7 @@ error[E0109]: type arguments are not allowed on local variable
 LL |     c1::<dyn Into<B>>;
    |     --   ^^^^^^^^^^^ type argument not allowed
    |     |
-   |     not allowed on this
+   |     not allowed on local variable
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/lifetimes/issue-97194.rs b/src/test/ui/lifetimes/issue-97194.rs
index accb4a99830..5f3560dbe94 100644
--- a/src/test/ui/lifetimes/issue-97194.rs
+++ b/src/test/ui/lifetimes/issue-97194.rs
@@ -2,7 +2,7 @@ extern "C" {
     fn bget(&self, index: [usize; Self::DIM]) -> bool {
         //~^ ERROR incorrect function inside `extern` block
         //~| ERROR `self` parameter is only allowed in associated functions
-        //~| ERROR use of undeclared type `Self`
+        //~| ERROR failed to resolve: `Self`
         type T<'a> = &'a str;
     }
 }
diff --git a/src/test/ui/lifetimes/issue-97194.stderr b/src/test/ui/lifetimes/issue-97194.stderr
index 15ad5aadf9f..93bde285a99 100644
--- a/src/test/ui/lifetimes/issue-97194.stderr
+++ b/src/test/ui/lifetimes/issue-97194.stderr
@@ -25,11 +25,11 @@ LL |     fn bget(&self, index: [usize; Self::DIM]) -> bool {
    |
    = note: associated functions are those in `impl` or `trait` definitions
 
-error[E0433]: failed to resolve: use of undeclared type `Self`
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
   --> $DIR/issue-97194.rs:2:35
    |
 LL |     fn bget(&self, index: [usize; Self::DIM]) -> bool {
-   |                                   ^^^^ use of undeclared type `Self`
+   |                                   ^^^^ `Self` is only available in impls, traits, and type definitions
 
 error: aborting due to 3 previous errors
 
diff --git a/src/test/ui/mod-subitem-as-enum-variant.stderr b/src/test/ui/mod-subitem-as-enum-variant.stderr
index 15da1d155a3..cf61e94bd86 100644
--- a/src/test/ui/mod-subitem-as-enum-variant.stderr
+++ b/src/test/ui/mod-subitem-as-enum-variant.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on module `Mod`
 LL |     Mod::<i32>::FakeVariant(0);
    |     ---   ^^^ type argument not allowed
    |     |
-   |     not allowed on this
+   |     not allowed on module `Mod`
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/resolve/issue-24968.rs b/src/test/ui/resolve/issue-24968.rs
index 916b48205dc..19e16abcee3 100644
--- a/src/test/ui/resolve/issue-24968.rs
+++ b/src/test/ui/resolve/issue-24968.rs
@@ -1,5 +1,30 @@
+// Also includes more Self usages per #93796
+
 fn foo(_: Self) {
 //~^ ERROR cannot find type `Self`
 }
 
+fn foo2() {
+    let x: Self;
+    //~^ ERROR cannot find type `Self`
+}
+
+type Foo<T>
+where
+    Self: Clone,
+//~^ ERROR cannot find type `Self`
+= Vec<T>;
+
+const FOO: Self = 0;
+//~^ ERROR cannot find type `Self`
+
+const FOO2: u32 = Self::bar();
+//~^ ERROR failed to resolve: `Self`
+
+static FOO_S: Self = 0;
+//~^ ERROR cannot find type `Self`
+
+static FOO_S2: u32 = Self::bar();
+//~^ ERROR failed to resolve: `Self`
+
 fn main() {}
diff --git a/src/test/ui/resolve/issue-24968.stderr b/src/test/ui/resolve/issue-24968.stderr
index c891952c42b..7e539d25804 100644
--- a/src/test/ui/resolve/issue-24968.stderr
+++ b/src/test/ui/resolve/issue-24968.stderr
@@ -1,9 +1,57 @@
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
+  --> $DIR/issue-24968.rs:21:19
+   |
+LL | const FOO2: u32 = Self::bar();
+   |                   ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
+  --> $DIR/issue-24968.rs:27:22
+   |
+LL | static FOO_S2: u32 = Self::bar();
+   |                      ^^^^ `Self` is only available in impls, traits, and type definitions
+
 error[E0411]: cannot find type `Self` in this scope
-  --> $DIR/issue-24968.rs:1:11
+  --> $DIR/issue-24968.rs:3:11
    |
 LL | fn foo(_: Self) {
-   |           ^^^^ `Self` is only available in impls, traits, and type definitions
+   |    ---    ^^^^ `Self` is only available in impls, traits, and type definitions
+   |    |
+   |    `Self` not allowed in a function
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:8:12
+   |
+LL | fn foo2() {
+   |    ---- `Self` not allowed in a function
+LL |     let x: Self;
+   |            ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:14:5
+   |
+LL | type Foo<T>
+   |      --- `Self` not allowed in a type alias
+LL | where
+LL |     Self: Clone,
+   |     ^^^^ `Self` is only available in impls, traits, and type definitions
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:18:12
+   |
+LL | const FOO: Self = 0;
+   |       ---  ^^^^ `Self` is only available in impls, traits, and type definitions
+   |       |
+   |       `Self` not allowed in a constant item
+
+error[E0411]: cannot find type `Self` in this scope
+  --> $DIR/issue-24968.rs:24:15
+   |
+LL | static FOO_S: Self = 0;
+   |        -----  ^^^^ `Self` is only available in impls, traits, and type definitions
+   |        |
+   |        `Self` not allowed in a static item
 
-error: aborting due to previous error
+error: aborting due to 7 previous errors
 
-For more information about this error, try `rustc --explain E0411`.
+Some errors have detailed explanations: E0411, E0433.
+For more information about an error, try `rustc --explain E0411`.
diff --git a/src/test/ui/structs/struct-path-associated-type.stderr b/src/test/ui/structs/struct-path-associated-type.stderr
index 7424ceecbe3..bdce0e1b331 100644
--- a/src/test/ui/structs/struct-path-associated-type.stderr
+++ b/src/test/ui/structs/struct-path-associated-type.stderr
@@ -10,7 +10,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     let z = T::A::<u8> {};
    |                -   ^^ type argument not allowed
    |                |
-   |                not allowed on this
+   |                not allowed on this type
 
 error[E0071]: expected struct, variant or union type, found associated type
   --> $DIR/struct-path-associated-type.rs:14:13
@@ -30,7 +30,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     let z = T::A::<u8> {};
    |                -   ^^ type argument not allowed
    |                |
-   |                not allowed on this
+   |                not allowed on this type
 
 error[E0223]: ambiguous associated type
   --> $DIR/struct-path-associated-type.rs:32:13
diff --git a/src/test/ui/structs/struct-path-self.stderr b/src/test/ui/structs/struct-path-self.stderr
index 4bd0fb38985..c2a8623f9b4 100644
--- a/src/test/ui/structs/struct-path-self.stderr
+++ b/src/test/ui/structs/struct-path-self.stderr
@@ -10,7 +10,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         let z = Self::<u8> {};
    |                 ----   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on self type
    |
 help: the `Self` type doesn't accept type parameters
    |
@@ -36,7 +36,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         let z = Self::<u8> {};
    |                 ----   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on self type
    |
 note: `Self` is of type `S`
   --> $DIR/struct-path-self.rs:1:8
@@ -58,7 +58,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         let z = Self::<u8> {};
    |                 ----   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on self type
    |
 note: `Self` is of type `S`
   --> $DIR/struct-path-self.rs:1:8
diff --git a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
index cfc596e1b78..9601bdce4c5 100644
--- a/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
+++ b/src/test/ui/type-alias-enum-variants/enum-variant-generic-args.stderr
@@ -23,7 +23,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |         Self::TSVariant::<()>(());
    |               ---------   ^^ type argument not allowed
    |               |
-   |               not allowed on this
+   |               not allowed on this type
 
 error[E0109]: type arguments are not allowed on self type
   --> $DIR/enum-variant-generic-args.rs:17:16
@@ -31,7 +31,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         Self::<()>::TSVariant(());
    |         ----   ^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self type
    |
 note: `Self` is of type `Enum<T>`
   --> $DIR/enum-variant-generic-args.rs:7:6
@@ -71,7 +71,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         Self::<()>::TSVariant::<()>(());
    |         ----   ^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self type
    |
 note: `Self` is of type `Enum<T>`
   --> $DIR/enum-variant-generic-args.rs:7:6
@@ -92,7 +92,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |         Self::<()>::TSVariant::<()>(());
    |                     ---------   ^^ type argument not allowed
    |                     |
-   |                     not allowed on this
+   |                     not allowed on this type
 
 error[E0308]: mismatched types
   --> $DIR/enum-variant-generic-args.rs:26:29
@@ -112,7 +112,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |         Self::SVariant::<()> { v: () };
    |               --------   ^^ type argument not allowed
    |               |
-   |               not allowed on this
+   |               not allowed on this type
    |
    = note: enum variants can't have type parameters
 help: you might have meant to specity type parameters on enum `Enum`
@@ -139,7 +139,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         Self::<()>::SVariant { v: () };
    |         ----   ^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self type
    |
 note: `Self` is of type `Enum<T>`
   --> $DIR/enum-variant-generic-args.rs:7:6
@@ -172,7 +172,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         Self::<()>::SVariant::<()> { v: () };
    |         ----   ^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self type
    |
 note: `Self` is of type `Enum<T>`
   --> $DIR/enum-variant-generic-args.rs:7:6
@@ -193,7 +193,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |         Self::<()>::SVariant::<()> { v: () };
    |                     --------   ^^ type argument not allowed
    |                     |
-   |                     not allowed on this
+   |                     not allowed on this type
    |
    = note: enum variants can't have type parameters
 help: you might have meant to specity type parameters on enum `Enum`
@@ -220,7 +220,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |         Self::UVariant::<()>;
    |               --------   ^^ type argument not allowed
    |               |
-   |               not allowed on this
+   |               not allowed on this type
 
 error[E0109]: type arguments are not allowed on self type
   --> $DIR/enum-variant-generic-args.rs:43:16
@@ -228,7 +228,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         Self::<()>::UVariant;
    |         ----   ^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self type
    |
 note: `Self` is of type `Enum<T>`
   --> $DIR/enum-variant-generic-args.rs:7:6
@@ -249,7 +249,7 @@ error[E0109]: type arguments are not allowed on self type
 LL |         Self::<()>::UVariant::<()>;
    |         ----   ^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on self type
    |
 note: `Self` is of type `Enum<T>`
   --> $DIR/enum-variant-generic-args.rs:7:6
@@ -270,7 +270,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |         Self::<()>::UVariant::<()>;
    |                     --------   ^^ type argument not allowed
    |                     |
-   |                     not allowed on this
+   |                     not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:54:29
@@ -278,7 +278,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Enum::<()>::TSVariant::<()>(());
    |                 ---------   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:57:24
@@ -286,7 +286,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Alias::TSVariant::<()>(());
    |            ---------   ^^ type argument not allowed
    |            |
-   |            not allowed on this
+   |            not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:59:30
@@ -294,7 +294,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Alias::<()>::TSVariant::<()>(());
    |                  ---------   ^^ type argument not allowed
    |                  |
-   |                  not allowed on this
+   |                  not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:62:29
@@ -302,7 +302,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     AliasFixed::TSVariant::<()>(());
    |                 ---------   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on this type
 
 error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:64:5
@@ -338,7 +338,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     AliasFixed::<()>::TSVariant::<()>(());
    |                       ---------   ^^ type argument not allowed
    |                       |
-   |                       not allowed on this
+   |                       not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:72:28
@@ -346,7 +346,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Enum::<()>::SVariant::<()> { v: () };
    |                 --------   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on this type
    |
    = note: enum variants can't have type parameters
 
@@ -356,7 +356,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Alias::SVariant::<()> { v: () };
    |            --------   ^^ type argument not allowed
    |            |
-   |            not allowed on this
+   |            not allowed on this type
    |
    = note: enum variants can't have type parameters
 help: you might have meant to specity type parameters on enum `Enum`
@@ -371,7 +371,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Alias::<()>::SVariant::<()> { v: () };
    |                  --------   ^^ type argument not allowed
    |                  |
-   |                  not allowed on this
+   |                  not allowed on this type
    |
    = note: enum variants can't have type parameters
 help: you might have meant to specity type parameters on enum `Enum`
@@ -386,7 +386,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     AliasFixed::SVariant::<()> { v: () };
    |                 --------   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on this type
    |
    = note: enum variants can't have type parameters
 help: you might have meant to specity type parameters on enum `Enum`
@@ -429,7 +429,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     AliasFixed::<()>::SVariant::<()> { v: () };
    |                       --------   ^^ type argument not allowed
    |                       |
-   |                       not allowed on this
+   |                       not allowed on this type
    |
    = note: enum variants can't have type parameters
 help: you might have meant to specity type parameters on enum `Enum`
@@ -444,7 +444,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Enum::<()>::UVariant::<()>;
    |                 --------   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:93:23
@@ -452,7 +452,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Alias::UVariant::<()>;
    |            --------   ^^ type argument not allowed
    |            |
-   |            not allowed on this
+   |            not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:95:29
@@ -460,7 +460,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     Alias::<()>::UVariant::<()>;
    |                  --------   ^^ type argument not allowed
    |                  |
-   |                  not allowed on this
+   |                  not allowed on this type
 
 error[E0109]: type arguments are not allowed on this type
   --> $DIR/enum-variant-generic-args.rs:98:28
@@ -468,7 +468,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     AliasFixed::UVariant::<()>;
    |                 --------   ^^ type argument not allowed
    |                 |
-   |                 not allowed on this
+   |                 not allowed on this type
 
 error[E0107]: this type alias takes 0 generic arguments but 1 generic argument was supplied
   --> $DIR/enum-variant-generic-args.rs:100:5
@@ -504,7 +504,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     AliasFixed::<()>::UVariant::<()>;
    |                       --------   ^^ type argument not allowed
    |                       |
-   |                       not allowed on this
+   |                       not allowed on this type
 
 error: aborting due to 39 previous errors
 
diff --git a/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr b/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr
index 474548a14a9..51b1c8a1068 100644
--- a/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr
+++ b/src/test/ui/type-alias-enum-variants/no-type-application-on-aliased-enum-variant.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     let _ = Alias::None::<u8>;
    |                    ----   ^^ type argument not allowed
    |                    |
-   |                    not allowed on this
+   |                    not allowed on this type
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias/issue-62263-self-in-atb.rs b/src/test/ui/type-alias/issue-62263-self-in-atb.rs
index 1f64b4cfe5c..91522d8912f 100644
--- a/src/test/ui/type-alias/issue-62263-self-in-atb.rs
+++ b/src/test/ui/type-alias/issue-62263-self-in-atb.rs
@@ -3,6 +3,6 @@ pub trait Trait {
 }
 
 pub type Alias = dyn Trait<A = Self::A>;
-//~^ ERROR failed to resolve: use of undeclared type `Self` [E0433]
+//~^ ERROR failed to resolve: `Self`
 
 fn main() {}
diff --git a/src/test/ui/type-alias/issue-62263-self-in-atb.stderr b/src/test/ui/type-alias/issue-62263-self-in-atb.stderr
index d34b6ed5038..c20074dc27c 100644
--- a/src/test/ui/type-alias/issue-62263-self-in-atb.stderr
+++ b/src/test/ui/type-alias/issue-62263-self-in-atb.stderr
@@ -1,8 +1,8 @@
-error[E0433]: failed to resolve: use of undeclared type `Self`
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
   --> $DIR/issue-62263-self-in-atb.rs:5:32
    |
 LL | pub type Alias = dyn Trait<A = Self::A>;
-   |                                ^^^^ use of undeclared type `Self`
+   |                                ^^^^ `Self` is only available in impls, traits, and type definitions
 
 error: aborting due to previous error
 
diff --git a/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs b/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs
index 999902fb18b..a4d9a285485 100644
--- a/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs
+++ b/src/test/ui/type-alias/issue-62305-self-assoc-ty.rs
@@ -1,4 +1,4 @@
 type Alias = Self::Target;
-//~^ ERROR failed to resolve: use of undeclared type `Self` [E0433]
+//~^ ERROR failed to resolve: `Self`
 
 fn main() {}
diff --git a/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr b/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr
index 823a5fa50fc..f3da50df926 100644
--- a/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr
+++ b/src/test/ui/type-alias/issue-62305-self-assoc-ty.stderr
@@ -1,8 +1,8 @@
-error[E0433]: failed to resolve: use of undeclared type `Self`
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
   --> $DIR/issue-62305-self-assoc-ty.rs:1:14
    |
 LL | type Alias = Self::Target;
-   |              ^^^^ use of undeclared type `Self`
+   |              ^^^^ `Self` is only available in impls, traits, and type definitions
 
 error: aborting due to previous error
 
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 cae41672ead..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,9 @@ 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
 
diff --git a/src/test/ui/type/issue-91268.stderr b/src/test/ui/type/issue-91268.stderr
index 1df5a2cf07b..e426f450b11 100644
--- a/src/test/ui/type/issue-91268.stderr
+++ b/src/test/ui/type/issue-91268.stderr
@@ -41,7 +41,7 @@ error[E0109]: type arguments are not allowed on this type
 LL |     0: u8(ţ
    |        -- ^ type argument not allowed
    |        |
-   |        not allowed on this
+   |        not allowed on this type
    |
 help: primitive type `u8` doesn't have generic parameters
    |
diff --git a/src/test/ui/typeck/prim-with-args.stderr b/src/test/ui/typeck/prim-with-args.stderr
index cdc7e96bfc5..c45fd00bae9 100644
--- a/src/test/ui/typeck/prim-with-args.stderr
+++ b/src/test/ui/typeck/prim-with-args.stderr
@@ -4,7 +4,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: isize<isize>;
    |         ----- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `isize` doesn't have generic parameters
    |
@@ -18,7 +18,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: i8<isize>;
    |         -- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i8` doesn't have generic parameters
    |
@@ -32,7 +32,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: i16<isize>;
    |         --- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i16` doesn't have generic parameters
    |
@@ -46,7 +46,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: i32<isize>;
    |         --- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i32` doesn't have generic parameters
    |
@@ -60,7 +60,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: i64<isize>;
    |         --- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i64` doesn't have generic parameters
    |
@@ -74,7 +74,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: usize<isize>;
    |         ----- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `usize` doesn't have generic parameters
    |
@@ -88,7 +88,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: u8<isize>;
    |         -- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u8` doesn't have generic parameters
    |
@@ -102,7 +102,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: u16<isize>;
    |         --- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u16` doesn't have generic parameters
    |
@@ -116,7 +116,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: u32<isize>;
    |         --- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u32` doesn't have generic parameters
    |
@@ -130,7 +130,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: u64<isize>;
    |         --- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u64` doesn't have generic parameters
    |
@@ -144,7 +144,7 @@ error[E0109]: type arguments are not allowed on this type
 LL | let _x: char<isize>;
    |         ---- ^^^^^ type argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `char` doesn't have generic parameters
    |
@@ -158,7 +158,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: isize<'static>;
    |         ----- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `isize` doesn't have generic parameters
    |
@@ -172,7 +172,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: i8<'static>;
    |         -- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i8` doesn't have generic parameters
    |
@@ -186,7 +186,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: i16<'static>;
    |         --- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i16` doesn't have generic parameters
    |
@@ -200,7 +200,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: i32<'static>;
    |         --- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i32` doesn't have generic parameters
    |
@@ -214,7 +214,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: i64<'static>;
    |         --- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `i64` doesn't have generic parameters
    |
@@ -228,7 +228,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: usize<'static>;
    |         ----- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `usize` doesn't have generic parameters
    |
@@ -242,7 +242,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: u8<'static>;
    |         -- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u8` doesn't have generic parameters
    |
@@ -256,7 +256,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: u16<'static>;
    |         --- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u16` doesn't have generic parameters
    |
@@ -270,7 +270,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: u32<'static>;
    |         --- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u32` doesn't have generic parameters
    |
@@ -284,7 +284,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: u64<'static>;
    |         --- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `u64` doesn't have generic parameters
    |
@@ -298,7 +298,7 @@ error[E0109]: lifetime arguments are not allowed on this type
 LL | let _x: char<'static>;
    |         ---- ^^^^^^^ lifetime argument not allowed
    |         |
-   |         not allowed on this
+   |         not allowed on this type
    |
 help: primitive type `char` doesn't have generic parameters
    |
diff --git a/src/test/ui/use/use-self-type.rs b/src/test/ui/use/use-self-type.rs
index 370593b2eb2..3b4ce429701 100644
--- a/src/test/ui/use/use-self-type.rs
+++ b/src/test/ui/use/use-self-type.rs
@@ -4,7 +4,7 @@ impl S {
     fn f() {}
     fn g() {
         use Self::f; //~ ERROR unresolved import
-        pub(in Self::f) struct Z; //~ ERROR use of undeclared type `Self`
+        pub(in Self::f) struct Z; //~ ERROR failed to resolve: `Self`
     }
 }
 
diff --git a/src/test/ui/use/use-self-type.stderr b/src/test/ui/use/use-self-type.stderr
index d1469fb3490..e6153941151 100644
--- a/src/test/ui/use/use-self-type.stderr
+++ b/src/test/ui/use/use-self-type.stderr
@@ -1,14 +1,14 @@
-error[E0433]: failed to resolve: use of undeclared type `Self`
+error[E0433]: failed to resolve: `Self` is only available in impls, traits, and type definitions
   --> $DIR/use-self-type.rs:7:16
    |
 LL |         pub(in Self::f) struct Z;
-   |                ^^^^ use of undeclared type `Self`
+   |                ^^^^ `Self` is only available in impls, traits, and type definitions
 
 error[E0432]: unresolved import `Self`
   --> $DIR/use-self-type.rs:6:13
    |
 LL |         use Self::f;
-   |             ^^^^ use of undeclared type `Self`
+   |             ^^^^ `Self` is only available in impls, traits, and type definitions
 
 error: aborting due to 2 previous errors
 
diff --git a/src/test/ui/usize-generic-argument-parent.stderr b/src/test/ui/usize-generic-argument-parent.stderr
index b3980101104..abe8c09b739 100644
--- a/src/test/ui/usize-generic-argument-parent.stderr
+++ b/src/test/ui/usize-generic-argument-parent.stderr
@@ -4,7 +4,7 @@ error[E0109]: const arguments are not allowed on this type
 LL |     let x: usize<foo>;
    |            ----- ^^^ const argument not allowed
    |            |
-   |            not allowed on this
+   |            not allowed on this type
    |
 help: primitive type `usize` doesn't have generic parameters
    |