about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMatthias Krüger <476013+matthiaskrgr@users.noreply.github.com>2025-07-01 04:25:36 +0200
committerGitHub <noreply@github.com>2025-07-01 04:25:36 +0200
commite2ea213874477e0874af598eecdb730ef2a52b32 (patch)
tree88e4834d7c646033dd1b932bb830dfdf1d6f943a
parent79e96c0dc580d511e2327c30b17001774a2721ae (diff)
parent74fda50f3b8b9cd3ad05c5f2f5c8cef8a14aad88 (diff)
downloadrust-e2ea213874477e0874af598eecdb730ef2a52b32.tar.gz
rust-e2ea213874477e0874af598eecdb730ef2a52b32.zip
Rollup merge of #143234 - GuillaumeGomez:ice-143128, r=oli-obk
Replace `ItemCtxt::report_placeholder_type_error` match with a call to `TyCtxt::def_descr`

Fixes rust-lang/rust#143128.

We could likely use `tcx.def_descr` in more places (and therefore remove more `descr` methods). If it's something that we want to do, I can send a follow-up.

r? `@oli-obk`
-rw-r--r--compiler/rustc_hir/src/hir.rs28
-rw-r--r--compiler/rustc_hir_analysis/src/collect.rs12
-rw-r--r--tests/rustdoc-ui/invalid_infered_static_and_const.stderr4
-rw-r--r--tests/ui/closures/missing-body.rs7
-rw-r--r--tests/ui/closures/missing-body.stderr19
-rw-r--r--tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr2
-rw-r--r--tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr2
-rw-r--r--tests/ui/did_you_mean/bad-assoc-ty.rs2
-rw-r--r--tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed2
-rw-r--r--tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs2
-rw-r--r--tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr2
-rw-r--r--tests/ui/fn/error-recovery-mismatch.stderr2
-rw-r--r--tests/ui/self/self-infer.rs4
-rw-r--r--tests/ui/self/self-infer.stderr4
-rw-r--r--tests/ui/suggestions/bad-infer-in-trait-impl.rs2
-rw-r--r--tests/ui/suggestions/bad-infer-in-trait-impl.stderr2
-rw-r--r--tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr2
-rw-r--r--tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr2
-rw-r--r--tests/ui/typeck/issue-74086.rs2
-rw-r--r--tests/ui/typeck/issue-74086.stderr2
-rw-r--r--tests/ui/typeck/issue-75889.stderr4
-rw-r--r--tests/ui/typeck/issue-81885.rs4
-rw-r--r--tests/ui/typeck/issue-81885.stderr4
-rw-r--r--tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr2
-rw-r--r--tests/ui/typeck/issue-88643.rs6
-rw-r--r--tests/ui/typeck/issue-88643.stderr6
-rw-r--r--tests/ui/typeck/typeck_type_placeholder_item.rs28
-rw-r--r--tests/ui/typeck/typeck_type_placeholder_item.stderr28
-rw-r--r--tests/ui/typeck/typeck_type_placeholder_item_help.rs2
-rw-r--r--tests/ui/typeck/typeck_type_placeholder_item_help.stderr2
30 files changed, 89 insertions, 101 deletions
diff --git a/compiler/rustc_hir/src/hir.rs b/compiler/rustc_hir/src/hir.rs
index 75dff588669..88e0ee1cc0b 100644
--- a/compiler/rustc_hir/src/hir.rs
+++ b/compiler/rustc_hir/src/hir.rs
@@ -3141,15 +3141,6 @@ pub enum TraitItemKind<'hir> {
     /// type.
     Type(GenericBounds<'hir>, Option<&'hir Ty<'hir>>),
 }
-impl TraitItemKind<'_> {
-    pub fn descr(&self) -> &'static str {
-        match self {
-            TraitItemKind::Const(..) => "associated constant",
-            TraitItemKind::Fn(..) => "function",
-            TraitItemKind::Type(..) => "associated type",
-        }
-    }
-}
 
 // The bodies for items are stored "out of line", in a separate
 // hashmap in the `Crate`. Here we just record the hir-id of the item
@@ -3211,15 +3202,6 @@ pub enum ImplItemKind<'hir> {
     /// An associated type.
     Type(&'hir Ty<'hir>),
 }
-impl ImplItemKind<'_> {
-    pub fn descr(&self) -> &'static str {
-        match self {
-            ImplItemKind::Const(..) => "associated constant",
-            ImplItemKind::Fn(..) => "function",
-            ImplItemKind::Type(..) => "associated type",
-        }
-    }
-}
 
 /// A constraint on an associated item.
 ///
@@ -4545,16 +4527,6 @@ pub enum ForeignItemKind<'hir> {
     Type,
 }
 
-impl ForeignItemKind<'_> {
-    pub fn descr(&self) -> &'static str {
-        match self {
-            ForeignItemKind::Fn(..) => "function",
-            ForeignItemKind::Static(..) => "static variable",
-            ForeignItemKind::Type => "type",
-        }
-    }
-}
-
 /// A variable captured by a closure.
 #[derive(Debug, Copy, Clone, HashStable_Generic)]
 pub struct Upvar {
diff --git a/compiler/rustc_hir_analysis/src/collect.rs b/compiler/rustc_hir_analysis/src/collect.rs
index d7568554669..3ee39fb71b2 100644
--- a/compiler/rustc_hir_analysis/src/collect.rs
+++ b/compiler/rustc_hir_analysis/src/collect.rs
@@ -277,17 +277,7 @@ impl<'tcx> ItemCtxt<'tcx> {
             }
             _ => self.item_def_id,
         };
-        // FIXME: just invoke `tcx.def_descr` instead of going through the HIR
-        // Can also remove most `descr` methods then.
-        let kind = match self.tcx.hir_node_by_def_id(kind_id) {
-            Node::Item(it) => it.kind.descr(),
-            Node::ImplItem(it) => it.kind.descr(),
-            Node::TraitItem(it) => it.kind.descr(),
-            Node::ForeignItem(it) => it.kind.descr(),
-            Node::OpaqueTy(_) => "opaque type",
-            Node::Synthetic => self.tcx.def_descr(kind_id.into()),
-            node => todo!("{node:#?}"),
-        };
+        let kind = self.tcx.def_descr(kind_id.into());
         let mut diag = placeholder_type_error_diag(
             self,
             generics,
diff --git a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr
index 401020224d6..3e116826c49 100644
--- a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr
+++ b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr
@@ -1,10 +1,10 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
   --> $DIR/invalid_infered_static_and_const.rs:1:24
    |
 LL | const FOO: dyn Fn() -> _ = "";
    |                        ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/invalid_infered_static_and_const.rs:2:25
    |
 LL | static BOO: dyn Fn() -> _ = "";
diff --git a/tests/ui/closures/missing-body.rs b/tests/ui/closures/missing-body.rs
new file mode 100644
index 00000000000..461c2be3ccd
--- /dev/null
+++ b/tests/ui/closures/missing-body.rs
@@ -0,0 +1,7 @@
+// Checks that the compiler complains about the missing closure body and does not
+// crash.
+// This is a regression test for <https://github.com/rust-lang/rust/issues/143128>.
+
+fn main() { |b: [str; _]| {}; }
+//~^ ERROR the placeholder `_` is not allowed within types on item signatures for closures
+//~| ERROR the size for values of type `str` cannot be known at compilation time
diff --git a/tests/ui/closures/missing-body.stderr b/tests/ui/closures/missing-body.stderr
new file mode 100644
index 00000000000..33580fc2fbd
--- /dev/null
+++ b/tests/ui/closures/missing-body.stderr
@@ -0,0 +1,19 @@
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for closures
+  --> $DIR/missing-body.rs:5:23
+   |
+LL | fn main() { |b: [str; _]| {}; }
+   |                       ^ not allowed in type signatures
+
+error[E0277]: the size for values of type `str` cannot be known at compilation time
+  --> $DIR/missing-body.rs:5:17
+   |
+LL | fn main() { |b: [str; _]| {}; }
+   |                 ^^^^^^^^ doesn't have a size known at compile-time
+   |
+   = help: the trait `Sized` is not implemented for `str`
+   = note: slice and array elements must have `Sized` type
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0121, E0277.
+For more information about an error, try `rustc --explain E0121`.
diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr
index fe1ce5ad18b..ed6e5c3e0c0 100644
--- a/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr
+++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr
@@ -302,7 +302,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
 LL | trait P<F> where F: Fn() -> _ {
    |                             ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/bad-assoc-ty.rs:88:38
    |
 LL |     fn foo<F>(_: F) where F: Fn() -> _ {}
diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr
index 2cf7a150aa2..2ee8ab2760a 100644
--- a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr
+++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr
@@ -284,7 +284,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
 LL | trait P<F> where F: Fn() -> _ {
    |                             ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/bad-assoc-ty.rs:88:38
    |
 LL |     fn foo<F>(_: F) where F: Fn() -> _ {}
diff --git a/tests/ui/did_you_mean/bad-assoc-ty.rs b/tests/ui/did_you_mean/bad-assoc-ty.rs
index 9abda4fd962..39f0a84855a 100644
--- a/tests/ui/did_you_mean/bad-assoc-ty.rs
+++ b/tests/ui/did_you_mean/bad-assoc-ty.rs
@@ -86,7 +86,7 @@ trait P<F> where F: Fn() -> _ {
 
 trait Q {
     fn foo<F>(_: F) where F: Fn() -> _ {}
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
 }
 
 fn main() {}
diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed
index db18cf2ad96..0096d3eaea4 100644
--- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed
+++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed
@@ -7,7 +7,7 @@ trait Foo<T>: Sized {
 
 impl Foo<usize> for () {
     fn bar(i: i32, t: usize, s: &()) -> (usize, i32) {
-        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
         //~| ERROR type annotations needed
         (1, 2)
     }
diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs
index 1217a96112d..9ebc565b8fd 100644
--- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs
+++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs
@@ -7,7 +7,7 @@ trait Foo<T>: Sized {
 
 impl Foo<usize> for () {
     fn bar(i: _, t: _, s: _) -> _ {
-        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
         //~| ERROR type annotations needed
         (1, 2)
     }
diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr
index 6c24a5899ea..3c11ad0cf29 100644
--- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr
+++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr
@@ -1,4 +1,4 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/replace-impl-infer-ty-from-trait.rs:9:15
    |
 LL |     fn bar(i: _, t: _, s: _) -> _ {
diff --git a/tests/ui/fn/error-recovery-mismatch.stderr b/tests/ui/fn/error-recovery-mismatch.stderr
index c046302cb91..10dab3052be 100644
--- a/tests/ui/fn/error-recovery-mismatch.stderr
+++ b/tests/ui/fn/error-recovery-mismatch.stderr
@@ -29,7 +29,7 @@ LL |     fn fold<T>(&self, _: T, &self._) {}
    = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686>
    = note: `#[warn(anonymous_parameters)]` on by default
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/error-recovery-mismatch.rs:11:35
    |
 LL |     fn fold<T>(&self, _: T, &self._) {}
diff --git a/tests/ui/self/self-infer.rs b/tests/ui/self/self-infer.rs
index 9839b8880e9..d6f6d8bfa06 100644
--- a/tests/ui/self/self-infer.rs
+++ b/tests/ui/self/self-infer.rs
@@ -1,8 +1,8 @@
 struct S;
 
 impl S {
-    fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions
-    fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for methods
+    fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for methods
 }
 
 fn main() {}
diff --git a/tests/ui/self/self-infer.stderr b/tests/ui/self/self-infer.stderr
index f9db559390f..13d803d9559 100644
--- a/tests/ui/self/self-infer.stderr
+++ b/tests/ui/self/self-infer.stderr
@@ -1,10 +1,10 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/self-infer.rs:4:16
    |
 LL |     fn f(self: _) {}
    |                ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/self-infer.rs:5:17
    |
 LL |     fn g(self: &_) {}
diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.rs b/tests/ui/suggestions/bad-infer-in-trait-impl.rs
index f38b168037b..db6fc9319e1 100644
--- a/tests/ui/suggestions/bad-infer-in-trait-impl.rs
+++ b/tests/ui/suggestions/bad-infer-in-trait-impl.rs
@@ -4,7 +4,7 @@ trait Foo {
 
 impl Foo for () {
     fn bar(s: _) {}
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
     //~| ERROR has 1 parameter but the declaration in trait `Foo::bar` has 0
 }
 
diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr
index 8b7d67ac041..5aa46545943 100644
--- a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr
+++ b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr
@@ -1,4 +1,4 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/bad-infer-in-trait-impl.rs:6:15
    |
 LL |     fn bar(s: _) {}
diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr
index c6e0c699520..a165ef12060 100644
--- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr
+++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr
@@ -16,7 +16,7 @@ LL | impl<T> const FromResidual for T {
    = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local
    = note: only traits defined in the current crate can be implemented for a type parameter
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/ice-119717-constant-lifetime.rs:9:31
    |
 LL |     fn from_residual(t: T) -> _ {
diff --git a/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr b/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr
index d535c39639f..6472ac7363b 100644
--- a/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr
+++ b/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr
@@ -1,4 +1,4 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:23
    |
 LL |     fn deserialize(s: _) {}
diff --git a/tests/ui/typeck/issue-74086.rs b/tests/ui/typeck/issue-74086.rs
index 1993cc7db35..c00ba81f551 100644
--- a/tests/ui/typeck/issue-74086.rs
+++ b/tests/ui/typeck/issue-74086.rs
@@ -1,4 +1,4 @@
 fn main() {
     static BUG: fn(_) -> u8 = |_| 8;
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static items
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for statics
 }
diff --git a/tests/ui/typeck/issue-74086.stderr b/tests/ui/typeck/issue-74086.stderr
index 25f454ac0c3..02c48201918 100644
--- a/tests/ui/typeck/issue-74086.stderr
+++ b/tests/ui/typeck/issue-74086.stderr
@@ -1,4 +1,4 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/issue-74086.rs:2:20
    |
 LL |     static BUG: fn(_) -> u8 = |_| 8;
diff --git a/tests/ui/typeck/issue-75889.stderr b/tests/ui/typeck/issue-75889.stderr
index 1438f481ec7..c76f7c60b2e 100644
--- a/tests/ui/typeck/issue-75889.stderr
+++ b/tests/ui/typeck/issue-75889.stderr
@@ -1,10 +1,10 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
   --> $DIR/issue-75889.rs:3:24
    |
 LL | const FOO: dyn Fn() -> _ = "";
    |                        ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/issue-75889.rs:4:25
    |
 LL | static BOO: dyn Fn() -> _ = "";
diff --git a/tests/ui/typeck/issue-81885.rs b/tests/ui/typeck/issue-81885.rs
index d73c77b8f3a..d675231d898 100644
--- a/tests/ui/typeck/issue-81885.rs
+++ b/tests/ui/typeck/issue-81885.rs
@@ -1,7 +1,7 @@
 const TEST4: fn() -> _ = 42;
-//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constant items
+//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
 
 fn main() {
     const TEST5: fn() -> _ = 42;
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constant items
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
 }
diff --git a/tests/ui/typeck/issue-81885.stderr b/tests/ui/typeck/issue-81885.stderr
index 25a6bb632ef..414fe548883 100644
--- a/tests/ui/typeck/issue-81885.stderr
+++ b/tests/ui/typeck/issue-81885.stderr
@@ -1,10 +1,10 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
   --> $DIR/issue-81885.rs:1:22
    |
 LL | const TEST4: fn() -> _ = 42;
    |                      ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
   --> $DIR/issue-81885.rs:5:26
    |
 LL |     const TEST5: fn() -> _ = 42;
diff --git a/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr b/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr
index a4cb53025e3..c4a5c0dea6e 100644
--- a/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr
+++ b/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr
@@ -1,4 +1,4 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/issue-83621-placeholder-static-in-extern.rs:4:15
    |
 LL |     static x: _;
diff --git a/tests/ui/typeck/issue-88643.rs b/tests/ui/typeck/issue-88643.rs
index 4435cba0207..e562f3e55ac 100644
--- a/tests/ui/typeck/issue-88643.rs
+++ b/tests/ui/typeck/issue-88643.rs
@@ -8,12 +8,12 @@ use std::collections::HashMap;
 pub trait T {}
 
 static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new();
-//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121]
+//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121]
 
 static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new();
-//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121]
+//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121]
 
 static CALLBACKS3: Option<dyn Fn(& _)> = None;
-//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121]
+//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121]
 
 fn main() {}
diff --git a/tests/ui/typeck/issue-88643.stderr b/tests/ui/typeck/issue-88643.stderr
index d5d596b6f42..ad11c3ea8e0 100644
--- a/tests/ui/typeck/issue-88643.stderr
+++ b/tests/ui/typeck/issue-88643.stderr
@@ -1,16 +1,16 @@
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/issue-88643.rs:10:56
    |
 LL | static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new();
    |                                                        ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/issue-88643.rs:13:33
    |
 LL | static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new();
    |                                 ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics
   --> $DIR/issue-88643.rs:16:36
    |
 LL | static CALLBACKS3: Option<dyn Fn(& _)> = None;
diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs
index dc790361919..48547c019d6 100644
--- a/tests/ui/typeck/typeck_type_placeholder_item.rs
+++ b/tests/ui/typeck/typeck_type_placeholder_item.rs
@@ -41,7 +41,7 @@ impl Test9 {
     //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
 
     fn test10(&self, _x : _) { }
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
 }
 
 fn test11(x: &usize) -> &_ {
@@ -56,10 +56,10 @@ unsafe fn test12(x: *const usize) -> *const *const _ {
 
 impl Clone for Test9 {
     fn clone(&self) -> _ { Test9 }
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
 
     fn clone_from(&mut self, other: _) { *self = Test9; }
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
 }
 
 struct Test10 {
@@ -108,15 +108,15 @@ pub fn main() {
         //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types
 
         fn fn_test10(&self, _x : _) { }
-        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
     }
 
     impl Clone for FnTest9 {
         fn clone(&self) -> _ { FnTest9 }
-        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
 
         fn clone_from(&mut self, other: _) { *self = FnTest9; }
-        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+        //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
     }
 
     struct FnTest10 {
@@ -140,19 +140,19 @@ pub fn main() {
 
 trait T {
     fn method_test1(&self, x: _);
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
     fn method_test2(&self, x: _) -> _;
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
-    //~| ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
+    //~| ERROR the placeholder `_` is not allowed within types on item signatures for methods
     fn method_test3(&self) -> _;
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods
     fn assoc_fn_test1(x: _);
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
     fn assoc_fn_test2(x: _) -> _;
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
-    //~| ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
+    //~| ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
     fn assoc_fn_test3() -> _;
-    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions
+    //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions
 }
 
 struct BadStruct<_>(_);
diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr
index 53476f6c807..87750ee6dc1 100644
--- a/tests/ui/typeck/typeck_type_placeholder_item.stderr
+++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr
@@ -203,7 +203,7 @@ LL | unsafe fn test12(x: *const usize) -> *const *const _ {
    |                                      |             not allowed in type signatures
    |                                      help: replace with the correct return type: `*const *const usize`
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:58:24
    |
 LL |     fn clone(&self) -> _ { Test9 }
@@ -215,7 +215,7 @@ LL -     fn clone(&self) -> _ { Test9 }
 LL +     fn clone(&self) -> Test9 { Test9 }
    |
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:61:37
    |
 LL |     fn clone_from(&mut self, other: _) { *self = Test9; }
@@ -332,7 +332,7 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures
 LL |     fn fn_test8(_f: fn() -> _) { }
    |                             ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:115:28
    |
 LL |         fn clone(&self) -> _ { FnTest9 }
@@ -344,7 +344,7 @@ LL -         fn clone(&self) -> _ { FnTest9 }
 LL +         fn clone(&self) -> FnTest9 { FnTest9 }
    |
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:118:41
    |
 LL |         fn clone_from(&mut self, other: _) { *self = FnTest9; }
@@ -389,49 +389,49 @@ LL |     fn fn_test13(x: _) -> (i32, _) { (x, x) }
    |                           |     not allowed in type signatures
    |                           help: replace with the correct return type: `(i32, i32)`
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:142:31
    |
 LL |     fn method_test1(&self, x: _);
    |                               ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:144:31
    |
 LL |     fn method_test2(&self, x: _) -> _;
    |                               ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:144:37
    |
 LL |     fn method_test2(&self, x: _) -> _;
    |                                     ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:147:31
    |
 LL |     fn method_test3(&self) -> _;
    |                               ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/typeck_type_placeholder_item.rs:149:26
    |
 LL |     fn assoc_fn_test1(x: _);
    |                          ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/typeck_type_placeholder_item.rs:151:26
    |
 LL |     fn assoc_fn_test2(x: _) -> _;
    |                          ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/typeck_type_placeholder_item.rs:151:32
    |
 LL |     fn assoc_fn_test2(x: _) -> _;
    |                                ^ not allowed in type signatures
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions
   --> $DIR/typeck_type_placeholder_item.rs:154:28
    |
 LL |     fn assoc_fn_test3() -> _;
@@ -575,7 +575,7 @@ LL |     fn test9(&self) -> _ { () }
    |                        not allowed in type signatures
    |                        help: replace with the correct return type: `()`
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:43:27
    |
 LL |     fn test10(&self, _x : _) { }
@@ -590,7 +590,7 @@ LL |         fn fn_test9(&self) -> _ { () }
    |                               not allowed in type signatures
    |                               help: replace with the correct return type: `()`
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods
   --> $DIR/typeck_type_placeholder_item.rs:110:34
    |
 LL |         fn fn_test10(&self, _x : _) { }
diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.rs b/tests/ui/typeck/typeck_type_placeholder_item_help.rs
index ab433aaaf16..758b94f9854 100644
--- a/tests/ui/typeck/typeck_type_placeholder_item_help.rs
+++ b/tests/ui/typeck/typeck_type_placeholder_item_help.rs
@@ -11,7 +11,7 @@ const TEST3: _ = Some(42);
 //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
 
 const TEST4: fn() -> _ = 42;
-//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constant items
+//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants
 
 trait Test5 {
     const TEST5: _ = 42;
diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr
index 5066e2eaa52..2fce00e7a8e 100644
--- a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr
+++ b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr
@@ -31,7 +31,7 @@ LL - const TEST3: _ = Some(42);
 LL + const TEST3: Option<i32> = Some(42);
    |
 
-error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items
+error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants
   --> $DIR/typeck_type_placeholder_item_help.rs:13:22
    |
 LL | const TEST4: fn() -> _ = 42;