mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
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> {
|
||||
/// Allows you to map the `value` of a canonical while keeping the
|
||||
/// same set of bound variables.
|
||||
|
@ -1655,6 +1655,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "normalizing `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
// FIXME: Implement `normalize_generic_arg_after_erasing_regions` and
|
||||
@ -1701,6 +1702,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "computing implied outlives bounds for `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: invoke `infcx.at().dropck_outlives()` instead.
|
||||
@ -1711,6 +1713,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "computing dropck types for `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: invoke `infcx.predicate_may_hold()` or
|
||||
@ -1738,6 +1741,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "evaluating `type_op_ascribe_user_type` `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: part of the `Eq` type-op
|
||||
@ -1748,6 +1752,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "evaluating `type_op_eq` `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: part of the `Subtype` type-op
|
||||
@ -1758,6 +1763,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "evaluating `type_op_subtype` `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: part of the `ProvePredicate` type-op
|
||||
@ -1778,6 +1784,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "normalizing `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: part of the `Normalize` type-op
|
||||
@ -1788,6 +1795,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "normalizing `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: part of the `Normalize` type-op
|
||||
@ -1798,6 +1806,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "normalizing `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
/// Do not call this query directly: part of the `Normalize` type-op
|
||||
@ -1808,6 +1817,7 @@ rustc_queries! {
|
||||
NoSolution,
|
||||
> {
|
||||
desc { "normalizing `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
query subst_and_check_impossible_predicates(key: (DefId, SubstsRef<'tcx>)) -> bool {
|
||||
@ -1821,6 +1831,7 @@ rustc_queries! {
|
||||
goal: CanonicalTyGoal<'tcx>
|
||||
) -> MethodAutoderefStepsResult<'tcx> {
|
||||
desc { "computing autoderef types for `{:?}`", goal }
|
||||
remap_env_constness
|
||||
}
|
||||
|
||||
query supported_target_features(_: CrateNum) -> FxHashMap<String, Option<Symbol>> {
|
||||
|
@ -1354,6 +1354,10 @@ impl<'tcx> ParamEnv<'tcx> {
|
||||
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
|
||||
/// which "reveals" the true results of projections in all cases
|
||||
/// (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> {
|
||||
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…
Reference in New Issue
Block a user