@@ -1061,8 +1061,17 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1061
1061
None
1062
1062
}
1063
1063
1064
+ // Mark the given macro as unused unless its name starts with `_`.
1065
+ // Macro uses will remove items from this set, and the remaining
1066
+ // items will be reported as `unused_macros`.
1067
+ fn insert_unused_macro ( & mut self , ident : Ident , node_id : NodeId , span : Span ) {
1068
+ if !ident. as_str ( ) . starts_with ( "_" ) {
1069
+ self . r . unused_macros . insert ( node_id, span) ;
1070
+ }
1071
+ }
1072
+
1064
1073
fn define_macro ( & mut self , item : & ast:: Item ) -> LegacyScope < ' a > {
1065
- let parent_scope = & self . parent_scope ;
1074
+ let parent_scope = self . parent_scope ;
1066
1075
let expansion = parent_scope. expansion ;
1067
1076
let ( ext, ident, span, is_legacy) = match & item. kind {
1068
1077
ItemKind :: MacroDef ( def) => {
@@ -1102,7 +1111,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1102
1111
( res, vis, span, expansion, IsMacroExport ) ) ;
1103
1112
} else {
1104
1113
self . r . check_reserved_macro_name ( ident, res) ;
1105
- self . r . unused_macros . insert ( item. id , span) ;
1114
+ self . insert_unused_macro ( ident , item. id , span) ;
1106
1115
}
1107
1116
LegacyScope :: Binding ( self . r . arenas . alloc_legacy_binding ( LegacyBinding {
1108
1117
parent_legacy_scope : parent_scope. legacy , binding, ident
@@ -1111,7 +1120,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1111
1120
let module = parent_scope. module ;
1112
1121
let vis = self . resolve_visibility ( & item. vis ) ;
1113
1122
if vis != ty:: Visibility :: Public {
1114
- self . r . unused_macros . insert ( item. id , span) ;
1123
+ self . insert_unused_macro ( ident , item. id , span) ;
1115
1124
}
1116
1125
self . r . define ( module, ident, MacroNS , ( res, vis, span, expansion) ) ;
1117
1126
self . parent_scope . legacy
0 commit comments