Remove ItemKind::descr method

This commit is contained in:
Guillaume Gomez 2025-07-01 14:36:28 +02:00
parent f46ce66fcc
commit 022c91465a
3 changed files with 2 additions and 23 deletions

View file

@ -4400,27 +4400,6 @@ impl ItemKind<'_> {
_ => return None,
})
}
pub fn descr(&self) -> &'static str {
match self {
ItemKind::ExternCrate(..) => "extern crate",
ItemKind::Use(..) => "`use` import",
ItemKind::Static(..) => "static item",
ItemKind::Const(..) => "constant item",
ItemKind::Fn { .. } => "function",
ItemKind::Macro(..) => "macro",
ItemKind::Mod(..) => "module",
ItemKind::ForeignMod { .. } => "extern block",
ItemKind::GlobalAsm { .. } => "global asm item",
ItemKind::TyAlias(..) => "type alias",
ItemKind::Enum(..) => "enum",
ItemKind::Struct(..) => "struct",
ItemKind::Union(..) => "union",
ItemKind::Trait(..) => "trait",
ItemKind::TraitAlias(..) => "trait alias",
ItemKind::Impl(..) => "implementation",
}
}
}
/// A reference from an trait to one of its associated items. This

View file

@ -2844,7 +2844,7 @@ fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
.find(|item| !item.span.is_dummy()) // Skip prelude `use`s
.map(|item| errors::ItemFollowingInnerAttr {
span: if let Some(ident) = item.kind.ident() { ident.span } else { item.span },
kind: item.kind.descr(),
kind: tcx.def_descr(item.owner_id.to_def_id()),
});
let err = tcx.dcx().create_err(errors::InvalidAttrAtCrateLevel {
span,

View file

@ -5,7 +5,7 @@ LL | #![derive(Clone, Copy)]
| ^^^^^^^^^^^^^^^^^^^^^^^
LL |
LL | use std::ptr::addr_of;
| ------- the inner attribute doesn't annotate this `use` import
| ------- the inner attribute doesn't annotate this import
|
help: perhaps you meant to use an outer attribute
|