@@ -157,19 +157,6 @@ impl<'a> Resolver<'a> {
157157 self . macro_map . insert ( def_id, ext. clone ( ) ) ;
158158 Some ( ext)
159159 }
160-
161- /// Ensures that the reduced graph rooted at the given external module
162- /// is built, building it if it is not.
163- pub fn populate_module_if_necessary ( & mut self , module : Module < ' a > ) {
164- if module. populated . get ( ) { return }
165- let def_id = module. def_id ( ) . unwrap ( ) ;
166- for child in self . cstore . item_children_untracked ( def_id, self . session ) {
167- let child = child. map_id ( |_| panic ! ( "unexpected id" ) ) ;
168- BuildReducedGraphVisitor { parent_scope : self . dummy_parent_scope ( ) , r : self }
169- . build_reduced_graph_for_external_crate_res ( module, child) ;
170- }
171- module. populated . set ( true )
172- }
173160}
174161
175162pub struct BuildReducedGraphVisitor < ' a , ' b > {
@@ -595,7 +582,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
595582 self . r . get_module ( DefId { krate : crate_id, index : CRATE_DEF_INDEX } )
596583 } ;
597584
598- self . r . populate_module_if_necessary ( module) ;
599585 if let Some ( name) = self . r . session . parse_sess . injected_crate_name . try_get ( ) {
600586 if name. as_str ( ) == ident. name . as_str ( ) {
601587 self . r . injected_crate = Some ( module) ;
@@ -868,7 +854,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
868854 }
869855
870856 /// Builds the reduced graph for a single item in an external crate.
871- fn build_reduced_graph_for_external_crate_res (
857+ crate fn build_reduced_graph_for_external_crate_res (
872858 & mut self ,
873859 parent : Module < ' a > ,
874860 child : Export < ast:: NodeId > ,
@@ -922,6 +908,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
922908 span) ;
923909 self . r . define ( parent, ident, TypeNS , ( module, vis, DUMMY_SP , expansion) ) ;
924910
911+ module. populate_on_access . set ( false ) ;
925912 for child in self . r . cstore . item_children_untracked ( def_id, self . r . session ) {
926913 let res = child. res . map_id ( |_| panic ! ( "unexpected id" ) ) ;
927914 let ns = if let Res :: Def ( DefKind :: AssocTy , _) = res {
@@ -935,7 +922,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
935922 self . r . has_self . insert ( res. def_id ( ) ) ;
936923 }
937924 }
938- module. populated . set ( true ) ;
939925 }
940926 Res :: Def ( DefKind :: Struct , def_id) | Res :: Def ( DefKind :: Union , def_id) => {
941927 self . r . define ( parent, ident, TypeNS , ( res, vis, DUMMY_SP , expansion) ) ;
@@ -951,19 +937,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
951937 }
952938 }
953939
954- fn legacy_import_macro ( & mut self ,
955- name : Name ,
956- binding : & ' a NameBinding < ' a > ,
957- span : Span ,
958- allow_shadowing : bool ) {
959- if self . r . macro_use_prelude . insert ( name, binding) . is_some ( ) && !allow_shadowing {
960- let msg = format ! ( "`{}` is already in scope" , name) ;
961- let note =
962- "macro-expanded `#[macro_use]`s may not shadow existing macros (see RFC 1560)" ;
963- self . r . session . struct_span_err ( span, & msg) . note ( note) . emit ( ) ;
964- }
965- }
966-
967940 /// Returns `true` if we should consider the underlying `extern crate` to be used.
968941 fn process_legacy_macro_imports ( & mut self , item : & Item , module : Module < ' a > ) -> bool {
969942 let mut import_all = None ;
@@ -1021,9 +994,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1021994 if let Some ( span) = import_all {
1022995 let directive = macro_use_directive ( self , span) ;
1023996 self . r . potentially_unused_imports . push ( directive) ;
1024- module. for_each_child ( | ident, ns, binding| if ns == MacroNS {
1025- let imported_binding = self . r . import ( binding, directive) ;
1026- self . legacy_import_macro ( ident. name , imported_binding, span, allow_shadowing) ;
997+ module. for_each_child ( & mut self . r , |this , ident, ns, binding| if ns == MacroNS {
998+ let imported_binding = this . import ( binding, directive) ;
999+ this . legacy_import_macro ( ident. name , imported_binding, span, allow_shadowing) ;
10271000 } ) ;
10281001 } else {
10291002 for ident in single_imports. iter ( ) . cloned ( ) {
@@ -1039,8 +1012,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
10391012 let directive = macro_use_directive ( self , ident. span ) ;
10401013 self . r . potentially_unused_imports . push ( directive) ;
10411014 let imported_binding = self . r . import ( binding, directive) ;
1042- self . legacy_import_macro ( ident. name , imported_binding,
1043- ident. span , allow_shadowing) ;
1015+ self . r . legacy_import_macro ( ident. name , imported_binding,
1016+ ident. span , allow_shadowing) ;
10441017 } else {
10451018 span_err ! ( self . r. session, ident. span, E0469 , "imported macro not found" ) ;
10461019 }
0 commit comments