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