Skip to content

Commit 9ef19dd

Browse files
authored
Rollup merge of #142306 - compiler-errors:nit-reveal-param-env-query, r=lcnr
Dont unwrap and re-wrap typing envs Just a tiny tweak to make the query less awkward. r? lcnr
2 parents 80e294e + 6227acc commit 9ef19dd

File tree

4 files changed

+7
-11
lines changed

4 files changed

+7
-11
lines changed

compiler/rustc_middle/src/query/erase.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -389,6 +389,7 @@ tcx_lifetime! {
389389
rustc_middle::ty::layout::FnAbiError,
390390
rustc_middle::ty::layout::LayoutError,
391391
rustc_middle::ty::ParamEnv,
392+
rustc_middle::ty::TypingEnv,
392393
rustc_middle::ty::Predicate,
393394
rustc_middle::ty::SymbolName,
394395
rustc_middle::ty::TraitRef,

compiler/rustc_middle/src/query/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1566,7 +1566,7 @@ rustc_queries! {
15661566
/// Like `param_env`, but returns the `ParamEnv` after all opaque types have been
15671567
/// replaced with their hidden type. This is used in the old trait solver
15681568
/// when in `PostAnalysis` mode and should not be called directly.
1569-
query param_env_normalized_for_post_analysis(def_id: DefId) -> ty::ParamEnv<'tcx> {
1569+
query typing_env_normalized_for_post_analysis(def_id: DefId) -> ty::TypingEnv<'tcx> {
15701570
desc { |tcx| "computing revealed normalized predicates of `{}`", tcx.def_path_str(def_id) }
15711571
}
15721572

compiler/rustc_middle/src/ty/mod.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1116,10 +1116,7 @@ impl<'tcx> TypingEnv<'tcx> {
11161116
}
11171117

11181118
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)
11231120
}
11241121

11251122
/// Modify the `typing_mode` to `PostAnalysis` and eagerly reveal all
@@ -1133,7 +1130,7 @@ impl<'tcx> TypingEnv<'tcx> {
11331130
// No need to reveal opaques with the new solver enabled,
11341131
// since we have lazy norm.
11351132
let param_env = if tcx.next_trait_solver_globally() {
1136-
ParamEnv::new(param_env.caller_bounds())
1133+
param_env
11371134
} else {
11381135
ParamEnv::new(tcx.reveal_opaque_types_in_bounds(param_env.caller_bounds()))
11391136
};

compiler/rustc_ty_utils/src/ty.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,8 @@ impl<'tcx> TypeVisitor<TyCtxt<'tcx>> for ImplTraitInTraitFinder<'_, 'tcx> {
255255
}
256256
}
257257

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)
262260
}
263261

264262
/// Check if a function is async.
@@ -374,7 +372,7 @@ pub(crate) fn provide(providers: &mut Providers) {
374372
asyncness,
375373
adt_sized_constraint,
376374
param_env,
377-
param_env_normalized_for_post_analysis,
375+
typing_env_normalized_for_post_analysis,
378376
defaultness,
379377
unsizing_params_for_adt,
380378
impl_self_is_guaranteed_unsized,

0 commit comments

Comments
 (0)