@@ -9,7 +9,7 @@ use rustc_hir as hir;
9
9
use rustc_hir:: intravisit:: { self , Visitor } ;
10
10
use rustc_infer:: infer:: error_reporting:: TypeAnnotationNeeded :: E0282 ;
11
11
use rustc_middle:: ty:: adjustment:: { Adjust , Adjustment , PointerCoercion } ;
12
- use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder , TypeSuperFoldable } ;
12
+ use rustc_middle:: ty:: fold:: { TypeFoldable , TypeFolder } ;
13
13
use rustc_middle:: ty:: visit:: TypeVisitableExt ;
14
14
use rustc_middle:: ty:: { self , Ty , TyCtxt } ;
15
15
use rustc_span:: symbol:: sym;
@@ -768,49 +768,30 @@ impl<'cx, 'tcx> Resolver<'cx, 'tcx> {
768
768
}
769
769
}
770
770
771
- struct EraseEarlyRegions < ' tcx > {
772
- tcx : TyCtxt < ' tcx > ,
773
- }
774
-
775
- impl < ' tcx > TypeFolder < TyCtxt < ' tcx > > for EraseEarlyRegions < ' tcx > {
776
- fn interner ( & self ) -> TyCtxt < ' tcx > {
777
- self . tcx
778
- }
779
- fn fold_ty ( & mut self , ty : Ty < ' tcx > ) -> Ty < ' tcx > {
780
- if ty. has_type_flags ( ty:: TypeFlags :: HAS_FREE_REGIONS ) {
781
- ty. super_fold_with ( self )
782
- } else {
783
- ty
784
- }
785
- }
786
- fn fold_region ( & mut self , r : ty:: Region < ' tcx > ) -> ty:: Region < ' tcx > {
787
- if r. is_bound ( ) { r } else { self . tcx . lifetimes . re_erased }
788
- }
789
- }
790
-
791
771
impl < ' cx , ' tcx > TypeFolder < TyCtxt < ' tcx > > for Resolver < ' cx , ' tcx > {
792
772
fn interner ( & self ) -> TyCtxt < ' tcx > {
793
773
self . fcx . tcx
794
774
}
795
775
796
776
fn fold_ty ( & mut self , t : Ty < ' tcx > ) -> Ty < ' tcx > {
777
+ let tcx = self . fcx . tcx ;
797
778
match self . fcx . fully_resolve ( t) {
798
779
Ok ( t) if self . fcx . next_trait_solver ( ) => {
799
780
// We must normalize erasing regions here, since later lints
800
781
// expect that types that show up in the typeck are fully
801
782
// normalized.
802
- if let Ok ( t) = self . fcx . tcx . try_normalize_erasing_regions ( self . fcx . param_env , t) {
783
+ if let Ok ( t) = tcx. try_normalize_erasing_regions ( self . fcx . param_env , t) {
803
784
t
804
785
} else {
805
- EraseEarlyRegions { tcx : self . fcx . tcx } . fold_ty ( t )
786
+ tcx . fold_regions ( t , |_ , _| tcx. lifetimes . re_erased )
806
787
}
807
788
}
808
789
Ok ( t) => {
809
790
// Do not anonymize late-bound regions
810
791
// (e.g. keep `for<'a>` named `for<'a>`).
811
792
// This allows NLL to generate error messages that
812
793
// refer to the higher-ranked lifetime names written by the user.
813
- EraseEarlyRegions { tcx : self . fcx . tcx } . fold_ty ( t )
794
+ tcx . fold_regions ( t , |_ , _| tcx. lifetimes . re_erased )
814
795
}
815
796
Err ( _) => {
816
797
debug ! ( "Resolver::fold_ty: input type `{:?}` not fully resolvable" , t) ;
0 commit comments