Remap more env constness for queries
This commit is contained in:
parent
2bea3b3aa3
commit
17b53b9645
5 changed files with 40 additions and 18 deletions
|
@ -67,27 +67,20 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
|||
) -> Result<EvaluationResult, OverflowError> {
|
||||
let mut _orig_values = OriginalQueryValues::default();
|
||||
|
||||
let (param_env, predicate) = match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(mut pred) => {
|
||||
let orig_pred_constness = pred.constness;
|
||||
let env_constness = pred.constness.and(obligation.param_env.constness());
|
||||
|
||||
let predicate = if orig_pred_constness != pred.constness {
|
||||
self.tcx.mk_predicate(
|
||||
obligation.predicate.kind().rebind(ty::PredicateKind::Trait(pred)),
|
||||
)
|
||||
} else {
|
||||
obligation.predicate
|
||||
};
|
||||
|
||||
(obligation.param_env.with_constness(env_constness), predicate)
|
||||
let param_env = match obligation.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(pred) => {
|
||||
// we ignore the value set to it.
|
||||
let mut _constness = pred.constness;
|
||||
obligation
|
||||
.param_env
|
||||
.with_constness(_constness.and(obligation.param_env.constness()))
|
||||
}
|
||||
// constness has no effect on the given predicate.
|
||||
_ => (obligation.param_env.without_const(), obligation.predicate),
|
||||
_ => obligation.param_env.without_const(),
|
||||
};
|
||||
|
||||
let c_pred =
|
||||
self.canonicalize_query_keep_static(param_env.and(predicate), &mut _orig_values);
|
||||
let c_pred = self
|
||||
.canonicalize_query_keep_static(param_env.and(obligation.predicate), &mut _orig_values);
|
||||
// Run canonical query. If overflow occurs, rerun from scratch but this time
|
||||
// in standard trait query mode so that overflow is handled appropriately
|
||||
// within `SelectionContext`.
|
||||
|
|
|
@ -30,8 +30,14 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
|||
|
||||
fn perform_query(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
|
||||
mut canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
|
||||
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
|
||||
match canonicalized.value.value.predicate.kind().skip_binder() {
|
||||
ty::PredicateKind::Trait(pred) => {
|
||||
canonicalized.value.param_env.remap_constness_with(pred.constness);
|
||||
}
|
||||
_ => canonicalized.value.param_env = canonicalized.value.param_env.without_const(),
|
||||
}
|
||||
tcx.type_op_prove_predicate(canonicalized)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue