Skip to content

Commit 19b208c

Browse files
Teach clippy that macros are now HIR items
1 parent b9a85b3 commit 19b208c

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

src/tools/clippy/clippy_lints/src/missing_doc.rs

+1
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
123123
hir::ItemKind::Const(..)
124124
| hir::ItemKind::Enum(..)
125125
| hir::ItemKind::Mod(..)
126+
| hir::ItemKind::Macro{ .. }
126127
| hir::ItemKind::Static(..)
127128
| hir::ItemKind::Struct(..)
128129
| hir::ItemKind::Trait(..)

src/tools/clippy/clippy_lints/src/missing_inline.rs

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
119119
hir::ItemKind::Const(..)
120120
| hir::ItemKind::Enum(..)
121121
| hir::ItemKind::Mod(..)
122+
| hir::ItemKind::Macro { .. }
122123
| hir::ItemKind::Static(..)
123124
| hir::ItemKind::Struct(..)
124125
| hir::ItemKind::TraitAlias(..)

src/tools/clippy/clippy_lints/src/utils/inspector.rs

+13
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,19 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
408408
},
409409
hir::ItemKind::Mod(..) => println!("module"),
410410
hir::ItemKind::ForeignMod { abi, .. } => println!("foreign module with abi: {}", abi),
411+
hir::ItemKind::Macro { ref macro_def, .. } => {
412+
if macro_def.ast.macro_rules {
413+
if macro_def.is_exported {
414+
println!("exported macro introduced by `macro_rules!`");
415+
} else {
416+
println!("nonexported macro introduced by `macro_rules!`");
417+
}
418+
} else {
419+
// There's no point in distinguishing exported and nonexported `macro`
420+
// macros. That's defined their visibility, which was printed above.
421+
println!("macro introduced by `macro`");
422+
}
423+
}
411424
hir::ItemKind::GlobalAsm(asm) => println!("global asm: {:?}", asm),
412425
hir::ItemKind::TyAlias(..) => {
413426
println!("type alias for {:?}", cx.tcx.type_of(did));

0 commit comments

Comments
 (0)