@@ -641,7 +641,7 @@ impl<'ra> ModuleData<'ra> {
641641}
642642
643643impl < ' ra > Module < ' ra > {
644- fn for_each_child < ' tcx , R , F > ( self , resolver : & mut R , mut f : F )
644+ fn for_each_child_mut < ' tcx , R , F > ( self , resolver : & mut R , mut f : F )
645645 where
646646 R : AsMut < Resolver < ' ra , ' tcx > > ,
647647 F : FnMut ( & mut R , Ident , Namespace , NameBinding < ' ra > ) ,
@@ -653,10 +653,22 @@ impl<'ra> Module<'ra> {
653653 }
654654 }
655655
656+ fn for_each_child < ' tcx , R , F > ( self , resolver : & R , mut f : F )
657+ where
658+ R : AsRef < Resolver < ' ra , ' tcx > > ,
659+ F : FnMut ( & R , Ident , Namespace , NameBinding < ' ra > ) ,
660+ {
661+ for ( key, name_resolution) in resolver. as_ref ( ) . resolutions ( self ) . borrow ( ) . iter ( ) {
662+ if let Some ( binding) = name_resolution. borrow ( ) . binding {
663+ f ( resolver, key. ident , key. ns , binding) ;
664+ }
665+ }
666+ }
667+
656668 /// This modifies `self` in place. The traits will be stored in `self.traits`.
657- fn ensure_traits < ' tcx , R > ( self , resolver : & mut R )
669+ fn ensure_traits < ' tcx , R > ( self , resolver : & R )
658670 where
659- R : AsMut < Resolver < ' ra , ' tcx > > ,
671+ R : AsRef < Resolver < ' ra , ' tcx > > ,
660672 {
661673 let mut traits = self . traits . borrow_mut ( ) ;
662674 if traits. is_none ( ) {
@@ -666,7 +678,7 @@ impl<'ra> Module<'ra> {
666678 return ;
667679 }
668680 if let Res :: Def ( DefKind :: Trait | DefKind :: TraitAlias , def_id) = binding. res ( ) {
669- collected_traits. push ( ( name, binding, r. as_mut ( ) . get_module ( def_id) ) )
681+ collected_traits. push ( ( name, binding, r. as_ref ( ) . get_module ( def_id) ) )
670682 }
671683 } ) ;
672684 * traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1332,6 +1344,12 @@ impl<'ra, 'tcx> AsMut<Resolver<'ra, 'tcx>> for Resolver<'ra, 'tcx> {
13321344 }
13331345}
13341346
1347+ impl < ' ra , ' tcx > AsRef < Resolver < ' ra , ' tcx > > for Resolver < ' ra , ' tcx > {
1348+ fn as_ref ( & self ) -> & Resolver < ' ra , ' tcx > {
1349+ self
1350+ }
1351+ }
1352+
13351353impl < ' tcx > Resolver < ' _ , ' tcx > {
13361354 fn opt_local_def_id ( & self , node : NodeId ) -> Option < LocalDefId > {
13371355 self . opt_feed ( node) . map ( |f| f. key ( ) )
@@ -1859,7 +1877,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
18591877 // We don't reject trait aliases (`trait_module == None`) because we don't have access to their
18601878 // associated items.
18611879 fn trait_may_have_item (
1862- & mut self ,
1880+ & self ,
18631881 trait_module : Option < Module < ' ra > > ,
18641882 assoc_item : Option < ( Symbol , Namespace ) > ,
18651883 ) -> bool {
0 commit comments