diff options
Diffstat (limited to 'compiler/rustc_ty_utils')
| -rw-r--r-- | compiler/rustc_ty_utils/src/abi.rs | 38 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 30 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout.rs | 44 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout/invariant.rs | 2 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/needs_drop.rs | 46 |
5 files changed, 88 insertions, 72 deletions
diff --git a/compiler/rustc_ty_utils/src/abi.rs b/compiler/rustc_ty_utils/src/abi.rs index 0184e93acf1..e2283383196 100644 --- a/compiler/rustc_ty_utils/src/abi.rs +++ b/compiler/rustc_ty_utils/src/abi.rs @@ -7,7 +7,7 @@ use rustc_hir::lang_items::LangItem; use rustc_middle::bug; use rustc_middle::query::Providers; use rustc_middle::ty::layout::{ - FnAbiError, HasParamEnv, HasTyCtxt, LayoutCx, LayoutOf, TyAndLayout, fn_can_unwind, + FnAbiError, HasTyCtxt, HasTypingEnv, LayoutCx, LayoutOf, TyAndLayout, fn_can_unwind, }; use rustc_middle::ty::{self, InstanceKind, Ty, TyCtxt}; use rustc_session::config::OptLevel; @@ -26,11 +26,11 @@ pub(crate) fn provide(providers: &mut Providers) { // for `Instance` (e.g. typeck would use `Ty::fn_sig` instead), // or should go through `FnAbi` instead, to avoid losing any // adjustments `fn_abi_of_instance` might be performing. -#[tracing::instrument(level = "debug", skip(tcx, param_env))] +#[tracing::instrument(level = "debug", skip(tcx, typing_env))] fn fn_sig_for_fn_abi<'tcx>( tcx: TyCtxt<'tcx>, instance: ty::Instance<'tcx>, - param_env: ty::ParamEnv<'tcx>, + typing_env: ty::TypingEnv<'tcx>, ) -> ty::PolyFnSig<'tcx> { if let InstanceKind::ThreadLocalShim(..) = instance.def { return ty::Binder::dummy(tcx.mk_fn_sig( @@ -42,7 +42,7 @@ fn fn_sig_for_fn_abi<'tcx>( )); } - let ty = instance.ty(tcx, param_env); + let ty = instance.ty(tcx, typing_env); match *ty.kind() { ty::FnDef(..) => { // HACK(davidtwco,eddyb): This is a workaround for polymorphization considering @@ -56,7 +56,10 @@ fn fn_sig_for_fn_abi<'tcx>( ty::FnDef(def_id, args) => tcx .fn_sig(def_id) .map_bound(|fn_sig| { - tcx.normalize_erasing_regions(tcx.param_env(def_id), fn_sig) + tcx.normalize_erasing_regions( + ty::TypingEnv::non_body_analysis(tcx, def_id), + fn_sig, + ) }) .instantiate(tcx, args), _ => unreachable!(), @@ -329,27 +332,26 @@ fn conv_from_spec_abi(tcx: TyCtxt<'_>, abi: ExternAbi, c_variadic: bool) -> Conv fn fn_abi_of_fn_ptr<'tcx>( tcx: TyCtxt<'tcx>, - query: ty::ParamEnvAnd<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>, + query: ty::PseudoCanonicalInput<'tcx, (ty::PolyFnSig<'tcx>, &'tcx ty::List<Ty<'tcx>>)>, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> { - let (param_env, (sig, extra_args)) = query.into_parts(); - - let cx = LayoutCx::new(tcx, param_env); + let ty::PseudoCanonicalInput { typing_env, value: (sig, extra_args) } = query; + let cx = LayoutCx::new(tcx, typing_env); fn_abi_new_uncached(&cx, sig, extra_args, None, None, false) } fn fn_abi_of_instance<'tcx>( tcx: TyCtxt<'tcx>, - query: ty::ParamEnvAnd<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>, + query: ty::PseudoCanonicalInput<'tcx, (ty::Instance<'tcx>, &'tcx ty::List<Ty<'tcx>>)>, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> { - let (param_env, (instance, extra_args)) = query.into_parts(); + let ty::PseudoCanonicalInput { typing_env, value: (instance, extra_args) } = query; - let sig = fn_sig_for_fn_abi(tcx, instance, param_env); + let sig = fn_sig_for_fn_abi(tcx, instance, typing_env); let caller_location = instance.def.requires_caller_location(tcx).then(|| tcx.caller_location_ty()); fn_abi_new_uncached( - &LayoutCx::new(tcx, param_env), + &LayoutCx::new(tcx, typing_env), sig, extra_args, caller_location, @@ -395,7 +397,7 @@ fn adjust_for_rust_scalar<'tcx>( Some(kind) } else if let Some(pointee) = drop_target_pointee { // The argument to `drop_in_place` is semantically equivalent to a mutable reference. - Some(PointerKind::MutableRef { unpin: pointee.is_unpin(tcx, cx.param_env()) }) + Some(PointerKind::MutableRef { unpin: pointee.is_unpin(tcx, cx.typing_env.param_env) }) } else { None }; @@ -542,7 +544,7 @@ fn fn_abi_sanity_check<'tcx>( // With metadata. Must be unsized and not on the stack. assert!(arg.layout.is_unsized() && !on_stack); // Also, must not be `extern` type. - let tail = tcx.struct_tail_for_codegen(arg.layout.ty, cx.param_env()); + let tail = tcx.struct_tail_for_codegen(arg.layout.ty, cx.typing_env); if matches!(tail.kind(), ty::Foreign(..)) { // These types do not have metadata, so having `meta_attrs` is bogus. // Conceptually, unsized arguments must be copied around, which requires dynamically @@ -573,7 +575,7 @@ fn fn_abi_new_uncached<'tcx>( force_thin_self_ptr: bool, ) -> Result<&'tcx FnAbi<'tcx, Ty<'tcx>>, &'tcx FnAbiError<'tcx>> { let tcx = cx.tcx(); - let sig = tcx.normalize_erasing_late_bound_regions(cx.param_env, sig); + let sig = tcx.normalize_erasing_late_bound_regions(cx.typing_env, sig); let conv = conv_from_spec_abi(cx.tcx(), sig.abi, sig.c_variadic); @@ -744,7 +746,7 @@ fn fn_abi_adjust_for_abi<'tcx>( #[tracing::instrument(level = "debug", skip(cx))] fn make_thin_self_ptr<'tcx>( - cx: &(impl HasTyCtxt<'tcx> + HasParamEnv<'tcx>), + cx: &(impl HasTyCtxt<'tcx> + HasTypingEnv<'tcx>), layout: TyAndLayout<'tcx>, ) -> TyAndLayout<'tcx> { let tcx = cx.tcx(); @@ -784,6 +786,6 @@ fn make_thin_self_ptr<'tcx>( // NOTE(eddyb) using an empty `ParamEnv`, and `unwrap`-ing the `Result` // should always work because the type is always `*mut ()`. - ..tcx.layout_of(ty::ParamEnv::reveal_all().and(unit_ptr_ty)).unwrap() + ..tcx.layout_of(ty::TypingEnv::fully_monomorphized().as_query_input(unit_ptr_ty)).unwrap() } } diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 1d8a0880760..84fc03a8f13 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -6,7 +6,9 @@ use rustc_middle::bug; use rustc_middle::query::Providers; use rustc_middle::traits::{BuiltinImplSource, CodegenObligationError}; use rustc_middle::ty::util::AsyncDropGlueMorphology; -use rustc_middle::ty::{self, GenericArgsRef, Instance, TyCtxt, TypeVisitableExt, TypingMode}; +use rustc_middle::ty::{ + self, GenericArgsRef, Instance, PseudoCanonicalInput, TyCtxt, TypeVisitableExt, +}; use rustc_span::sym; use rustc_trait_selection::traits; use rustc_type_ir::ClosureKind; @@ -17,18 +19,18 @@ use crate::errors::UnexpectedFnPtrAssociatedItem; fn resolve_instance_raw<'tcx>( tcx: TyCtxt<'tcx>, - key: ty::ParamEnvAnd<'tcx, (DefId, GenericArgsRef<'tcx>)>, + key: ty::PseudoCanonicalInput<'tcx, (DefId, GenericArgsRef<'tcx>)>, ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> { - let (param_env, (def_id, args)) = key.into_parts(); + let PseudoCanonicalInput { typing_env, value: (def_id, args) } = key; let result = if let Some(trait_def_id) = tcx.trait_of_item(def_id) { - debug!(" => associated item, attempting to find impl in param_env {:#?}", param_env); + debug!(" => associated item, attempting to find impl in typing_env {:#?}", typing_env); resolve_associated_item( tcx, def_id, - param_env, + typing_env, trait_def_id, - tcx.normalize_erasing_regions(param_env, args), + tcx.normalize_erasing_regions(typing_env, args), ) } else { let def = if tcx.intrinsic(def_id).is_some() { @@ -37,7 +39,7 @@ fn resolve_instance_raw<'tcx>( } else if tcx.is_lang_item(def_id, LangItem::DropInPlace) { let ty = args.type_at(0); - if ty.needs_drop(tcx, param_env) { + if ty.needs_drop(tcx, typing_env) { debug!(" => nontrivial drop glue"); match *ty.kind() { ty::Closure(..) @@ -93,15 +95,16 @@ fn resolve_instance_raw<'tcx>( fn resolve_associated_item<'tcx>( tcx: TyCtxt<'tcx>, trait_item_id: DefId, - param_env: ty::ParamEnv<'tcx>, + typing_env: ty::TypingEnv<'tcx>, trait_id: DefId, rcvr_args: GenericArgsRef<'tcx>, ) -> Result<Option<Instance<'tcx>>, ErrorGuaranteed> { - debug!(?trait_item_id, ?param_env, ?trait_id, ?rcvr_args, "resolve_associated_item"); + debug!(?trait_item_id, ?typing_env, ?trait_id, ?rcvr_args, "resolve_associated_item"); let trait_ref = ty::TraitRef::from_method(tcx, trait_id, rcvr_args); - let vtbl = match tcx.codegen_select_candidate((param_env, trait_ref)) { + let input = typing_env.as_query_input(trait_ref); + let vtbl = match tcx.codegen_select_candidate(input) { Ok(vtbl) => vtbl, Err( CodegenObligationError::Ambiguity @@ -116,7 +119,7 @@ fn resolve_associated_item<'tcx>( traits::ImplSource::UserDefined(impl_data) => { debug!( "resolving ImplSource::UserDefined: {:?}, {:?}, {:?}, {:?}", - param_env, trait_item_id, rcvr_args, impl_data + typing_env, trait_item_id, rcvr_args, impl_data ); assert!(!rcvr_args.has_infer()); assert!(!trait_ref.has_infer()); @@ -129,8 +132,9 @@ fn resolve_associated_item<'tcx>( .unwrap_or_else(|| { bug!("{:?} not found in {:?}", trait_item_id, impl_data.impl_def_id); }); - let infcx = tcx.infer_ctxt().build(TypingMode::PostAnalysis); - let param_env = param_env.with_reveal_all_normalized(tcx); + + let typing_env = typing_env.with_reveal_all_normalized(tcx); + let (infcx, param_env) = tcx.infer_ctxt().build_with_typing_env(typing_env); let args = rcvr_args.rebase_onto(tcx, trait_def_id, impl_data.args); let args = translate_args( &infcx, diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 63421dfdce6..02ee3f32915 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -19,7 +19,8 @@ use rustc_middle::ty::layout::{ }; use rustc_middle::ty::print::with_no_trimmed_paths; use rustc_middle::ty::{ - self, AdtDef, CoroutineArgsExt, EarlyBinder, GenericArgsRef, Ty, TyCtxt, TypeVisitableExt, + self, AdtDef, CoroutineArgsExt, EarlyBinder, GenericArgsRef, PseudoCanonicalInput, Ty, TyCtxt, + TypeVisitableExt, }; use rustc_session::{DataTypeKind, FieldInfo, FieldKind, SizeKind, VariantInfo}; use rustc_span::sym; @@ -40,22 +41,22 @@ pub(crate) fn provide(providers: &mut Providers) { #[instrument(skip(tcx, query), level = "debug")] fn layout_of<'tcx>( tcx: TyCtxt<'tcx>, - query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, + query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, ) -> Result<TyAndLayout<'tcx>, &'tcx LayoutError<'tcx>> { - let (param_env, ty) = query.into_parts(); + let PseudoCanonicalInput { typing_env, value: ty } = query; debug!(?ty); // Optimization: We convert to RevealAll and convert opaque types in the where bounds // to their hidden types. This reduces overall uncached invocations of `layout_of` and // is thus a small performance improvement. - let param_env = param_env.with_reveal_all_normalized(tcx); + let typing_env = typing_env.with_reveal_all_normalized(tcx); let unnormalized_ty = ty; // FIXME: We might want to have two different versions of `layout_of`: // One that can be called after typecheck has completed and can use // `normalize_erasing_regions` here and another one that can be called // before typecheck has completed and uses `try_normalize_erasing_regions`. - let ty = match tcx.try_normalize_erasing_regions(param_env, ty) { + let ty = match tcx.try_normalize_erasing_regions(typing_env, ty) { Ok(t) => t, Err(normalization_error) => { return Err(tcx @@ -66,10 +67,10 @@ fn layout_of<'tcx>( if ty != unnormalized_ty { // Ensure this layout is also cached for the normalized type. - return tcx.layout_of(param_env.and(ty)); + return tcx.layout_of(typing_env.as_query_input(ty)); } - let cx = LayoutCx::new(tcx, param_env); + let cx = LayoutCx::new(tcx, typing_env); let layout = layout_of_uncached(&cx, ty)?; let layout = TyAndLayout { ty, layout }; @@ -104,7 +105,7 @@ fn map_error<'tcx>( // This is sometimes not a compile error if there are trivially false where clauses. // See `tests/ui/layout/trivial-bounds-sized.rs` for an example. assert!(field.layout.is_unsized(), "invalid layout error {err:#?}"); - if !field.ty.is_sized(cx.tcx(), cx.param_env) { + if !field.ty.is_sized(cx.tcx(), cx.typing_env.param_env) { cx.tcx().dcx().delayed_bug(format!( "encountered unexpected unsized field in layout of {ty:?}: {field:#?}" )); @@ -152,7 +153,6 @@ fn layout_of_uncached<'tcx>( } let tcx = cx.tcx(); - let param_env = cx.param_env; let dl = cx.data_layout(); let scalar_unit = |value: Primitive| { let size = value.size(dl); @@ -178,12 +178,12 @@ fn layout_of_uncached<'tcx>( { if let Some(start) = start { scalar.valid_range_mut().start = start - .try_to_bits(tcx, param_env) + .try_to_bits(tcx, cx.typing_env) .ok_or_else(|| error(cx, LayoutError::Unknown(ty)))?; } if let Some(end) = end { let mut end = end - .try_to_bits(tcx, param_env) + .try_to_bits(tcx, cx.typing_env) .ok_or_else(|| error(cx, LayoutError::Unknown(ty)))?; if !include_end { end = end.wrapping_sub(1); @@ -235,8 +235,8 @@ fn layout_of_uncached<'tcx>( data_ptr.valid_range_mut().start = 1; } - let pointee = tcx.normalize_erasing_regions(param_env, pointee); - if pointee.is_sized(tcx, param_env) { + let pointee = tcx.normalize_erasing_regions(cx.typing_env, pointee); + if pointee.is_sized(tcx, cx.typing_env.param_env) { return Ok(tcx.mk_layout(LayoutData::scalar(cx, data_ptr))); } @@ -247,7 +247,7 @@ fn layout_of_uncached<'tcx>( { let pointee_metadata = Ty::new_projection(tcx, metadata_def_id, [pointee]); let metadata_ty = - match tcx.try_normalize_erasing_regions(param_env, pointee_metadata) { + match tcx.try_normalize_erasing_regions(cx.typing_env, pointee_metadata) { Ok(metadata_ty) => metadata_ty, Err(mut err) => { // Usually `<Ty as Pointee>::Metadata` can't be normalized because @@ -259,7 +259,7 @@ fn layout_of_uncached<'tcx>( // that is an alias, which is likely the cause of the normalization // error. match tcx.try_normalize_erasing_regions( - param_env, + cx.typing_env, tcx.struct_tail_raw(pointee, |ty| ty, || {}), ) { Ok(_) => {} @@ -283,7 +283,7 @@ fn layout_of_uncached<'tcx>( metadata } else { - let unsized_part = tcx.struct_tail_for_codegen(pointee, param_env); + let unsized_part = tcx.struct_tail_for_codegen(pointee, cx.typing_env); match unsized_part.kind() { ty::Foreign(..) => { @@ -316,7 +316,7 @@ fn layout_of_uncached<'tcx>( // Arrays and slices. ty::Array(element, mut count) => { if count.has_aliases() { - count = tcx.normalize_erasing_regions(param_env, count); + count = tcx.normalize_erasing_regions(cx.typing_env, count); if count.has_aliases() { return Err(error(cx, LayoutError::Unknown(ty))); } @@ -331,7 +331,7 @@ fn layout_of_uncached<'tcx>( .checked_mul(count, dl) .ok_or_else(|| error(cx, LayoutError::SizeOverflow(ty)))?; - let abi = if count != 0 && ty.is_privately_uninhabited(tcx, param_env) { + let abi = if count != 0 && ty.is_privately_uninhabited(tcx, cx.typing_env) { BackendRepr::Uninhabited } else { BackendRepr::Memory { sized: true } @@ -620,7 +620,11 @@ fn layout_of_uncached<'tcx>( // If the struct tail is sized and can be unsized, check that unsizing doesn't move the fields around. if cfg!(debug_assertions) && maybe_unsized - && def.non_enum_variant().tail().ty(tcx, args).is_sized(tcx, cx.param_env) + && def + .non_enum_variant() + .tail() + .ty(tcx, args) + .is_sized(tcx, cx.typing_env.param_env) { let mut variants = variants; let tail_replacement = cx.layout_of(Ty::new_slice(tcx, tcx.types.u8)).unwrap(); @@ -1024,7 +1028,7 @@ fn record_layout_for_printing<'tcx>(cx: &LayoutCx<'tcx>, layout: TyAndLayout<'tc // Ignore layouts that are done with non-empty environments or // non-monomorphic layouts, as the user only wants to see the stuff // resulting from the final codegen session. - if layout.ty.has_non_region_param() || !cx.param_env.caller_bounds().is_empty() { + if layout.ty.has_non_region_param() || !cx.typing_env.param_env.caller_bounds().is_empty() { return; } diff --git a/compiler/rustc_ty_utils/src/layout/invariant.rs b/compiler/rustc_ty_utils/src/layout/invariant.rs index fc05dd8256b..26ea81daf78 100644 --- a/compiler/rustc_ty_utils/src/layout/invariant.rs +++ b/compiler/rustc_ty_utils/src/layout/invariant.rs @@ -9,7 +9,7 @@ pub(super) fn partially_check_layout<'tcx>(cx: &LayoutCx<'tcx>, layout: &TyAndLa let tcx = cx.tcx(); // Type-level uninhabitedness should always imply ABI uninhabitedness. - if layout.ty.is_privately_uninhabited(tcx, cx.param_env) { + if layout.ty.is_privately_uninhabited(tcx, cx.typing_env) { assert!(layout.is_uninhabited()); } diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 5fecbd310b7..d462dbd9416 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -14,14 +14,17 @@ use crate::errors::NeedsDropOverflow; type NeedsDropResult<T> = Result<T, AlwaysRequiresDrop>; -fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { +fn needs_drop_raw<'tcx>( + tcx: TyCtxt<'tcx>, + query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, +) -> bool { // If we don't know a type doesn't need drop, for example if it's a type // parameter without a `Copy` bound, then we conservatively return that it // needs drop. let adt_has_dtor = |adt_def: ty::AdtDef<'tcx>| adt_def.destructor(tcx).map(|_| DtorType::Significant); - let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_dtor, false) - .filter(filter_array_elements(tcx, query.param_env)) + let res = drop_tys_helper(tcx, query.value, query.typing_env, adt_has_dtor, false) + .filter(filter_array_elements(tcx, query.typing_env)) .next() .is_some(); @@ -29,14 +32,17 @@ fn needs_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx> res } -fn needs_async_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>) -> bool { +fn needs_async_drop_raw<'tcx>( + tcx: TyCtxt<'tcx>, + query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, +) -> bool { // If we don't know a type doesn't need async drop, for example if it's a // type parameter without a `Copy` bound, then we conservatively return that // it needs async drop. let adt_has_async_dtor = |adt_def: ty::AdtDef<'tcx>| adt_def.async_destructor(tcx).map(|_| DtorType::Significant); - let res = drop_tys_helper(tcx, query.value, query.param_env, adt_has_async_dtor, false) - .filter(filter_array_elements(tcx, query.param_env)) + let res = drop_tys_helper(tcx, query.value, query.typing_env, adt_has_async_dtor, false) + .filter(filter_array_elements(tcx, query.typing_env)) .next() .is_some(); @@ -50,11 +56,11 @@ fn needs_async_drop_raw<'tcx>(tcx: TyCtxt<'tcx>, query: ty::ParamEnvAnd<'tcx, Ty /// logic that is easier to follow while not repeating any checks that may thus diverge. fn filter_array_elements<'tcx>( tcx: TyCtxt<'tcx>, - param_env: ty::ParamEnv<'tcx>, + typing_env: ty::TypingEnv<'tcx>, ) -> impl Fn(&Result<Ty<'tcx>, AlwaysRequiresDrop>) -> bool { move |ty| match ty { Ok(ty) => match *ty.kind() { - ty::Array(elem, _) => tcx.needs_drop_raw(param_env.and(elem)), + ty::Array(elem, _) => tcx.needs_drop_raw(typing_env.as_query_input(elem)), _ => true, }, Err(AlwaysRequiresDrop) => true, @@ -63,16 +69,16 @@ fn filter_array_elements<'tcx>( fn has_significant_drop_raw<'tcx>( tcx: TyCtxt<'tcx>, - query: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, + query: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, ) -> bool { let res = drop_tys_helper( tcx, query.value, - query.param_env, + query.typing_env, adt_consider_insignificant_dtor(tcx), true, ) - .filter(filter_array_elements(tcx, query.param_env)) + .filter(filter_array_elements(tcx, query.typing_env)) .next() .is_some(); debug!("has_significant_drop_raw({:?}) = {:?}", query, res); @@ -81,7 +87,7 @@ fn has_significant_drop_raw<'tcx>( struct NeedsDropTypes<'tcx, F> { tcx: TyCtxt<'tcx>, - param_env: ty::ParamEnv<'tcx>, + typing_env: ty::TypingEnv<'tcx>, // Whether to reveal coroutine witnesses, this is set // to `false` unless we compute `needs_drop` for a coroutine witness. reveal_coroutine_witnesses: bool, @@ -99,7 +105,7 @@ struct NeedsDropTypes<'tcx, F> { impl<'tcx, F> NeedsDropTypes<'tcx, F> { fn new( tcx: TyCtxt<'tcx>, - param_env: ty::ParamEnv<'tcx>, + typing_env: ty::TypingEnv<'tcx>, ty: Ty<'tcx>, adt_components: F, ) -> Self { @@ -107,7 +113,7 @@ impl<'tcx, F> NeedsDropTypes<'tcx, F> { seen_tys.insert(ty); Self { tcx, - param_env, + typing_env, reveal_coroutine_witnesses: false, seen_tys, query_ty: ty, @@ -180,7 +186,7 @@ where } } - _ if component.is_copy_modulo_regions(tcx, self.param_env) => (), + _ if component.is_copy_modulo_regions(tcx, self.typing_env.param_env) => (), ty::Closure(_, args) => { for upvar in args.as_closure().upvar_tys() { @@ -204,7 +210,7 @@ where }; for required_ty in tys { let required = tcx - .try_normalize_erasing_regions(self.param_env, required_ty) + .try_normalize_erasing_regions(self.typing_env, required_ty) .unwrap_or(required_ty); queue_type(self, required); @@ -271,7 +277,7 @@ enum DtorType { fn drop_tys_helper<'tcx>( tcx: TyCtxt<'tcx>, ty: Ty<'tcx>, - param_env: rustc_middle::ty::ParamEnv<'tcx>, + typing_env: ty::TypingEnv<'tcx>, adt_has_dtor: impl Fn(ty::AdtDef<'tcx>) -> Option<DtorType>, only_significant: bool, ) -> impl Iterator<Item = NeedsDropResult<Ty<'tcx>>> { @@ -337,7 +343,7 @@ fn drop_tys_helper<'tcx>( .map(|v| v.into_iter()) }; - NeedsDropTypes::new(tcx, param_env, ty, adt_components) + NeedsDropTypes::new(tcx, typing_env, ty, adt_components) } fn adt_consider_insignificant_dtor<'tcx>( @@ -375,7 +381,7 @@ fn adt_drop_tys<'tcx>( drop_tys_helper( tcx, tcx.type_of(def_id).instantiate_identity(), - tcx.param_env(def_id), + ty::TypingEnv::non_body_analysis(tcx, def_id), adt_has_dtor, false, ) @@ -392,7 +398,7 @@ fn adt_significant_drop_tys( drop_tys_helper( tcx, tcx.type_of(def_id).instantiate_identity(), // identical to `tcx.make_adt(def, identity_args)` - tcx.param_env(def_id), + ty::TypingEnv::non_body_analysis(tcx, def_id), adt_consider_insignificant_dtor(tcx), true, ) |
