Remap more env constness for queries
This commit is contained in:
parent
2bea3b3aa3
commit
17b53b9645
@ -246,6 +246,14 @@ impl<'tcx, R> Canonical<'tcx, QueryResponse<'tcx, R>> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'tcx, R> Canonical<'tcx, ty::ParamEnvAnd<'tcx, R>> {
|
||||||
|
#[inline]
|
||||||
|
pub fn without_const(mut self) -> Self {
|
||||||
|
self.value = self.value.without_const();
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'tcx, V> Canonical<'tcx, V> {
|
impl<'tcx, V> Canonical<'tcx, V> {
|
||||||
/// Allows you to map the `value` of a canonical while keeping the
|
/// Allows you to map the `value` of a canonical while keeping the
|
||||||
/// same set of bound variables.
|
/// same set of bound variables.
|
||||||
|
@ -1655,6 +1655,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "normalizing `{:?}`", goal }
|
desc { "normalizing `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: Implement `normalize_generic_arg_after_erasing_regions` and
|
// FIXME: Implement `normalize_generic_arg_after_erasing_regions` and
|
||||||
@ -1701,6 +1702,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "computing implied outlives bounds for `{:?}`", goal }
|
desc { "computing implied outlives bounds for `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
|
/// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
|
||||||
@ -1711,6 +1713,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "computing dropck types for `{:?}`", goal }
|
desc { "computing dropck types for `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
|
/// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
|
||||||
@ -1738,6 +1741,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
|
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Eq` type-op
|
/// Do not call this query directly: part of the `Eq` type-op
|
||||||
@ -1748,6 +1752,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "evaluating `type_op_eq` `{:?}`", goal }
|
desc { "evaluating `type_op_eq` `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Subtype` type-op
|
/// Do not call this query directly: part of the `Subtype` type-op
|
||||||
@ -1758,6 +1763,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "evaluating `type_op_subtype` `{:?}`", goal }
|
desc { "evaluating `type_op_subtype` `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `ProvePredicate` type-op
|
/// Do not call this query directly: part of the `ProvePredicate` type-op
|
||||||
@ -1778,6 +1784,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "normalizing `{:?}`", goal }
|
desc { "normalizing `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Normalize` type-op
|
/// Do not call this query directly: part of the `Normalize` type-op
|
||||||
@ -1788,6 +1795,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "normalizing `{:?}`", goal }
|
desc { "normalizing `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Normalize` type-op
|
/// Do not call this query directly: part of the `Normalize` type-op
|
||||||
@ -1798,6 +1806,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "normalizing `{:?}`", goal }
|
desc { "normalizing `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Do not call this query directly: part of the `Normalize` type-op
|
/// Do not call this query directly: part of the `Normalize` type-op
|
||||||
@ -1808,6 +1817,7 @@ rustc_queries! {
|
|||||||
NoSolution,
|
NoSolution,
|
||||||
> {
|
> {
|
||||||
desc { "normalizing `{:?}`", goal }
|
desc { "normalizing `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
|
query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
|
||||||
@ -1821,6 +1831,7 @@ rustc_queries! {
|
|||||||
goal: CanonicalTyGoal<'tcx>
|
goal: CanonicalTyGoal<'tcx>
|
||||||
) -> MethodAutoderefStepsResult<'tcx> {
|
) -> MethodAutoderefStepsResult<'tcx> {
|
||||||
desc { "computing autoderef types for `{:?}`", goal }
|
desc { "computing autoderef types for `{:?}`", goal }
|
||||||
|
remap_env_constness
|
||||||
}
|
}
|
||||||
|
|
||||||
query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
|
query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
|
||||||
|
@ -1354,6 +1354,10 @@ impl<'tcx> ParamEnv<'tcx> {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn remap_constness_with(&mut self, mut constness: ty::BoundConstness) {
|
||||||
|
*self = self.with_constness(constness.and(self.constness()))
|
||||||
|
}
|
||||||
|
|
||||||
/// Returns a new parameter environment with the same clauses, but
|
/// Returns a new parameter environment with the same clauses, but
|
||||||
/// which "reveals" the true results of projections in all cases
|
/// which "reveals" the true results of projections in all cases
|
||||||
/// (even for associated types that are specializable). This is
|
/// (even for associated types that are specializable). This is
|
||||||
|
@ -67,27 +67,20 @@ impl<'cx, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'cx, 'tcx> {
|
|||||||
) -> Result<EvaluationResult, OverflowError> {
|
) -> Result<EvaluationResult, OverflowError> {
|
||||||
let mut _orig_values = OriginalQueryValues::default();
|
let mut _orig_values = OriginalQueryValues::default();
|
||||||
|
|
||||||
let (param_env, predicate) = match obligation.predicate.kind().skip_binder() {
|
let param_env = match obligation.predicate.kind().skip_binder() {
|
||||||
ty::PredicateKind::Trait(mut pred) => {
|
ty::PredicateKind::Trait(pred) => {
|
||||||
let orig_pred_constness = pred.constness;
|
// we ignore the value set to it.
|
||||||
let env_constness = pred.constness.and(obligation.param_env.constness());
|
let mut _constness = pred.constness;
|
||||||
|
obligation
|
||||||
let predicate = if orig_pred_constness != pred.constness {
|
.param_env
|
||||||
self.tcx.mk_predicate(
|
.with_constness(_constness.and(obligation.param_env.constness()))
|
||||||
obligation.predicate.kind().rebind(ty::PredicateKind::Trait(pred)),
|
|
||||||
)
|
|
||||||
} else {
|
|
||||||
obligation.predicate
|
|
||||||
};
|
|
||||||
|
|
||||||
(obligation.param_env.with_constness(env_constness), predicate)
|
|
||||||
}
|
}
|
||||||
// constness has no effect on the given predicate.
|
// constness has no effect on the given predicate.
|
||||||
_ => (obligation.param_env.without_const(), obligation.predicate),
|
_ => obligation.param_env.without_const(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let c_pred =
|
let c_pred = self
|
||||||
self.canonicalize_query_keep_static(param_env.and(predicate), &mut _orig_values);
|
.canonicalize_query_keep_static(param_env.and(obligation.predicate), &mut _orig_values);
|
||||||
// Run canonical query. If overflow occurs, rerun from scratch but this time
|
// Run canonical query. If overflow occurs, rerun from scratch but this time
|
||||||
// in standard trait query mode so that overflow is handled appropriately
|
// in standard trait query mode so that overflow is handled appropriately
|
||||||
// within `SelectionContext`.
|
// within `SelectionContext`.
|
||||||
|
@ -30,8 +30,14 @@ impl<'tcx> super::QueryTypeOp<'tcx> for ProvePredicate<'tcx> {
|
|||||||
|
|
||||||
fn perform_query(
|
fn perform_query(
|
||||||
tcx: TyCtxt<'tcx>,
|
tcx: TyCtxt<'tcx>,
|
||||||
canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
|
mut canonicalized: Canonicalized<'tcx, ParamEnvAnd<'tcx, Self>>,
|
||||||
) -> Fallible<CanonicalizedQueryResponse<'tcx, ()>> {
|
) -> 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)
|
tcx.type_op_prove_predicate(canonicalized)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user