@@ -36,7 +36,7 @@ use rustc_middle::ty::{self, GenericParamDefKind, InferConst, InferTy, Ty, TyCtx
3636use rustc_middle:: ty:: { ConstVid , EffectVid , FloatVid , IntVid , TyVid } ;
3737use rustc_middle:: ty:: { GenericArg , GenericArgKind , GenericArgs , GenericArgsRef } ;
3838use rustc_span:: symbol:: Symbol ;
39- use rustc_span:: Span ;
39+ use rustc_span:: { Span , DUMMY_SP } ;
4040
4141use std:: cell:: { Cell , RefCell } ;
4242use std:: fmt;
@@ -1422,12 +1422,25 @@ impl<'tcx> InferCtxt<'tcx> {
14221422 /// This method is idempotent, but it not typically not invoked
14231423 /// except during the writeback phase.
14241424 pub fn fully_resolve < T : TypeFoldable < TyCtxt < ' tcx > > > ( & self , value : T ) -> FixupResult < ' tcx , T > {
1425- let value = resolve:: fully_resolve ( self , value) ;
1426- assert ! (
1427- value. as_ref( ) . map_or( true , |value| !value. has_infer( ) ) ,
1428- "`{value:?}` is not fully resolved"
1429- ) ;
1430- value
1425+ match resolve:: fully_resolve ( self , value) {
1426+ Ok ( value) => {
1427+ if value. has_non_region_infer ( ) {
1428+ bug ! ( "`{value:?}` is not fully resolved" ) ;
1429+ }
1430+ if value. has_infer_regions ( ) {
1431+ let guar = self
1432+ . tcx
1433+ . sess
1434+ . delay_span_bug ( DUMMY_SP , format ! ( "`{value:?}` is not fully resolved" ) ) ;
1435+ Ok ( self . tcx . fold_regions ( value, |re, _| {
1436+ if re. is_var ( ) { ty:: Region :: new_error ( self . tcx , guar) } else { re }
1437+ } ) )
1438+ } else {
1439+ Ok ( value)
1440+ }
1441+ }
1442+ Err ( e) => Err ( e) ,
1443+ }
14311444 }
14321445
14331446 // Instantiates the bound variables in a given binder with fresh inference
0 commit comments