11use rustc_data_structures:: fx:: FxIndexMap ;
22use rustc_errors:: ErrorGuaranteed ;
3+ use rustc_hir:: OpaqueTyOrigin ;
34use rustc_hir:: def_id:: LocalDefId ;
5+ use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
46use rustc_infer:: infer:: { InferCtxt , NllRegionVariableOrigin , TyCtxtInferExt as _} ;
57use rustc_macros:: extension;
68use rustc_middle:: ty:: fold:: fold_regions;
@@ -10,6 +12,7 @@ use rustc_middle::ty::{
1012 TypingMode ,
1113} ;
1214use rustc_span:: Span ;
15+ use rustc_trait_selection:: regions:: OutlivesEnvironmentBuildExt ;
1316use rustc_trait_selection:: traits:: ObligationCtxt ;
1417use tracing:: { debug, instrument} ;
1518
@@ -406,20 +409,16 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
406409 }
407410
408411 fn get_canonical_args ( & self ) -> ty:: GenericArgsRef < ' tcx > {
409- use rustc_hir as hir;
410- use rustc_infer:: infer:: outlives:: env:: OutlivesEnvironment ;
411- use rustc_trait_selection:: traits:: outlives_bounds:: InferCtxtExt as _;
412-
413412 if let Some ( & canonical_args) = self . canonical_args . get ( ) {
414413 return canonical_args;
415414 }
416415
417416 let & Self { tcx, def_id, .. } = self ;
418417 let origin = tcx. local_opaque_ty_origin ( def_id) ;
419418 let parent = match origin {
420- hir :: OpaqueTyOrigin :: FnReturn { parent, .. }
421- | hir :: OpaqueTyOrigin :: AsyncFn { parent, .. }
422- | hir :: OpaqueTyOrigin :: TyAlias { parent, .. } => parent,
419+ OpaqueTyOrigin :: FnReturn { parent, .. }
420+ | OpaqueTyOrigin :: AsyncFn { parent, .. }
421+ | OpaqueTyOrigin :: TyAlias { parent, .. } => parent,
423422 } ;
424423 let param_env = tcx. param_env ( parent) ;
425424 let args = GenericArgs :: identity_for_item ( tcx, parent) . extend_to (
@@ -439,8 +438,7 @@ impl<'tcx> LazyOpaqueTyEnv<'tcx> {
439438 tcx. dcx ( ) . span_delayed_bug ( tcx. def_span ( def_id) , "error getting implied bounds" ) ;
440439 Default :: default ( )
441440 } ) ;
442- let implied_bounds = infcx. implied_bounds_tys ( parent, param_env, wf_tys) ;
443- let outlives_env = OutlivesEnvironment :: with_bounds ( param_env, implied_bounds) ;
441+ let outlives_env = OutlivesEnvironment :: new ( & infcx, parent, param_env, wf_tys) ;
444442
445443 let mut seen = vec ! [ tcx. lifetimes. re_static] ;
446444 let canonical_args = fold_regions ( tcx, args, |r1, _| {
0 commit comments