@@ -17,7 +17,7 @@ use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
1717use rustc_middle:: middle:: stability:: EvalResult ;
1818use rustc_middle:: span_bug;
1919use rustc_middle:: ty:: error:: TypeErrorToStringExt ;
20- use rustc_middle:: ty:: fold:: BottomUpFolder ;
20+ use rustc_middle:: ty:: fold:: { BottomUpFolder , fold_regions } ;
2121use rustc_middle:: ty:: layout:: { LayoutError , MAX_SIMD_LANES } ;
2222use rustc_middle:: ty:: util:: { Discr , InspectCoroutineFields , IntTypeExt } ;
2323use rustc_middle:: ty:: {
@@ -322,8 +322,12 @@ fn check_opaque_meets_bounds<'tcx>(
322322 } ;
323323 let param_env = tcx. param_env ( defining_use_anchor) ;
324324
325- // FIXME(#132279): This should eventually use the already defined hidden types.
326- let infcx = tcx. infer_ctxt ( ) . build ( TypingMode :: analysis_in_body ( tcx, defining_use_anchor) ) ;
325+ // FIXME(#132279): Once `PostBorrowckAnalysis` is supported in the old solver, this branch should be removed.
326+ let infcx = tcx. infer_ctxt ( ) . build ( if tcx. next_trait_solver_globally ( ) {
327+ TypingMode :: post_borrowck_analysis ( tcx, defining_use_anchor)
328+ } else {
329+ TypingMode :: analysis_in_body ( tcx, defining_use_anchor)
330+ } ) ;
327331 let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
328332
329333 let args = match origin {
@@ -346,7 +350,7 @@ fn check_opaque_meets_bounds<'tcx>(
346350 // FIXME: Consider wrapping the hidden type in an existential `Binder` and instantiating it
347351 // here rather than using ReErased.
348352 let hidden_ty = tcx. type_of ( def_id. to_def_id ( ) ) . instantiate ( tcx, args) ;
349- let hidden_ty = tcx . fold_regions ( hidden_ty, |re, _dbi| match re. kind ( ) {
353+ let hidden_ty = fold_regions ( tcx , hidden_ty, |re, _dbi| match re. kind ( ) {
350354 ty:: ReErased => infcx. next_region_var ( RegionVariableOrigin :: MiscVariable ( span) ) ,
351355 _ => re,
352356 } ) ;
@@ -417,7 +421,11 @@ fn check_opaque_meets_bounds<'tcx>(
417421 let outlives_env = OutlivesEnvironment :: with_bounds ( param_env, implied_bounds) ;
418422 ocx. resolve_regions_and_report_errors ( defining_use_anchor, & outlives_env) ?;
419423
420- if let hir:: OpaqueTyOrigin :: FnReturn { .. } | hir:: OpaqueTyOrigin :: AsyncFn { .. } = origin {
424+ if infcx. next_trait_solver ( ) {
425+ Ok ( ( ) )
426+ } else if let hir:: OpaqueTyOrigin :: FnReturn { .. } | hir:: OpaqueTyOrigin :: AsyncFn { .. } =
427+ origin
428+ {
421429 // HACK: this should also fall through to the hidden type check below, but the original
422430 // implementation had a bug where equivalent lifetimes are not identical. This caused us
423431 // to reject existing stable code that is otherwise completely fine. The real fix is to
0 commit comments