@@ -163,25 +163,15 @@ impl<'a> Resolver<'a> {
163
163
Some ( ext)
164
164
}
165
165
166
- // FIXME: `extra_placeholders` should be included into the `fragment` as regular placeholders.
167
166
crate fn build_reduced_graph (
168
167
& mut self ,
169
168
fragment : & AstFragment ,
170
- extra_placeholders : & [ NodeId ] ,
171
169
parent_scope : ParentScope < ' a > ,
172
170
) -> LegacyScope < ' a > {
173
171
let mut def_collector = DefCollector :: new ( & mut self . definitions , parent_scope. expansion ) ;
174
172
fragment. visit_with ( & mut def_collector) ;
175
- for placeholder in extra_placeholders {
176
- def_collector. visit_macro_invoc ( * placeholder) ;
177
- }
178
-
179
173
let mut visitor = BuildReducedGraphVisitor { r : self , parent_scope } ;
180
174
fragment. visit_with ( & mut visitor) ;
181
- for placeholder in extra_placeholders {
182
- visitor. parent_scope . legacy = visitor. visit_invoc ( * placeholder) ;
183
- }
184
-
185
175
visitor. parent_scope . legacy
186
176
}
187
177
@@ -1064,8 +1054,17 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1064
1054
None
1065
1055
}
1066
1056
1057
+ // Mark the given macro as unused unless its name starts with `_`.
1058
+ // Macro uses will remove items from this set, and the remaining
1059
+ // items will be reported as `unused_macros`.
1060
+ fn insert_unused_macro ( & mut self , ident : Ident , node_id : NodeId , span : Span ) {
1061
+ if !ident. as_str ( ) . starts_with ( "_" ) {
1062
+ self . r . unused_macros . insert ( node_id, span) ;
1063
+ }
1064
+ }
1065
+
1067
1066
fn define_macro ( & mut self , item : & ast:: Item ) -> LegacyScope < ' a > {
1068
- let parent_scope = & self . parent_scope ;
1067
+ let parent_scope = self . parent_scope ;
1069
1068
let expansion = parent_scope. expansion ;
1070
1069
let ( ext, ident, span, is_legacy) = match & item. kind {
1071
1070
ItemKind :: MacroDef ( def) => {
@@ -1105,7 +1104,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1105
1104
( res, vis, span, expansion, IsMacroExport ) ) ;
1106
1105
} else {
1107
1106
self . r . check_reserved_macro_name ( ident, res) ;
1108
- self . r . unused_macros . insert ( item. id , span) ;
1107
+ self . insert_unused_macro ( ident , item. id , span) ;
1109
1108
}
1110
1109
LegacyScope :: Binding ( self . r . arenas . alloc_legacy_binding ( LegacyBinding {
1111
1110
parent_legacy_scope : parent_scope. legacy , binding, ident
@@ -1114,7 +1113,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1114
1113
let module = parent_scope. module ;
1115
1114
let vis = self . resolve_visibility ( & item. vis ) ;
1116
1115
if vis != ty:: Visibility :: Public {
1117
- self . r . unused_macros . insert ( item. id , span) ;
1116
+ self . insert_unused_macro ( ident , item. id , span) ;
1118
1117
}
1119
1118
self . r . define ( module, ident, MacroNS , ( res, vis, span, expansion) ) ;
1120
1119
self . parent_scope . legacy
0 commit comments