diff options
Diffstat (limited to 'compiler/rustc_ty_utils/src')
| -rw-r--r-- | compiler/rustc_ty_utils/src/instance.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/layout.rs | 8 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/needs_drop.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_ty_utils/src/ty.rs | 11 | 
4 files changed, 18 insertions, 15 deletions
diff --git a/compiler/rustc_ty_utils/src/instance.rs b/compiler/rustc_ty_utils/src/instance.rs index 29fc92e1f2f..8798772e398 100644 --- a/compiler/rustc_ty_utils/src/instance.rs +++ b/compiler/rustc_ty_utils/src/instance.rs @@ -133,8 +133,10 @@ fn resolve_associated_item<'tcx>( bug!("{:?} not found in {:?}", trait_item_id, impl_data.impl_def_id); }); - // Since this is a trait item, we need to see if the item is either a trait default item - // or a specialization because we can't resolve those unless we can `Reveal::All`. + // Since this is a trait item, we need to see if the item is either a trait + // default item or a specialization because we can't resolve those until we're + // in `TypingMode::PostAnalysis`. + // // NOTE: This should be kept in sync with the similar code in // `rustc_trait_selection::traits::project::assemble_candidates_from_impls()`. let eligible = if leaf_def.is_final() { @@ -155,7 +157,7 @@ fn resolve_associated_item<'tcx>( return Ok(None); } - let typing_env = typing_env.with_reveal_all_normalized(tcx); + let typing_env = typing_env.with_post_analysis_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( diff --git a/compiler/rustc_ty_utils/src/layout.rs b/compiler/rustc_ty_utils/src/layout.rs index 092e140a600..66134b81b2a 100644 --- a/compiler/rustc_ty_utils/src/layout.rs +++ b/compiler/rustc_ty_utils/src/layout.rs @@ -46,10 +46,10 @@ fn layout_of<'tcx>( 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 typing_env = typing_env.with_reveal_all_normalized(tcx); + // Optimization: We convert to TypingMode::PostAnalysis 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 typing_env = typing_env.with_post_analysis_normalized(tcx); let unnormalized_ty = ty; // FIXME: We might want to have two different versions of `layout_of`: diff --git a/compiler/rustc_ty_utils/src/needs_drop.rs b/compiler/rustc_ty_utils/src/needs_drop.rs index 469a4ac3e41..d85da7d355e 100644 --- a/compiler/rustc_ty_utils/src/needs_drop.rs +++ b/compiler/rustc_ty_utils/src/needs_drop.rs @@ -431,13 +431,13 @@ fn adt_significant_drop_tys( #[instrument(level = "debug", skip(tcx), ret)] fn list_significant_drop_tys<'tcx>( tcx: TyCtxt<'tcx>, - ty: ty::ParamEnvAnd<'tcx, Ty<'tcx>>, + key: ty::PseudoCanonicalInput<'tcx, Ty<'tcx>>, ) -> &'tcx ty::List<Ty<'tcx>> { tcx.mk_type_list( &drop_tys_helper( tcx, - ty.value, - ty::TypingEnv { typing_mode: ty::TypingMode::PostAnalysis, param_env: ty.param_env }, + key.value, + key.typing_env, adt_consider_insignificant_dtor(tcx), true, true, diff --git a/compiler/rustc_ty_utils/src/ty.rs b/compiler/rustc_ty_utils/src/ty.rs index 292e777f288..61f2262dfe8 100644 --- a/compiler/rustc_ty_utils/src/ty.rs +++ b/compiler/rustc_ty_utils/src/ty.rs @@ -158,8 +158,7 @@ fn param_env(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { let local_did = def_id.as_local(); - let unnormalized_env = - ty::ParamEnv::new(tcx.mk_clauses(&predicates), traits::Reveal::UserFacing); + let unnormalized_env = ty::ParamEnv::new(tcx.mk_clauses(&predicates)); let body_id = local_did.unwrap_or(CRATE_DEF_ID); let cause = traits::ObligationCause::misc(tcx.def_span(def_id), body_id); @@ -249,8 +248,10 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> { } } -fn param_env_reveal_all_normalized(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { - tcx.param_env(def_id).with_reveal_all_normalized(tcx) +fn param_env_normalized_for_post_analysis(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> { + // This is a bit ugly but the easiest way to avoid code duplication. + let typing_env = ty::TypingEnv::non_body_analysis(tcx, def_id); + typing_env.with_post_analysis_normalized(tcx).param_env } /// If the given trait impl enables exploiting the former order dependence of trait objects, @@ -362,7 +363,7 @@ pub(crate) fn provide(providers: &mut Providers) { asyncness, adt_sized_constraint, param_env, - param_env_reveal_all_normalized, + param_env_normalized_for_post_analysis, self_ty_of_trait_impl_enabling_order_dep_trait_object_hack, defaultness, unsizing_params_for_adt,  | 
