@@ -578,7 +578,7 @@ struct ModuleData<'ra> {
578578 globs : RefCell < Vec < Import < ' ra > > > ,
579579
580580 /// Used to memoize the traits in this module for faster searches through all traits in scope.
581- traits : RefCell < Option < Box < [ ( Ident , NameBinding < ' ra > ) ] > > > ,
581+ traits : RefCell < Option < Box < [ ( Ident , NameBinding < ' ra > , Option < Module < ' ra > > ) ] > > > ,
582582
583583 /// Span of the module itself. Used for error reporting.
584584 span : Span ,
@@ -654,12 +654,12 @@ impl<'ra> Module<'ra> {
654654 let mut traits = self . traits . borrow_mut ( ) ;
655655 if traits. is_none ( ) {
656656 let mut collected_traits = Vec :: new ( ) ;
657- self . for_each_child ( resolver, |_ , name, ns, binding| {
657+ self . for_each_child ( resolver, |r , name, ns, binding| {
658658 if ns != TypeNS {
659659 return ;
660660 }
661- if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , _ ) = binding. res ( ) {
662- collected_traits. push ( ( name, binding) )
661+ if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , def_id ) = binding. res ( ) {
662+ collected_traits. push ( ( name, binding, r . as_mut ( ) . get_module ( def_id ) ) )
663663 }
664664 } ) ;
665665 * traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1813,11 +1813,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18131813 ) {
18141814 module. ensure_traits ( self ) ;
18151815 let traits = module. traits . borrow ( ) ;
1816- for ( trait_name, trait_binding) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
1817- let trait_module = self . get_module ( trait_binding. res ( ) . def_id ( ) ) ;
1816+ for & ( trait_name, trait_binding, trait_module) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
18181817 if self . trait_may_have_item ( trait_module, assoc_item) {
18191818 let def_id = trait_binding. res ( ) . def_id ( ) ;
1820- let import_ids = self . find_transitive_imports ( & trait_binding. kind , * trait_name) ;
1819+ let import_ids = self . find_transitive_imports ( & trait_binding. kind , trait_name) ;
18211820 found_traits. push ( TraitCandidate { def_id, import_ids } ) ;
18221821 }
18231822 }
0 commit comments