@@ -17,7 +17,7 @@ use rustc_middle::middle::resolve_bound_vars::ResolvedArg;
17
17
use rustc_middle:: middle:: stability:: EvalResult ;
18
18
use rustc_middle:: span_bug;
19
19
use rustc_middle:: ty:: error:: TypeErrorToStringExt ;
20
- use rustc_middle:: ty:: fold:: BottomUpFolder ;
20
+ use rustc_middle:: ty:: fold:: { BottomUpFolder , fold_regions } ;
21
21
use rustc_middle:: ty:: layout:: { LayoutError , MAX_SIMD_LANES } ;
22
22
use rustc_middle:: ty:: util:: { Discr , InspectCoroutineFields , IntTypeExt } ;
23
23
use rustc_middle:: ty:: {
@@ -322,8 +322,12 @@ fn check_opaque_meets_bounds<'tcx>(
322
322
} ;
323
323
let param_env = tcx. param_env ( defining_use_anchor) ;
324
324
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
+ } ) ;
327
331
let ocx = ObligationCtxt :: new_with_diagnostics ( & infcx) ;
328
332
329
333
let args = match origin {
@@ -346,7 +350,7 @@ fn check_opaque_meets_bounds<'tcx>(
346
350
// FIXME: Consider wrapping the hidden type in an existential `Binder` and instantiating it
347
351
// here rather than using ReErased.
348
352
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 ( ) {
350
354
ty:: ReErased => infcx. next_region_var ( RegionVariableOrigin :: MiscVariable ( span) ) ,
351
355
_ => re,
352
356
} ) ;
@@ -417,7 +421,11 @@ fn check_opaque_meets_bounds<'tcx>(
417
421
let outlives_env = OutlivesEnvironment :: with_bounds ( param_env, implied_bounds) ;
418
422
ocx. resolve_regions_and_report_errors ( defining_use_anchor, & outlives_env) ?;
419
423
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
+ {
421
429
// HACK: this should also fall through to the hidden type check below, but the original
422
430
// implementation had a bug where equivalent lifetimes are not identical. This caused us
423
431
// to reject existing stable code that is otherwise completely fine. The real fix is to
0 commit comments