Skip to content

Commit 189bfc1

Browse files
Rollup merge of #143279 - GuillaumeGomez:rm-itemkind-descr, r=oli-obk
Remove `ItemKind::descr` method Follow-up of #143234. After this PR is merged, it will remain two `descr` methods: * `hir::GenericArg::descr` * `hir::AssocItemConstraintKind::descr` For both these enums, I don't think there is the right equivalent in `hir::DefKind` so unless I missed something, we can't remove these two methods because we can't convert these enums into `hir::DefKind`. r? `@oli-obk`
2 parents d2463c9 + 711c616 commit 189bfc1

File tree

7 files changed

+14
-29
lines changed

7 files changed

+14
-29
lines changed

compiler/rustc_hir/src/hir.rs

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4400,27 +4400,6 @@ impl ItemKind<'_> {
44004400
_ => return None,
44014401
})
44024402
}
4403-
4404-
pub fn descr(&self) -> &'static str {
4405-
match self {
4406-
ItemKind::ExternCrate(..) => "extern crate",
4407-
ItemKind::Use(..) => "`use` import",
4408-
ItemKind::Static(..) => "static item",
4409-
ItemKind::Const(..) => "constant item",
4410-
ItemKind::Fn { .. } => "function",
4411-
ItemKind::Macro(..) => "macro",
4412-
ItemKind::Mod(..) => "module",
4413-
ItemKind::ForeignMod { .. } => "extern block",
4414-
ItemKind::GlobalAsm { .. } => "global asm item",
4415-
ItemKind::TyAlias(..) => "type alias",
4416-
ItemKind::Enum(..) => "enum",
4417-
ItemKind::Struct(..) => "struct",
4418-
ItemKind::Union(..) => "union",
4419-
ItemKind::Trait(..) => "trait",
4420-
ItemKind::TraitAlias(..) => "trait alias",
4421-
ItemKind::Impl(..) => "implementation",
4422-
}
4423-
}
44244403
}
44254404

44264405
/// A reference from an trait to one of its associated items. This

compiler/rustc_passes/src/check_attr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2832,7 +2832,7 @@ fn check_invalid_crate_level_attr(tcx: TyCtxt<'_>, attrs: &[Attribute]) {
28322832
.find(|item| !item.span.is_dummy()) // Skip prelude `use`s
28332833
.map(|item| errors::ItemFollowingInnerAttr {
28342834
span: if let Some(ident) = item.kind.ident() { ident.span } else { item.span },
2835-
kind: item.kind.descr(),
2835+
kind: tcx.def_descr(item.owner_id.to_def_id()),
28362836
});
28372837
let err = tcx.dcx().create_err(errors::InvalidAttrAtCrateLevel {
28382838
span,

src/tools/clippy/clippy_lints/src/undocumented_unsafe_blocks.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,10 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks {
256256
cx,
257257
UNNECESSARY_SAFETY_COMMENT,
258258
span,
259-
format!("{} has unnecessary safety comment", item.kind.descr()),
259+
format!(
260+
"{} has unnecessary safety comment",
261+
cx.tcx.def_descr(item.owner_id.to_def_id()),
262+
),
260263
|diag| {
261264
diag.span_help(help_span, "consider removing the safety comment");
262265
},
@@ -274,7 +277,10 @@ impl<'tcx> LateLintPass<'tcx> for UndocumentedUnsafeBlocks {
274277
cx,
275278
UNNECESSARY_SAFETY_COMMENT,
276279
span,
277-
format!("{} has unnecessary safety comment", item.kind.descr()),
280+
format!(
281+
"{} has unnecessary safety comment",
282+
cx.tcx.def_descr(item.owner_id.to_def_id()),
283+
),
278284
|diag| {
279285
diag.span_help(help_span, "consider removing the safety comment");
280286
},

src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.default.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ LL | unsafe impl TrailingComment for () {} // SAFETY:
240240
|
241241
= help: consider adding a safety comment on the preceding line
242242

243-
error: constant item has unnecessary safety comment
243+
error: constant has unnecessary safety comment
244244
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:508:5
245245
|
246246
LL | const BIG_NUMBER: i32 = 1000000;

src/tools/clippy/tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.disabled.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ LL | unsafe impl TrailingComment for () {} // SAFETY:
240240
|
241241
= help: consider adding a safety comment on the preceding line
242242

243-
error: constant item has unnecessary safety comment
243+
error: constant has unnecessary safety comment
244244
--> tests/ui-toml/undocumented_unsafe_blocks/undocumented_unsafe_blocks.rs:508:5
245245
|
246246
LL | const BIG_NUMBER: i32 = 1000000;

src/tools/clippy/tests/ui/unnecessary_safety_comment.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: constant item has unnecessary safety comment
1+
error: constant has unnecessary safety comment
22
--> tests/ui/unnecessary_safety_comment.rs:6:5
33
|
44
LL | const CONST: u32 = 0;
@@ -12,7 +12,7 @@ LL | // SAFETY:
1212
= note: `-D clippy::unnecessary-safety-comment` implied by `-D warnings`
1313
= help: to override `-D warnings` add `#[allow(clippy::unnecessary_safety_comment)]`
1414

15-
error: static item has unnecessary safety comment
15+
error: static has unnecessary safety comment
1616
--> tests/ui/unnecessary_safety_comment.rs:10:5
1717
|
1818
LL | static STATIC: u32 = 0;

tests/ui/lowering/issue-121108.stderr

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ LL | #![derive(Clone, Copy)]
55
| ^^^^^^^^^^^^^^^^^^^^^^^
66
LL |
77
LL | use std::ptr::addr_of;
8-
| ------- the inner attribute doesn't annotate this `use` import
8+
| ------- the inner attribute doesn't annotate this import
99
|
1010
help: perhaps you meant to use an outer attribute
1111
|

0 commit comments

Comments
 (0)