Add constness to ParamEnv

This now causes a lot of queries to be executed twice, as reveal_all forces NotConst
This commit is contained in:
Oli Scherer 2021-10-21 14:56:00 +00:00 committed by Deadbeef
parent 22eeff700e
commit 721ffd14c3
No known key found for this signature in database
GPG key ID: 6D017A96D8E6C2F9
8 changed files with 126 additions and 45 deletions

View file

@ -370,12 +370,17 @@ impl AutoTraitFinder<'tcx> {
computed_preds.clone().chain(user_computed_preds.iter().cloned()),
)
.map(|o| o.predicate);
new_env = ty::ParamEnv::new(tcx.mk_predicates(normalized_preds), param_env.reveal());
new_env = ty::ParamEnv::new(
tcx.mk_predicates(normalized_preds),
param_env.reveal(),
param_env.constness(),
);
}
let final_user_env = ty::ParamEnv::new(
tcx.mk_predicates(user_computed_preds.into_iter()),
user_env.reveal(),
user_env.constness(),
);
debug!(
"evaluate_nested_obligations(ty={:?}, trait_did={:?}): succeeded with '{:?}' \

View file

@ -307,8 +307,11 @@ pub fn normalize_param_env_or_error<'tcx>(
debug!("normalize_param_env_or_error: elaborated-predicates={:?}", predicates);
let elaborated_env =
ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal());
let elaborated_env = ty::ParamEnv::new(
tcx.intern_predicates(&predicates),
unnormalized_env.reveal(),
unnormalized_env.constness(),
);
// HACK: we are trying to normalize the param-env inside *itself*. The problem is that
// normalization expects its param-env to be already normalized, which means we have
@ -360,8 +363,11 @@ pub fn normalize_param_env_or_error<'tcx>(
// predicates here anyway. Keeping them here anyway because it seems safer.
let outlives_env: Vec<_> =
non_outlives_predicates.iter().chain(&outlives_predicates).cloned().collect();
let outlives_env =
ty::ParamEnv::new(tcx.intern_predicates(&outlives_env), unnormalized_env.reveal());
let outlives_env = ty::ParamEnv::new(
tcx.intern_predicates(&outlives_env),
unnormalized_env.reveal(),
unnormalized_env.constness(),
);
let outlives_predicates = match do_normalize_predicates(
tcx,
region_context,
@ -381,7 +387,11 @@ pub fn normalize_param_env_or_error<'tcx>(
let mut predicates = non_outlives_predicates;
predicates.extend(outlives_predicates);
debug!("normalize_param_env_or_error: final predicates={:?}", predicates);
ty::ParamEnv::new(tcx.intern_predicates(&predicates), unnormalized_env.reveal())
ty::ParamEnv::new(
tcx.intern_predicates(&predicates),
unnormalized_env.reveal(),
unnormalized_env.constness(),
)
}
pub fn fully_normalize<'a, 'tcx, T>(

View file

@ -698,7 +698,11 @@ fn receiver_is_dispatchable<'tcx>(
.chain(array::IntoIter::new([unsize_predicate, trait_predicate]))
.collect();
ty::ParamEnv::new(tcx.intern_predicates(&caller_bounds), param_env.reveal())
ty::ParamEnv::new(
tcx.intern_predicates(&caller_bounds),
param_env.reveal(),
param_env.constness(),
)
};
// Receiver: DispatchFromDyn<Receiver[Self => U]>