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