Dont unwrap and re-wrap typing envs · rust-lang/rust@6227acc (original) (raw)

4 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -389,6 +389,7 @@ tcx_lifetime! {
389 389 rustc_middle::ty::layout::FnAbiError,
390 390 rustc_middle::ty::layout::LayoutError,
391 391 rustc_middle::ty::ParamEnv,
392 + rustc_middle::ty::TypingEnv,
392 393 rustc_middle::ty::Predicate,
393 394 rustc_middle::ty::SymbolName,
394 395 rustc_middle::ty::TraitRef,
Original file line number Diff line number Diff line change
@@ -1571,7 +1571,7 @@ rustc_queries! {
1571 1571 /// Like `param_env`, but returns the `ParamEnv` after all opaque types have been
1572 1572 /// replaced with their hidden type. This is used in the old trait solver
1573 1573 /// when in `PostAnalysis` mode and should not be called directly.
1574 - query param_env_normalized_for_post_analysis(def_id: DefId) -> ty::ParamEnv<'tcx> {
1574 + query typing_env_normalized_for_post_analysis(def_id: DefId) -> ty::TypingEnv<'tcx> {
1575 1575 desc { |tcx
1576 1576 }
1577 1577
Original file line number Diff line number Diff line change
@@ -1116,10 +1116,7 @@ impl<'tcx> TypingEnv<'tcx> {
1116 1116 }
1117 1117
1118 1118 pub fn post_analysis(tcx: TyCtxt<'tcx>, def_id: impl IntoQueryParam<DefId>) -> TypingEnv<'tcx> {
1119 -TypingEnv {
1120 -typing_mode: TypingMode::PostAnalysis,
1121 -param_env: tcx.param_env_normalized_for_post_analysis(def_id),
1122 -}
1119 + tcx.typing_env_normalized_for_post_analysis(def_id)
1123 1120 }
1124 1121
1125 1122 /// Modify the `typing_mode` to `PostAnalysis` and eagerly reveal all
@@ -1133,7 +1130,7 @@ impl<'tcx> TypingEnv<'tcx> {
1133 1130 // No need to reveal opaques with the new solver enabled,
1134 1131 // since we have lazy norm.
1135 1132 let param_env = if tcx.next_trait_solver_globally() {
1136 -ParamEnv::new(param_env.caller_bounds())
1133 + param_env
1137 1134 } else {
1138 1135 ParamEnv::new(tcx.reveal_opaque_types_in_bounds(param_env.caller_bounds()))
1139 1136 };
Original file line number Diff line number Diff line change
@@ -255,10 +255,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
255 255 }
256 256 }
257 257
258 -fn param_env_normalized_for_post_analysis(tcx: TyCtxt<'_>, def_id: DefId) -> ty::ParamEnv<'_> {
259 -// This is a bit ugly but the easiest way to avoid code duplication.
260 -let typing_env = ty::TypingEnv::non_body_analysis(tcx, def_id);
261 - typing_env.with_post_analysis_normalized(tcx).param_env
258 +fn typing_env_normalized_for_post_analysis(tcx: TyCtxt<'_>, def_id: DefId) -> ty::TypingEnv<'_> {
259 + ty::TypingEnv::non_body_analysis(tcx, def_id).with_post_analysis_normalized(tcx)
262 260 }
263 261
264 262 /// Check if a function is async.
@@ -374,7 +372,7 @@ pub(crate) fn provide(providers: &mut Providers) {
374 372 asyncness,
375 373 adt_sized_constraint,
376 374 param_env,
377 -param_env_normalized_for_post_analysis,
375 +typing_env_normalized_for_post_analysis,
378 376 defaultness,
379 377 unsizing_params_for_adt,
380 378 impl_self_is_guaranteed_unsized,