@@ -578,7 +578,7 @@ struct ModuleData<'ra> {
578
578
globs : RefCell < Vec < Import < ' ra > > > ,
579
579
580
580
/// 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 > > ) ] > > > ,
582
582
583
583
/// Span of the module itself. Used for error reporting.
584
584
span : Span ,
@@ -654,12 +654,12 @@ impl<'ra> Module<'ra> {
654
654
let mut traits = self . traits . borrow_mut ( ) ;
655
655
if traits. is_none ( ) {
656
656
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| {
658
658
if ns != TypeNS {
659
659
return ;
660
660
}
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 ) ) )
663
663
}
664
664
} ) ;
665
665
* traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1813,11 +1813,10 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1813
1813
) {
1814
1814
module. ensure_traits ( self ) ;
1815
1815
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 ( ) {
1818
1817
if self . trait_may_have_item ( trait_module, assoc_item) {
1819
1818
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) ;
1821
1820
found_traits. push ( TraitCandidate { def_id, import_ids } ) ;
1822
1821
}
1823
1822
}
0 commit comments