@@ -579,7 +579,7 @@ struct ModuleData<'ra> {
579
579
globs : RefCell < Vec < Import < ' ra > > > ,
580
580
581
581
/// 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 > > ) ] > > > ,
583
583
584
584
/// Span of the module itself. Used for error reporting.
585
585
span : Span ,
@@ -655,12 +655,12 @@ impl<'ra> Module<'ra> {
655
655
let mut traits = self . traits . borrow_mut ( ) ;
656
656
if traits. is_none ( ) {
657
657
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| {
659
659
if ns != TypeNS {
660
660
return ;
661
661
}
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 ) ) )
664
664
}
665
665
} ) ;
666
666
* traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1814,11 +1814,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1814
1814
) {
1815
1815
module. ensure_traits ( self ) ;
1816
1816
let traits = module. traits . borrow ( ) ;
1817
- for ( trait_name, trait_binding) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
1818
- let trait_module = self . get_module ( trait_binding. res ( ) . def_id ( ) ) ;
1817
+ for & ( trait_name, trait_binding, trait_module) in traits. as_ref ( ) . unwrap ( ) . iter ( ) {
1819
1818
if self . trait_may_have_item ( trait_module, assoc_item) {
1820
1819
let def_id = trait_binding. res ( ) . def_id ( ) ;
1821
- let import_ids = self . find_transitive_imports ( & trait_binding. kind , * trait_name) ;
1820
+ let import_ids = self . find_transitive_imports ( & trait_binding. kind , trait_name) ;
1822
1821
found_traits. push ( TraitCandidate { def_id, import_ids } ) ;
1823
1822
}
1824
1823
}
0 commit comments