@@ -552,16 +552,35 @@ impl<'a> Resolver<'a> {
552
552
used = true ; // Avoid the normal unused extern crate warning
553
553
}
554
554
555
+ let ( graph_root, arenas) = ( self . graph_root , self . arenas ) ;
556
+ let macro_use_directive = |span| arenas. alloc_import_directive ( ImportDirective {
557
+ id : item. id ,
558
+ parent : graph_root,
559
+ imported_module : Cell :: new ( Some ( module) ) ,
560
+ subclass : ImportDirectiveSubclass :: MacroUse ,
561
+ span : span,
562
+ module_path : Vec :: new ( ) ,
563
+ vis : Cell :: new ( ty:: Visibility :: Restricted ( DefId :: local ( CRATE_DEF_INDEX ) ) ) ,
564
+ expansion : expansion,
565
+ used : Cell :: new ( false ) ,
566
+ } ) ;
567
+
555
568
if let Some ( span) = legacy_imports. import_all {
569
+ let directive = macro_use_directive ( span) ;
570
+ self . potentially_unused_imports . push ( directive) ;
556
571
module. for_each_child ( |ident, ns, binding| if ns == MacroNS {
557
- self . legacy_import_macro ( ident. name , binding, span, allow_shadowing) ;
572
+ let imported_binding = self . import ( binding, directive) ;
573
+ self . legacy_import_macro ( ident. name , imported_binding, span, allow_shadowing) ;
558
574
} ) ;
559
575
} else {
560
576
for ( name, span) in legacy_imports. imports {
561
577
let ident = Ident :: with_empty_ctxt ( name) ;
562
578
let result = self . resolve_ident_in_module ( module, ident, MacroNS , false , None ) ;
563
579
if let Ok ( binding) = result {
564
- self . legacy_import_macro ( name, binding, span, allow_shadowing) ;
580
+ let directive = macro_use_directive ( span) ;
581
+ self . potentially_unused_imports . push ( directive) ;
582
+ let imported_binding = self . import ( binding, directive) ;
583
+ self . legacy_import_macro ( name, imported_binding, span, allow_shadowing) ;
565
584
} else {
566
585
span_err ! ( self . session, span, E0469 , "imported macro not found" ) ;
567
586
}
0 commit comments