@@ -641,7 +641,7 @@ impl<'ra> ModuleData<'ra> {
641
641
}
642
642
643
643
impl < ' 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 )
645
645
where
646
646
R : AsMut < Resolver < ' ra , ' tcx > > ,
647
647
F : FnMut ( & mut R , Ident , Namespace , NameBinding < ' ra > ) ,
@@ -653,10 +653,22 @@ impl<'ra> Module<'ra> {
653
653
}
654
654
}
655
655
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
+
656
668
/// 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 )
658
670
where
659
- R : AsMut < Resolver < ' ra , ' tcx > > ,
671
+ R : AsRef < Resolver < ' ra , ' tcx > > ,
660
672
{
661
673
let mut traits = self . traits . borrow_mut ( ) ;
662
674
if traits. is_none ( ) {
@@ -666,7 +678,7 @@ impl<'ra> Module<'ra> {
666
678
return ;
667
679
}
668
680
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) ) )
670
682
}
671
683
} ) ;
672
684
* traits = Some ( collected_traits. into_boxed_slice ( ) ) ;
@@ -1332,6 +1344,12 @@ impl<'ra, 'tcx> AsMut<Resolver<'ra, 'tcx>> for Resolver<'ra, 'tcx> {
1332
1344
}
1333
1345
}
1334
1346
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
+
1335
1353
impl < ' tcx > Resolver < ' _ , ' tcx > {
1336
1354
fn opt_local_def_id ( & self , node : NodeId ) -> Option < LocalDefId > {
1337
1355
self . opt_feed ( node) . map ( |f| f. key ( ) )
@@ -1859,7 +1877,7 @@ impl<'ra, 'tcx> Resolver<'ra, 'tcx> {
1859
1877
// We don't reject trait aliases (`trait_module == None`) because we don't have access to their
1860
1878
// associated items.
1861
1879
fn trait_may_have_item (
1862
- & mut self ,
1880
+ & self ,
1863
1881
trait_module : Option < Module < ' ra > > ,
1864
1882
assoc_item : Option < ( Symbol , Namespace ) > ,
1865
1883
) -> bool {
0 commit comments