@@ -18,7 +18,7 @@ use rustc_middle::mir::{
18
18
} ;
19
19
use rustc_middle:: traits:: ObligationCause ;
20
20
use rustc_middle:: traits:: ObligationCauseCode ;
21
- use rustc_middle:: ty:: { self , RegionVid , Ty , TyCtxt , TypeFoldable , TypeVisitableExt } ;
21
+ use rustc_middle:: ty:: { self , RegionVid , Ty , TyCtxt , TypeFoldable } ;
22
22
use rustc_mir_dataflow:: points:: DenseLocationMap ;
23
23
use rustc_span:: Span ;
24
24
@@ -1145,6 +1145,7 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1145
1145
}
1146
1146
1147
1147
let ty = ty. fold_with ( & mut OpaqueFolder { tcx } ) ;
1148
+ let mut failed = false ;
1148
1149
1149
1150
let ty = tcx. fold_regions ( ty, |r, _depth| {
1150
1151
let r_vid = self . to_region_vid ( r) ;
@@ -1160,15 +1161,18 @@ impl<'tcx> RegionInferenceContext<'tcx> {
1160
1161
. filter ( |& u_r| !self . universal_regions . is_local_free_region ( u_r) )
1161
1162
. find ( |& u_r| self . eval_equal ( u_r, r_vid) )
1162
1163
. map ( |u_r| ty:: Region :: new_var ( tcx, u_r) )
1163
- // In the case of a failure, use `ReErased`. We will eventually
1164
- // return `None` in this case.
1165
- . unwrap_or ( tcx. lifetimes . re_erased )
1164
+ // In case we could not find a named region to map to,
1165
+ // we will return `None` below.
1166
+ . unwrap_or_else ( || {
1167
+ failed = true ;
1168
+ r
1169
+ } )
1166
1170
} ) ;
1167
1171
1168
1172
debug ! ( "try_promote_type_test_subject: folded ty = {:?}" , ty) ;
1169
1173
1170
1174
// This will be true if we failed to promote some region.
1171
- if ty . has_erased_regions ( ) {
1175
+ if failed {
1172
1176
return None ;
1173
1177
}
1174
1178
0 commit comments