@@ -820,7 +820,7 @@ pub struct ModuleS<'a> {
820820 // entry block for `f`.
821821 module_children : RefCell < NodeMap < Module < ' a > > > ,
822822
823- shadowed_traits : RefCell < Vec < & ' a NameBinding < ' a > > > ,
823+ prelude : RefCell < Option < Module < ' a > > > ,
824824
825825 glob_importers : RefCell < Vec < ( Module < ' a > , & ' a ImportDirective ) > > ,
826826 resolved_globs : RefCell < ( Vec < Module < ' a > > /* public */ , Vec < Module < ' a > > /* private */ ) > ,
@@ -855,7 +855,7 @@ impl<'a> ModuleS<'a> {
855855 resolutions : RefCell :: new ( HashMap :: new ( ) ) ,
856856 unresolved_imports : RefCell :: new ( Vec :: new ( ) ) ,
857857 module_children : RefCell :: new ( NodeMap ( ) ) ,
858- shadowed_traits : RefCell :: new ( Vec :: new ( ) ) ,
858+ prelude : RefCell :: new ( None ) ,
859859 glob_importers : RefCell :: new ( Vec :: new ( ) ) ,
860860 resolved_globs : RefCell :: new ( ( Vec :: new ( ) , Vec :: new ( ) ) ) ,
861861 public_glob_count : Cell :: new ( 0 ) ,
@@ -3336,33 +3336,25 @@ impl<'a, 'tcx> Resolver<'a, 'tcx> {
33363336 }
33373337
33383338 // Look for trait children.
3339- build_reduced_graph:: populate_module_if_necessary ( self , & search_module) ;
3340-
3341- search_module. for_each_child ( |_, ns, name_binding| {
3339+ let mut search_in_module = |module : Module < ' a > | module. for_each_child ( |_, ns, binding| {
33423340 if ns != TypeNS { return }
3343- let trait_def_id = match name_binding . def ( ) {
3341+ let trait_def_id = match binding . def ( ) {
33443342 Some ( Def :: Trait ( trait_def_id) ) => trait_def_id,
33453343 Some ( ..) | None => return ,
33463344 } ;
33473345 if self . trait_item_map . contains_key ( & ( name, trait_def_id) ) {
33483346 add_trait_info ( & mut found_traits, trait_def_id, name) ;
33493347 let trait_name = self . get_trait_name ( trait_def_id) ;
3350- self . record_use ( trait_name, TypeNS , name_binding) ;
3351- }
3352- } ) ;
3353-
3354- // Look for shadowed traits.
3355- for binding in search_module. shadowed_traits . borrow ( ) . iter ( ) {
3356- let did = binding. def ( ) . unwrap ( ) . def_id ( ) ;
3357- if self . trait_item_map . contains_key ( & ( name, did) ) {
3358- add_trait_info ( & mut found_traits, did, name) ;
3359- let trait_name = self . get_trait_name ( did) ;
33603348 self . record_use ( trait_name, TypeNS , binding) ;
33613349 }
3362- }
3350+ } ) ;
3351+ search_in_module ( search_module) ;
33633352
33643353 match search_module. parent_link {
3365- NoParentLink | ModuleParentLink ( ..) => break ,
3354+ NoParentLink | ModuleParentLink ( ..) => {
3355+ search_module. prelude . borrow ( ) . map ( search_in_module) ;
3356+ break ;
3357+ }
33663358 BlockParentLink ( parent_module, _) => {
33673359 search_module = parent_module;
33683360 }
0 commit comments