@@ -157,19 +157,6 @@ impl<'a> Resolver<'a> {
157
157
self . macro_map . insert ( def_id, ext. clone ( ) ) ;
158
158
Some ( ext)
159
159
}
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
- }
173
160
}
174
161
175
162
pub struct BuildReducedGraphVisitor < ' a , ' b > {
@@ -595,7 +582,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
595
582
self . r . get_module ( DefId { krate : crate_id, index : CRATE_DEF_INDEX } )
596
583
} ;
597
584
598
- self . r . populate_module_if_necessary ( module) ;
599
585
if let Some ( name) = self . r . session . parse_sess . injected_crate_name . try_get ( ) {
600
586
if name. as_str ( ) == ident. name . as_str ( ) {
601
587
self . r . injected_crate = Some ( module) ;
@@ -868,7 +854,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
868
854
}
869
855
870
856
/// 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 (
872
858
& mut self ,
873
859
parent : Module < ' a > ,
874
860
child : Export < ast:: NodeId > ,
@@ -922,6 +908,7 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
922
908
span) ;
923
909
self . r . define ( parent, ident, TypeNS , ( module, vis, DUMMY_SP , expansion) ) ;
924
910
911
+ module. populate_on_access . set ( false ) ;
925
912
for child in self . r . cstore . item_children_untracked ( def_id, self . r . session ) {
926
913
let res = child. res . map_id ( |_| panic ! ( "unexpected id" ) ) ;
927
914
let ns = if let Res :: Def ( DefKind :: AssocTy , _) = res {
@@ -935,7 +922,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
935
922
self . r . has_self . insert ( res. def_id ( ) ) ;
936
923
}
937
924
}
938
- module. populated . set ( true ) ;
939
925
}
940
926
Res :: Def ( DefKind :: Struct , def_id) | Res :: Def ( DefKind :: Union , def_id) => {
941
927
self . r . define ( parent, ident, TypeNS , ( res, vis, DUMMY_SP , expansion) ) ;
@@ -951,19 +937,6 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
951
937
}
952
938
}
953
939
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
-
967
940
/// Returns `true` if we should consider the underlying `extern crate` to be used.
968
941
fn process_legacy_macro_imports ( & mut self , item : & Item , module : Module < ' a > ) -> bool {
969
942
let mut import_all = None ;
@@ -1021,9 +994,9 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1021
994
if let Some ( span) = import_all {
1022
995
let directive = macro_use_directive ( self , span) ;
1023
996
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) ;
1027
1000
} ) ;
1028
1001
} else {
1029
1002
for ident in single_imports. iter ( ) . cloned ( ) {
@@ -1039,8 +1012,8 @@ impl<'a, 'b> BuildReducedGraphVisitor<'a, 'b> {
1039
1012
let directive = macro_use_directive ( self , ident. span ) ;
1040
1013
self . r . potentially_unused_imports . push ( directive) ;
1041
1014
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) ;
1044
1017
} else {
1045
1018
span_err ! ( self . r. session, ident. span, E0469 , "imported macro not found" ) ;
1046
1019
}
0 commit comments