Skip to content

Commit

Permalink
Teach clippy that macros are now HIR items
Browse files Browse the repository at this point in the history
  • Loading branch information
inquisitivecrystal committed Aug 14, 2021
1 parent b9a85b3 commit 19b208c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_lints/src/missing_doc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingDoc {
hir::ItemKind::Const(..)
| hir::ItemKind::Enum(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Macro{ .. }
| hir::ItemKind::Static(..)
| hir::ItemKind::Struct(..)
| hir::ItemKind::Trait(..)
Expand Down
1 change: 1 addition & 0 deletions src/tools/clippy/clippy_lints/src/missing_inline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ impl<'tcx> LateLintPass<'tcx> for MissingInline {
hir::ItemKind::Const(..)
| hir::ItemKind::Enum(..)
| hir::ItemKind::Mod(..)
| hir::ItemKind::Macro { .. }
| hir::ItemKind::Static(..)
| hir::ItemKind::Struct(..)
| hir::ItemKind::TraitAlias(..)
Expand Down
13 changes: 13 additions & 0 deletions src/tools/clippy/clippy_lints/src/utils/inspector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,19 @@ fn print_item(cx: &LateContext<'_>, item: &hir::Item<'_>) {
},
hir::ItemKind::Mod(..) => println!("module"),
hir::ItemKind::ForeignMod { abi, .. } => println!("foreign module with abi: {}", abi),
hir::ItemKind::Macro { ref macro_def, .. } => {
if macro_def.ast.macro_rules {
if macro_def.is_exported {
println!("exported macro introduced by `macro_rules!`");
} else {
println!("nonexported macro introduced by `macro_rules!`");
}
} else {
// There's no point in distinguishing exported and nonexported `macro`
// macros. That's defined their visibility, which was printed above.
println!("macro introduced by `macro`");
}
}
hir::ItemKind::GlobalAsm(asm) => println!("global asm: {:?}", asm),
hir::ItemKind::TyAlias(..) => {
println!("type alias for {:?}", cx.tcx.type_of(did));
Expand Down

0 comments on commit 19b208c

Please sign in to comment.