@@ -579,7 +579,7 @@ struct ModuleData<'ra> {
579579 globs : RefCell < Vec < Import < ' ra > > > ,
580580
581581 /// Used to memoize the traits in this module for faster searches through all traits in scope.
582- traits : RefCell < Option < Box < [ ( Ident , NameBinding < ' ra > ) ] > > > ,
582+ traits : RefCell < Option < Box < [ ( Ident , NameBinding < ' ra > , Option < Module < ' ra > > ) ] > > > ,
583583
584584 /// Span of the module itself. Used for error reporting.
585585 span : Span ,
@@ -655,12 +655,12 @@ impl<'ra> Module<'ra> {
655655 let mut traits = self . traits . borrow_mut ( ) ;
656656 if traits. is_none ( ) {
657657 let mut collected_traits = Vec :: new ( ) ;
658- self . for_each_child ( resolver, |_ , name, ns, binding| {
658+ self . for_each_child ( resolver, |r , name, ns, binding| {
659659 if ns != TypeNS {
660660 return ;
661661 }
662- if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , _ ) = binding. res ( ) {
663- collected_traits. push ( ( name, binding) )
662+ if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , def_id ) = binding. res ( ) {
663+ collected_traits. push ( ( name, binding, r . as_mut ( ) . get_module ( def_id ) ) )
664664 }
665665 } ) ;
666666 * traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1835,11 +1835,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18351835 ) {
18361836 module. ensure_traits ( self ) ;
18371837 let traits = module. traits . borrow ( ) ;
1838- for ( trait_name, trait_binding) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
1839- let trait_module = self . get_module ( trait_binding. res ( ) . def_id ( ) ) ;
1838+ for & ( trait_name, trait_binding, trait_module) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
18401839 if self . trait_may_have_item ( trait_module, assoc_item) {
18411840 let def_id = trait_binding. res ( ) . def_id ( ) ;
1842- let import_ids = self . find_transitive_imports ( & trait_binding. kind , * trait_name) ;
1841+ let import_ids = self . find_transitive_imports ( & trait_binding. kind , trait_name) ;
18431842 found_traits. push ( TraitCandidate { def_id, import_ids } ) ;
18441843 }
18451844 }
0 commit comments