remove Canonicalization trait, which serves no purpose
This commit is contained in:
parent
d748dc5db0
commit
1d664622b6
9 changed files with 32 additions and 151 deletions
|
|
@ -17,13 +17,13 @@
|
|||
|
||||
use infer::canonical::{
|
||||
Canonical, CanonicalTyVarKind, CanonicalVarInfo, CanonicalVarKind, CanonicalVarValues,
|
||||
Canonicalize,
|
||||
Canonicalized,
|
||||
};
|
||||
use infer::InferCtxt;
|
||||
use std::sync::atomic::Ordering;
|
||||
use ty::fold::{TypeFoldable, TypeFolder};
|
||||
use ty::subst::Kind;
|
||||
use ty::{self, CanonicalVar, Slice, Ty, TyCtxt, TypeFlags};
|
||||
use ty::{self, CanonicalVar, Lift, Slice, Ty, TyCtxt, TypeFlags};
|
||||
|
||||
use rustc_data_structures::fx::FxHashMap;
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
|
|
@ -44,9 +44,12 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
/// out the [chapter in the rustc guide][c].
|
||||
///
|
||||
/// [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html#canonicalizing-the-query
|
||||
pub fn canonicalize_query<V>(&self, value: &V) -> (V::Canonicalized, CanonicalVarValues<'tcx>)
|
||||
pub fn canonicalize_query<V>(
|
||||
&self,
|
||||
value: &V,
|
||||
) -> (Canonicalized<'gcx, V>, CanonicalVarValues<'tcx>)
|
||||
where
|
||||
V: Canonicalize<'gcx, 'tcx>,
|
||||
V: TypeFoldable<'tcx> + Lift<'gcx>,
|
||||
{
|
||||
self.tcx
|
||||
.sess
|
||||
|
|
@ -90,9 +93,9 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
pub fn canonicalize_response<V>(
|
||||
&self,
|
||||
value: &V,
|
||||
) -> (V::Canonicalized, CanonicalVarValues<'tcx>)
|
||||
) -> (Canonicalized<'gcx, V>, CanonicalVarValues<'tcx>)
|
||||
where
|
||||
V: Canonicalize<'gcx, 'tcx>,
|
||||
V: TypeFoldable<'tcx> + Lift<'gcx>,
|
||||
{
|
||||
Canonicalizer::canonicalize(
|
||||
value,
|
||||
|
|
@ -233,9 +236,9 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
|||
infcx: Option<&'cx InferCtxt<'cx, 'gcx, 'tcx>>,
|
||||
tcx: TyCtxt<'cx, 'gcx, 'tcx>,
|
||||
canonicalize_all_free_regions: CanonicalizeAllFreeRegions,
|
||||
) -> (V::Canonicalized, CanonicalVarValues<'tcx>)
|
||||
) -> (Canonicalized<'gcx, V>, CanonicalVarValues<'tcx>)
|
||||
where
|
||||
V: Canonicalize<'gcx, 'tcx>,
|
||||
V: TypeFoldable<'tcx> + Lift<'gcx>,
|
||||
{
|
||||
debug_assert!(
|
||||
!value.has_type_flags(TypeFlags::HAS_CANONICAL_VARS),
|
||||
|
|
@ -254,13 +257,10 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
|||
// Fast path: nothing that needs to be canonicalized.
|
||||
if !value.has_type_flags(needs_canonical_flags) {
|
||||
let out_value = gcx.lift(value).unwrap();
|
||||
let canon_value = V::intern(
|
||||
gcx,
|
||||
Canonical {
|
||||
variables: Slice::empty(),
|
||||
value: out_value,
|
||||
},
|
||||
);
|
||||
let canon_value = Canonical {
|
||||
variables: Slice::empty(),
|
||||
value: out_value,
|
||||
};
|
||||
let values = CanonicalVarValues {
|
||||
var_values: IndexVec::default(),
|
||||
};
|
||||
|
|
@ -291,13 +291,10 @@ impl<'cx, 'gcx, 'tcx> Canonicalizer<'cx, 'gcx, 'tcx> {
|
|||
|
||||
let canonical_variables = tcx.intern_canonical_var_infos(&canonicalizer.variables.raw);
|
||||
|
||||
let canonical_value = V::intern(
|
||||
gcx,
|
||||
Canonical {
|
||||
variables: canonical_variables,
|
||||
value: out_value,
|
||||
},
|
||||
);
|
||||
let canonical_value = Canonical {
|
||||
variables: canonical_variables,
|
||||
value: out_value,
|
||||
};
|
||||
let canonical_var_values = CanonicalVarValues {
|
||||
var_values: canonicalizer.var_values,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -35,7 +35,6 @@ use infer::{InferCtxt, RegionVariableOrigin, TypeVariableOrigin};
|
|||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use serialize::UseSpecializedDecodable;
|
||||
use std::fmt::Debug;
|
||||
use std::ops::Index;
|
||||
use syntax::codemap::Span;
|
||||
use ty::fold::TypeFoldable;
|
||||
|
|
@ -124,6 +123,8 @@ pub struct QueryResult<'tcx, R> {
|
|||
pub value: R,
|
||||
}
|
||||
|
||||
pub type Canonicalized<'gcx, V> = Canonical<'gcx, <V as Lift<'gcx>>::Lifted>;
|
||||
|
||||
pub type CanonicalizedQueryResult<'gcx, T> =
|
||||
Lrc<Canonical<'gcx, QueryResult<'gcx, <T as Lift<'gcx>>::Lifted>>>;
|
||||
|
||||
|
|
@ -184,19 +185,6 @@ impl<'tcx, R> Canonical<'tcx, QueryResult<'tcx, R>> {
|
|||
|
||||
pub type QueryRegionConstraint<'tcx> = ty::Binder<ty::OutlivesPredicate<Kind<'tcx>, Region<'tcx>>>;
|
||||
|
||||
/// Trait implemented by values that can be canonicalized. It mainly
|
||||
/// serves to identify the interning table we will use.
|
||||
pub trait Canonicalize<'gcx: 'tcx, 'tcx>: TypeFoldable<'tcx> + Lift<'gcx> {
|
||||
type Canonicalized: 'gcx + Debug;
|
||||
|
||||
/// After a value has been fully canonicalized and lifted, this
|
||||
/// method will allocate it in a global arena.
|
||||
fn intern(
|
||||
gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized;
|
||||
}
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
/// Creates a substitution S for the canonical value with fresh
|
||||
/// inference variables and applies it to the canonical value.
|
||||
|
|
@ -344,18 +332,3 @@ impl<'tcx> Index<CanonicalVar> for CanonicalVarValues<'tcx> {
|
|||
&self.var_values[value]
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gcx: 'tcx, 'tcx, T> Canonicalize<'gcx, 'tcx> for QueryResult<'tcx, T>
|
||||
where
|
||||
T: TypeFoldable<'tcx> + Lift<'gcx>,
|
||||
{
|
||||
// we ought to intern this, but I'm too lazy just now
|
||||
type Canonicalized = Lrc<Canonical<'gcx, QueryResult<'gcx, T::Lifted>>>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized {
|
||||
Lrc::new(value)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,13 +19,14 @@
|
|||
|
||||
use infer::canonical::substitute::substitute_value;
|
||||
use infer::canonical::{
|
||||
Canonical, CanonicalVarValues, Canonicalize, CanonicalizedQueryResult, Certainty,
|
||||
Canonical, CanonicalVarValues, CanonicalizedQueryResult, Certainty,
|
||||
QueryRegionConstraint, QueryResult,
|
||||
};
|
||||
use infer::region_constraints::{Constraint, RegionConstraintData};
|
||||
use infer::{InferCtxt, InferOk, InferResult, RegionObligation};
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
use rustc_data_structures::indexed_vec::IndexVec;
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
use std::fmt::Debug;
|
||||
use syntax::ast;
|
||||
use traits::query::NoSolution;
|
||||
|
|
@ -72,7 +73,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
canonical_result
|
||||
);
|
||||
|
||||
Ok(canonical_result)
|
||||
Ok(Lrc::new(canonical_result))
|
||||
}
|
||||
|
||||
/// Helper for `make_canonicalized_query_result` that does
|
||||
|
|
@ -84,8 +85,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
fulfill_cx: &mut FulfillmentContext<'tcx>,
|
||||
) -> Result<QueryResult<'tcx, T>, NoSolution>
|
||||
where
|
||||
T: Debug,
|
||||
QueryResult<'tcx, T>: Canonicalize<'gcx, 'tcx>,
|
||||
T: Debug + TypeFoldable<'tcx> + Lift<'gcx>,
|
||||
{
|
||||
let tcx = self.tcx;
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ use ty::subst::Substs;
|
|||
use ty::{self, AdtKind, Slice, Ty, TyCtxt, GenericParamDefKind, ToPredicate};
|
||||
use ty::error::{ExpectedFound, TypeError};
|
||||
use ty::fold::{TypeFolder, TypeFoldable, TypeVisitor};
|
||||
use infer::canonical::{Canonical, Canonicalize};
|
||||
use infer::{InferCtxt};
|
||||
|
||||
use rustc_data_structures::sync::Lrc;
|
||||
|
|
@ -1015,18 +1014,6 @@ pub fn provide(providers: &mut ty::query::Providers) {
|
|||
};
|
||||
}
|
||||
|
||||
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, Goal<'tcx>> {
|
||||
// we ought to intern this, but I'm too lazy just now
|
||||
type Canonicalized = Canonical<'gcx, ty::ParamEnvAnd<'gcx, Goal<'gcx>>>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
pub trait ExClauseFold<'tcx>
|
||||
where
|
||||
Self: chalk_engine::context::Context + Clone,
|
||||
|
|
@ -1053,20 +1040,3 @@ where
|
|||
tcx: TyCtxt<'a, 'gcx, 'tcx>,
|
||||
) -> Option<Self::LiftedExClause>;
|
||||
}
|
||||
|
||||
impl<'gcx: 'tcx, 'tcx, C> Canonicalize<'gcx, 'tcx> for chalk_engine::ExClause<C>
|
||||
where
|
||||
C: chalk_engine::context::Context + Clone,
|
||||
C: ExClauseLift<'gcx> + ExClauseFold<'tcx>,
|
||||
C::Substitution: Clone,
|
||||
C::RegionConstraint: Clone,
|
||||
{
|
||||
type Canonicalized = Canonical<'gcx, C::LiftedExClause>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@
|
|||
// except according to those terms.
|
||||
|
||||
use infer::at::At;
|
||||
use infer::canonical::{Canonical, Canonicalize};
|
||||
use infer::InferOk;
|
||||
use std::iter::FromIterator;
|
||||
use traits::query::CanonicalTyGoal;
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
use ty::subst::Kind;
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
|
||||
/// Given a type `ty` of some value being dropped, computes a set
|
||||
|
|
@ -44,7 +42,10 @@ impl<'cx, 'gcx, 'tcx> At<'cx, 'gcx, 'tcx> {
|
|||
// any destructor.
|
||||
let tcx = self.infcx.tcx;
|
||||
if trivial_dropck_outlives(tcx, ty) {
|
||||
return InferOk { value: vec![], obligations: vec![] };
|
||||
return InferOk {
|
||||
value: vec![],
|
||||
obligations: vec![],
|
||||
};
|
||||
}
|
||||
|
||||
let gcx = tcx.global_tcx();
|
||||
|
|
@ -152,17 +153,6 @@ impl<'tcx> FromIterator<DtorckConstraint<'tcx>> for DtorckConstraint<'tcx> {
|
|||
result
|
||||
}
|
||||
}
|
||||
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, Ty<'tcx>> {
|
||||
type Canonicalized = CanonicalTyGoal<'gcx>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
BraceStructTypeFoldableImpl! {
|
||||
impl<'tcx> TypeFoldable<'tcx> for DropckOutlivesResult<'tcx> {
|
||||
kinds, overflows
|
||||
|
|
|
|||
|
|
@ -9,11 +9,8 @@
|
|||
// except according to those terms.
|
||||
|
||||
use infer::InferCtxt;
|
||||
use infer::canonical::{Canonical, Canonicalize};
|
||||
use traits::{EvaluationResult, PredicateObligation, SelectionContext,
|
||||
TraitQueryMode, OverflowError};
|
||||
use traits::query::CanonicalPredicateGoal;
|
||||
use ty::{ParamEnvAnd, Predicate, TyCtxt};
|
||||
|
||||
impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
||||
/// Evaluates whether the predicate can be satisfied (by any means)
|
||||
|
|
@ -57,14 +54,3 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ParamEnvAnd<'tcx, Predicate<'tcx>> {
|
||||
type Canonicalized = CanonicalPredicateGoal<'gcx>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,11 +14,9 @@
|
|||
|
||||
use infer::{InferCtxt, InferOk};
|
||||
use infer::at::At;
|
||||
use infer::canonical::{Canonical, Canonicalize};
|
||||
use middle::const_val::ConstVal;
|
||||
use mir::interpret::GlobalId;
|
||||
use traits::{Obligation, ObligationCause, PredicateObligation, Reveal};
|
||||
use traits::query::CanonicalProjectionGoal;
|
||||
use traits::project::Normalized;
|
||||
use ty::{self, Ty, TyCtxt};
|
||||
use ty::fold::{TypeFoldable, TypeFolder};
|
||||
|
|
@ -250,17 +248,6 @@ BraceStructLiftImpl! {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ty::ParamEnvAnd<'tcx, ty::ProjectionTy<'tcx>> {
|
||||
type Canonicalized = CanonicalProjectionGoal<'gcx>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>,
|
||||
) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
impl_stable_hash_for!(struct NormalizationResult<'tcx> {
|
||||
normalized_ty
|
||||
});
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ use hir::map::DefPathData;
|
|||
use hir::svh::Svh;
|
||||
use ich::Fingerprint;
|
||||
use ich::StableHashingContext;
|
||||
use infer::canonical::{Canonical, Canonicalize};
|
||||
use infer::canonical::Canonical;
|
||||
use middle::lang_items::{FnTraitLangItem, FnMutTraitLangItem, FnOnceTraitLangItem};
|
||||
use middle::privacy::AccessLevels;
|
||||
use middle::resolve_lifetime::ObjectLifetimeDefault;
|
||||
|
|
@ -591,15 +591,6 @@ impl<'tcx> serialize::UseSpecializedDecodable for Ty<'tcx> {}
|
|||
|
||||
pub type CanonicalTy<'gcx> = Canonical<'gcx, Ty<'gcx>>;
|
||||
|
||||
impl <'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for Ty<'tcx> {
|
||||
type Canonicalized = CanonicalTy<'gcx>;
|
||||
|
||||
fn intern(_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, Self::Lifted>) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
||||
extern {
|
||||
/// A dummy type used to force Slice to by unsized without requiring fat pointers
|
||||
type OpaqueSliceContents;
|
||||
|
|
|
|||
|
|
@ -10,9 +10,7 @@
|
|||
|
||||
use chalk_engine::fallible::Fallible as ChalkEngineFallible;
|
||||
use chalk_engine::{context, hh::HhGoal, DelayedLiteral, ExClause};
|
||||
use rustc::infer::canonical::{
|
||||
Canonical, CanonicalVarValues, Canonicalize, QueryRegionConstraint, QueryResult,
|
||||
};
|
||||
use rustc::infer::canonical::{Canonical, CanonicalVarValues, QueryRegionConstraint, QueryResult};
|
||||
use rustc::infer::{InferCtxt, InferOk, LateBoundRegionConversionTime};
|
||||
use rustc::traits::{
|
||||
WellFormed,
|
||||
|
|
@ -519,14 +517,3 @@ BraceStructLiftImpl! {
|
|||
subst, constraints
|
||||
}
|
||||
}
|
||||
|
||||
impl<'gcx: 'tcx, 'tcx> Canonicalize<'gcx, 'tcx> for ConstrainedSubst<'tcx> {
|
||||
type Canonicalized = Canonical<'gcx, ConstrainedSubst<'gcx>>;
|
||||
|
||||
fn intern(
|
||||
_gcx: TyCtxt<'_, 'gcx, 'gcx>,
|
||||
value: Canonical<'gcx, ConstrainedSubst<'gcx>>,
|
||||
) -> Self::Canonicalized {
|
||||
value
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue