Canonical<'tcx, ty::ParamEnvAnd<'tcx, ty::Predicate<'tcx>>>;
pub type CanonicalTypeOpEqGoal<'tcx> =
- Canonical<'tcx, type_op::eq::Eq<'tcx>>;
+ Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::eq::Eq<'tcx>>>;
pub type CanonicalTypeOpSubtypeGoal<'tcx> =
- Canonical<'tcx, type_op::subtype::Subtype<'tcx>>;
+ Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::subtype::Subtype<'tcx>>>;
pub type CanonicalTypeOpProvePredicateGoal<'tcx> =
- Canonical<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>;
+ Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::prove_predicate::ProvePredicate<'tcx>>>;
pub type CanonicalTypeOpNormalizeGoal<'tcx, T> =
- Canonical<'tcx, type_op::normalize::Normalize<'tcx, T>>;
+ Canonical<'tcx, ty::ParamEnvAnd<'tcx, type_op::normalize::Normalize<T>>>;
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
pub struct NoSolution;
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use infer::canonical::{Canonical, CanonicalizedQueryResult, QueryResult};
+use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult};
use traits::query::Fallible;
-use ty::{ParamEnv, Ty, TyCtxt};
+use ty::{ParamEnvAnd, Ty, TyCtxt};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct Eq<'tcx> {
- pub param_env: ParamEnv<'tcx>,
pub a: Ty<'tcx>,
pub b: Ty<'tcx>,
}
impl<'tcx> Eq<'tcx> {
- pub fn new(param_env: ParamEnv<'tcx>, a: Ty<'tcx>, b: Ty<'tcx>) -> Self {
- Self { param_env, a, b }
+ pub fn new(a: Ty<'tcx>, b: Ty<'tcx>) -> Self {
+ Self { a, b }
}
}
impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
- type QueryKey = Self;
type QueryResult = ();
- fn prequery(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self> {
- if self.a == self.b {
- Ok(())
+ fn prequery(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Eq<'tcx>>) -> Option<Self::QueryResult> {
+ if key.value.a == key.value.b {
+ Some(())
} else {
- Err(self)
+ None
}
}
- fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx> {
- key.param_env
- }
-
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonical<'gcx, Eq<'gcx>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, ()>> {
tcx.type_op_eq(canonicalized)
}
BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for Eq<'tcx> {
- param_env,
a,
b,
}
BraceStructLiftImpl! {
impl<'a, 'tcx> Lift<'tcx> for Eq<'a> {
type Lifted = Eq<'tcx>;
- param_env,
a,
b,
}
}
impl_stable_hash_for! {
- struct Eq<'tcx> { param_env, a, b }
+ struct Eq<'tcx> { a, b }
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use infer::canonical::{
- Canonical, Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint, QueryResult,
-};
+use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryRegionConstraint,
+ QueryResult};
use infer::{InferCtxt, InferOk};
use std::fmt;
use std::rc::Rc;
use traits::query::Fallible;
use traits::ObligationCause;
use ty::fold::TypeFoldable;
-use ty::{Lift, ParamEnv, TyCtxt};
+use ty::{Lift, ParamEnvAnd, TyCtxt};
pub mod custom;
pub mod eq;
pub mod normalize;
pub mod outlives;
pub mod prove_predicate;
+use self::prove_predicate::ProvePredicate;
pub mod subtype;
pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)>;
}
-pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
- type QueryKey: TypeFoldable<'tcx> + Lift<'gcx>;
+pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>:
+ fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'gcx>
+{
type QueryResult: TypeFoldable<'tcx> + Lift<'gcx>;
/// Either converts `self` directly into a `QueryResult` (for
/// simple cases) or into a `QueryKey` (for more complex cases
/// where we actually have work to do).
- fn prequery(self, tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self::QueryKey>;
-
- fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx>;
+ fn prequery(
+ tcx: TyCtxt<'_, 'gcx, 'tcx>,
+ key: &ParamEnvAnd<'tcx, Self>,
+ ) -> Option<Self::QueryResult>;
/// Performs the actual query with the canonicalized key -- the
/// real work happens here. This method is not given an `infcx`
/// not captured in the return value.
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Self::QueryKey>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>>;
/// Casts a lifted query result (which is in the gcx lifetime)
) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>>;
fn fully_perform_into(
- self,
+ query_key: ParamEnvAnd<'tcx, Self>,
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
output_query_region_constraints: &mut Vec<QueryRegionConstraint<'tcx>>,
) -> Fallible<Self::QueryResult> {
- match QueryTypeOp::prequery(self, infcx.tcx) {
- Ok(result) => Ok(result),
- Err(query_key) => {
- // FIXME(#33684) -- We need to use
- // `canonicalize_hr_query_hack` here because of things
- // like the subtype query, which go awry around
- // `'static` otherwise.
- let (canonical_self, canonical_var_values) =
- infcx.canonicalize_hr_query_hack(&query_key);
- let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
- let canonical_result = Self::shrink_to_tcx_lifetime(&canonical_result);
-
- let param_env = Self::param_env(&query_key);
-
- let InferOk { value, obligations } = infcx
- .instantiate_nll_query_result_and_region_obligations(
- &ObligationCause::dummy(),
- param_env,
- &canonical_var_values,
- canonical_result,
- output_query_region_constraints,
- )?;
-
- // Typically, instantiating NLL query results does not
- // create obligations. However, in some cases there
- // are unresolved type variables, and unify them *can*
- // create obligations. In that case, we have to go
- // fulfill them. We do this via a (recursive) query.
- for obligation in obligations {
- let () = prove_predicate::ProvePredicate::new(
- obligation.param_env,
- obligation.predicate,
- ).fully_perform_into(infcx, output_query_region_constraints)?;
- }
-
- Ok(value)
- }
+ if let Some(result) = QueryTypeOp::prequery(infcx.tcx, &query_key) {
+ return Ok(result);
}
+
+ // FIXME(#33684) -- We need to use
+ // `canonicalize_hr_query_hack` here because of things
+ // like the subtype query, which go awry around
+ // `'static` otherwise.
+ let (canonical_self, canonical_var_values) = infcx.canonicalize_hr_query_hack(&query_key);
+ let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
+ let canonical_result = Self::shrink_to_tcx_lifetime(&canonical_result);
+
+ let param_env = query_key.param_env;
+
+ let InferOk { value, obligations } = infcx
+ .instantiate_nll_query_result_and_region_obligations(
+ &ObligationCause::dummy(),
+ param_env,
+ &canonical_var_values,
+ canonical_result,
+ output_query_region_constraints,
+ )?;
+
+ // Typically, instantiating NLL query results does not
+ // create obligations. However, in some cases there
+ // are unresolved type variables, and unify them *can*
+ // create obligations. In that case, we have to go
+ // fulfill them. We do this via a (recursive) query.
+ for obligation in obligations {
+ let () = ProvePredicate::fully_perform_into(
+ obligation
+ .param_env
+ .and(ProvePredicate::new(obligation.predicate)),
+ infcx,
+ output_query_region_constraints,
+ )?;
+ }
+
+ Ok(value)
}
}
-impl<'gcx: 'tcx, 'tcx, Q> TypeOp<'gcx, 'tcx> for Q
+impl<'gcx: 'tcx, 'tcx, Q> TypeOp<'gcx, 'tcx> for ParamEnvAnd<'tcx, Q>
where
Q: QueryTypeOp<'gcx, 'tcx>,
{
use std::fmt;
use traits::query::Fallible;
use ty::fold::TypeFoldable;
-use ty::{self, Lift, ParamEnv, Ty, TyCtxt};
+use ty::{self, Lift, ParamEnvAnd, Ty, TyCtxt};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
-pub struct Normalize<'tcx, T> {
- pub param_env: ParamEnv<'tcx>,
+pub struct Normalize<T> {
pub value: T,
}
-impl<'tcx, T> Normalize<'tcx, T>
+impl<'tcx, T> Normalize<T>
where
T: fmt::Debug + TypeFoldable<'tcx>,
{
- pub fn new(param_env: ParamEnv<'tcx>, value: T) -> Self {
- Self { param_env, value }
+ pub fn new(value: T) -> Self {
+ Self { value }
}
}
-impl<'gcx: 'tcx, 'tcx, T> super::QueryTypeOp<'gcx, 'tcx> for Normalize<'tcx, T>
+impl<'gcx: 'tcx, 'tcx, T> super::QueryTypeOp<'gcx, 'tcx> for Normalize<T>
where
T: Normalizable<'gcx, 'tcx>,
{
- type QueryKey = Self;
type QueryResult = T;
- fn prequery(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<T, Self> {
- if !self.value.has_projections() {
- Ok(self.value)
+ fn prequery(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<T> {
+ if !key.value.value.has_projections() {
+ Some(key.value.value)
} else {
- Err(self)
+ None
}
}
- fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx> {
- key.param_env
- }
-
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Self>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>> {
T::type_op_method(tcx, canonicalized)
}
}
}
-pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx> {
+pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx> + Copy {
fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Normalize<'gcx, Self>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self>>;
/// Convert from the `'gcx` (lifted) form of `Self` into the `tcx`
{
fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Normalize<'gcx, Self>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self>> {
tcx.type_op_normalize_ty(canonicalized)
}
{
fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Normalize<'gcx, Self>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self>> {
tcx.type_op_normalize_predicate(canonicalized)
}
{
fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Normalize<'gcx, Self>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self>> {
tcx.type_op_normalize_poly_fn_sig(canonicalized)
}
{
fn type_op_method(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Normalize<'gcx, Self>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Normalize<Self>>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self>> {
tcx.type_op_normalize_fn_sig(canonicalized)
}
}
BraceStructTypeFoldableImpl! {
- impl<'tcx, T> TypeFoldable<'tcx> for Normalize<'tcx, T> {
- param_env,
+ impl<'tcx, T> TypeFoldable<'tcx> for Normalize<T> {
value,
} where T: TypeFoldable<'tcx>,
}
BraceStructLiftImpl! {
- impl<'a, 'tcx, T> Lift<'tcx> for Normalize<'a, T> {
- type Lifted = Normalize<'tcx, T::Lifted>;
- param_env,
+ impl<'tcx, T> Lift<'tcx> for Normalize<T> {
+ type Lifted = Normalize<T::Lifted>;
value,
} where T: Lift<'tcx>,
}
impl_stable_hash_for! {
- impl<'tcx, T> for struct Normalize<'tcx, T> {
- param_env, value
+ impl<'tcx, T> for struct Normalize<T> {
+ value
}
}
use traits::query::dropck_outlives::trivial_dropck_outlives;
use traits::query::dropck_outlives::DropckOutlivesResult;
use traits::query::Fallible;
-use ty::{ParamEnv, ParamEnvAnd, Ty, TyCtxt};
+use ty::{ParamEnvAnd, Ty, TyCtxt};
-#[derive(Debug)]
+#[derive(Copy, Clone, Debug)]
pub struct DropckOutlives<'tcx> {
- param_env: ParamEnv<'tcx>,
dropped_ty: Ty<'tcx>,
}
impl<'tcx> DropckOutlives<'tcx> {
- pub fn new(param_env: ParamEnv<'tcx>, dropped_ty: Ty<'tcx>) -> Self {
- DropckOutlives {
- param_env,
- dropped_ty,
- }
+ pub fn new(dropped_ty: Ty<'tcx>) -> Self {
+ DropckOutlives { dropped_ty }
}
}
where
'gcx: 'tcx,
{
- type QueryKey = ParamEnvAnd<'tcx, Ty<'tcx>>;
type QueryResult = DropckOutlivesResult<'tcx>;
- fn prequery(self, tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self::QueryKey> {
- if trivial_dropck_outlives(tcx, self.dropped_ty) {
- Ok(DropckOutlivesResult::default())
+ fn prequery(
+ tcx: TyCtxt<'_, 'gcx, 'tcx>,
+ key: &ParamEnvAnd<'tcx, Self>,
+ ) -> Option<Self::QueryResult> {
+ if trivial_dropck_outlives(tcx, key.value.dropped_ty) {
+ Some(DropckOutlivesResult::default())
} else {
- Err(self.param_env.and(self.dropped_ty))
+ None
}
}
- fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx> {
- key.param_env
- }
-
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonicalized<'gcx, Self::QueryKey>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>> {
// Subtle: note that we are not invoking
// `infcx.at(...).dropck_outlives(...)` here, but rather the
// good because the interface doesn't give us one (so that we
// know we are not registering any subregion relations or
// other things).
+
+ // FIXME convert to the type expected by the `dropck_outlives`
+ // query. This should eventually be fixed by changing the
+ // *underlying query*.
+ let Canonical {
+ variables,
+ value:
+ ParamEnvAnd {
+ param_env,
+ value: DropckOutlives { dropped_ty },
+ },
+ } = canonicalized;
+ let canonicalized = Canonical {
+ variables,
+ value: param_env.and(dropped_ty),
+ };
+
tcx.dropck_outlives(canonicalized)
}
lifted_query_result
}
}
+
+BraceStructTypeFoldableImpl! {
+ impl<'tcx> TypeFoldable<'tcx> for DropckOutlives<'tcx> {
+ dropped_ty
+ }
+}
+
+BraceStructLiftImpl! {
+ impl<'a, 'tcx> Lift<'tcx> for DropckOutlives<'a> {
+ type Lifted = DropckOutlives<'tcx>;
+ dropped_ty
+ }
+}
+
+impl_stable_hash_for! {
+ struct DropckOutlives<'tcx> { dropped_ty }
+}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use infer::canonical::{Canonical, CanonicalizedQueryResult, QueryResult};
+use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult};
use traits::query::Fallible;
-use ty::{ParamEnv, Predicate, TyCtxt};
+use ty::{ParamEnvAnd, Predicate, TyCtxt};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct ProvePredicate<'tcx> {
- pub param_env: ParamEnv<'tcx>,
pub predicate: Predicate<'tcx>,
}
impl<'tcx> ProvePredicate<'tcx> {
- pub fn new(param_env: ParamEnv<'tcx>, predicate: Predicate<'tcx>) -> Self {
+ pub fn new(predicate: Predicate<'tcx>) -> Self {
ProvePredicate {
- param_env,
predicate,
}
}
}
impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
- type QueryKey = Self;
type QueryResult = ();
- fn prequery(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self::QueryKey> {
- Err(self)
- }
-
- fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx> {
- key.param_env
+ fn prequery(_tcx: TyCtxt<'_, 'gcx, 'tcx>, _key: &ParamEnvAnd<'tcx, Self>) -> Option<Self::QueryResult> {
+ None
}
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonical<'gcx, ProvePredicate<'gcx>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, ()>> {
tcx.type_op_prove_predicate(canonicalized)
}
BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for ProvePredicate<'tcx> {
- param_env,
predicate,
}
}
BraceStructLiftImpl! {
impl<'a, 'tcx> Lift<'tcx> for ProvePredicate<'a> {
type Lifted = ProvePredicate<'tcx>;
- param_env,
predicate,
}
}
impl_stable_hash_for! {
- struct ProvePredicate<'tcx> { param_env, predicate }
+ struct ProvePredicate<'tcx> { predicate }
}
// option. This file may not be copied, modified, or distributed
// except according to those terms.
-use infer::canonical::{Canonical, CanonicalizedQueryResult, QueryResult};
+use infer::canonical::{Canonical, Canonicalized, CanonicalizedQueryResult, QueryResult};
use traits::query::Fallible;
-use ty::{ParamEnv, Ty, TyCtxt};
+use ty::{ParamEnvAnd, Ty, TyCtxt};
#[derive(Copy, Clone, Debug, Hash, PartialEq, Eq)]
pub struct Subtype<'tcx> {
- pub param_env: ParamEnv<'tcx>,
pub sub: Ty<'tcx>,
pub sup: Ty<'tcx>,
}
impl<'tcx> Subtype<'tcx> {
- pub fn new(param_env: ParamEnv<'tcx>, sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self {
+ pub fn new(sub: Ty<'tcx>, sup: Ty<'tcx>) -> Self {
Self {
- param_env,
sub,
sup,
}
}
impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
- type QueryKey = Self;
type QueryResult = ();
- fn prequery(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<(), Self::QueryKey> {
- if self.sub == self.sup {
- Ok(())
+ fn prequery(_tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>) -> Option<()> {
+ if key.value.sub == key.value.sup {
+ Some(())
} else {
- Err(self)
+ None
}
}
- fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx> {
- key.param_env
- }
-
fn perform_query(
tcx: TyCtxt<'_, 'gcx, 'tcx>,
- canonicalized: Canonical<'gcx, Subtype<'gcx>>,
+ canonicalized: Canonicalized<'gcx, ParamEnvAnd<'tcx, Self>>,
) -> Fallible<CanonicalizedQueryResult<'gcx, ()>> {
tcx.type_op_subtype(canonicalized)
}
BraceStructTypeFoldableImpl! {
impl<'tcx> TypeFoldable<'tcx> for Subtype<'tcx> {
- param_env,
sub,
sup,
}
BraceStructLiftImpl! {
impl<'a, 'tcx> Lift<'tcx> for Subtype<'a> {
type Lifted = Subtype<'tcx>;
- param_env,
sub,
sup,
}
}
impl_stable_hash_for! {
- struct Subtype<'tcx> { param_env, sub, sup }
+ struct Subtype<'tcx> { sub, sup }
}
use dataflow::move_paths::{HasMoveData, MoveData};
use dataflow::MaybeInitializedPlaces;
use dataflow::{FlowAtLocation, FlowsAtLocation};
-use rustc::traits::query::dropck_outlives::DropckOutlivesResult;
use rustc::infer::canonical::QueryRegionConstraint;
use rustc::mir::Local;
use rustc::mir::{BasicBlock, Location, Mir};
+use rustc::traits::query::dropck_outlives::DropckOutlivesResult;
use rustc::traits::query::type_op::outlives::DropckOutlives;
use rustc::traits::query::type_op::TypeOp;
use rustc::ty::{Ty, TypeFoldable};
debug!("compute_drop_data(dropped_ty={:?})", dropped_ty,);
let param_env = cx.param_env;
- let (dropck_result, region_constraint_data) = DropckOutlives::new(param_env, dropped_ty)
+ let (dropck_result, region_constraint_data) = param_env
+ .and(DropckOutlives::new(dropped_ty))
.fully_perform(cx.infcx)
.unwrap();
let param_env = self.param_env;
self.fully_perform_op(
locations,
- type_op::subtype::Subtype::new(param_env, sub, sup),
+ param_env.and(type_op::subtype::Subtype::new(sub, sup)),
)
}
fn eq_types(&mut self, a: Ty<'tcx>, b: Ty<'tcx>, locations: Locations) -> Fallible<()> {
let param_env = self.param_env;
- self.fully_perform_op(locations, type_op::eq::Eq::new(param_env, b, a))
+ self.fully_perform_op(locations, param_env.and(type_op::eq::Eq::new(b, a)))
}
fn tcx(&self) -> TyCtxt<'a, 'gcx, 'tcx> {
let param_env = self.param_env;
self.fully_perform_op(
location.at_self(),
- type_op::prove_predicate::ProvePredicate::new(param_env, predicate),
+ param_env.and(type_op::prove_predicate::ProvePredicate::new(predicate)),
).unwrap_or_else(|NoSolution| {
span_mirbug!(self, NoSolution, "could not prove {:?}", predicate);
})
let param_env = self.param_env;
self.fully_perform_op(
location.to_locations(),
- type_op::normalize::Normalize::new(param_env, value),
+ param_env.and(type_op::normalize::Normalize::new(value)),
).unwrap_or_else(|NoSolution| {
span_mirbug!(self, NoSolution, "failed to normalize `{:?}`", value);
value
use rustc::traits::query::{Fallible, NoSolution};
use rustc::traits::{Obligation, Normalized, ObligationCause};
use rustc::ty::query::Providers;
-use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
+use rustc::ty::{ParamEnvAnd, FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
use rustc_data_structures::sync::Lrc;
use std::fmt;
fn type_op_eq<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, Eq<'tcx>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Eq<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
tcx.infer_ctxt()
- .enter_canonical_trait_query(&canonicalized, |infcx, Eq { param_env, a, b }| {
+ .enter_canonical_trait_query(&canonicalized, |infcx, key| {
+ let (param_env, Eq { a, b }) = key.into_parts();
Ok(infcx.at(&ObligationCause::dummy(), param_env).eq(a, b)?)
})
}
fn type_op_normalize<T>(
infcx: &InferCtxt<'_, 'gcx, 'tcx>,
- key: Normalize<'tcx, T>,
+ key: ParamEnvAnd<'tcx, Normalize<T>>,
) -> Fallible<InferOk<'tcx, T>>
where
T: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx>,
{
- let Normalize { param_env, value } = key;
+ let (param_env, Normalize { value }) = key.into_parts();
let Normalized { value, obligations } = infcx
.at(&ObligationCause::dummy(), param_env)
.normalize(&value)?;
fn type_op_normalize_ty(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, Normalize<'tcx, Ty<'tcx>>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Ty<'tcx>>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Ty<'tcx>>>>, NoSolution> {
tcx.infer_ctxt()
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
fn type_op_normalize_predicate(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, Normalize<'tcx, Predicate<'tcx>>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<Predicate<'tcx>>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Predicate<'tcx>>>>, NoSolution> {
tcx.infer_ctxt()
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
fn type_op_normalize_fn_sig(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, Normalize<'tcx, FnSig<'tcx>>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<FnSig<'tcx>>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, FnSig<'tcx>>>>, NoSolution> {
tcx.infer_ctxt()
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
fn type_op_normalize_poly_fn_sig(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, Normalize<'tcx, PolyFnSig<'tcx>>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Normalize<PolyFnSig<'tcx>>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, PolyFnSig<'tcx>>>>, NoSolution> {
tcx.infer_ctxt()
.enter_canonical_trait_query(&canonicalized, type_op_normalize)
fn type_op_subtype<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, Subtype<'tcx>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, Subtype<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
tcx.infer_ctxt().enter_canonical_trait_query(
- &canonicalized,
- |infcx,
- Subtype {
- param_env,
- sub,
- sup,
- }| {
+ &canonicalized, |infcx, key| {
+ let (param_env, Subtype { sub, sup }) = key.into_parts();
Ok(infcx
.at(&ObligationCause::dummy(), param_env)
.sup(sup, sub)?)
fn type_op_prove_predicate<'tcx>(
tcx: TyCtxt<'_, 'tcx, 'tcx>,
- canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>,
+ canonicalized: Canonical<'tcx, ParamEnvAnd<'tcx, ProvePredicate<'tcx>>>,
) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
tcx.infer_ctxt()
.enter_canonical_trait_query(&canonicalized, |_infcx, key| {
- let ProvePredicate {
- param_env,
- predicate,
- } = key;
+ let (param_env, ProvePredicate { predicate }) = key.into_parts();
Ok(InferOk {
value: (),
obligations: vec![Obligation::new(