More aliases
This commit is contained in:
parent
963568b46f
commit
c9c4053eed
@ -1,9 +1,15 @@
|
|||||||
//! Implementation of the Chalk `Interner` trait, which allows customizing the
|
//! Implementation of the Chalk `Interner` trait, which allows customizing the
|
||||||
//! representation of the various objects Chalk deals with (types, goals etc.).
|
//! representation of the various objects Chalk deals with (types, goals etc.).
|
||||||
|
|
||||||
use crate::{chalk_db, tls, ConstScalar, GenericArg};
|
use crate::{
|
||||||
|
chalk_db, tls, AliasTy, CanonicalVarKind, CanonicalVarKinds, ClosureId, Const, ConstData,
|
||||||
|
ConstScalar, Constraint, Constraints, FnDefId, GenericArg, GenericArgData, Goal, GoalData,
|
||||||
|
Goals, InEnvironment, Lifetime, LifetimeData, OpaqueTy, OpaqueTyId, ProgramClause,
|
||||||
|
ProgramClauseData, ProgramClauses, ProjectionTy, QuantifiedWhereClause, QuantifiedWhereClauses,
|
||||||
|
Substitution, Ty, TyData, TyKind, VariableKind, VariableKinds,
|
||||||
|
};
|
||||||
use base_db::salsa::InternId;
|
use base_db::salsa::InternId;
|
||||||
use chalk_ir::{Goal, GoalData};
|
use chalk_ir::{ProgramClauseImplication, SeparatorTraitRef, Variance};
|
||||||
use hir_def::TypeAliasId;
|
use hir_def::TypeAliasId;
|
||||||
use intern::{impl_internable, Interned};
|
use intern::{impl_internable, Interned};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
@ -30,37 +36,70 @@ fn deref(&self) -> &Self::Target {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Eq)]
|
||||||
|
pub struct PreHashedWrapper<T>(T, u64);
|
||||||
|
|
||||||
|
impl<T: fmt::Debug> fmt::Debug for PreHashedWrapper<T> {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
fmt::Debug::fmt(&self.0, f)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: PartialEq> PartialEq for PreHashedWrapper<T> {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.1 == other.1 && self.0 == other.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T> std::ops::Deref for PreHashedWrapper<T> {
|
||||||
|
type Target = T;
|
||||||
|
|
||||||
|
fn deref(&self) -> &Self::Target {
|
||||||
|
&self.0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl<T: std::hash::Hash> std::hash::Hash for PreHashedWrapper<T> {
|
||||||
|
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||||
|
state.write_u64(self.1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl_internable!(
|
impl_internable!(
|
||||||
InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>,
|
InternedWrapper<Vec<VariableKind>>,
|
||||||
InternedWrapper<SmallVec<[GenericArg; 2]>>,
|
InternedWrapper<SmallVec<[GenericArg; 2]>>,
|
||||||
InternedWrapper<chalk_ir::TyData<Interner>>,
|
InternedWrapper<TyData>,
|
||||||
InternedWrapper<chalk_ir::LifetimeData<Interner>>,
|
InternedWrapper<LifetimeData>,
|
||||||
InternedWrapper<chalk_ir::ConstData<Interner>>,
|
InternedWrapper<ConstData>,
|
||||||
InternedWrapper<ConstScalar>,
|
InternedWrapper<ConstScalar>,
|
||||||
InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
|
InternedWrapper<Vec<CanonicalVarKind>>,
|
||||||
InternedWrapper<Vec<chalk_ir::ProgramClause<Interner>>>,
|
InternedWrapper<Vec<ProgramClause>>,
|
||||||
InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Interner>>>,
|
InternedWrapper<Vec<QuantifiedWhereClause>>,
|
||||||
InternedWrapper<Vec<chalk_ir::Variance>>,
|
InternedWrapper<SmallVec<[Variance; 16]>>,
|
||||||
|
// InternedWrapper<PreHashedWrapper<Goals>>,
|
||||||
);
|
);
|
||||||
|
|
||||||
impl chalk_ir::interner::Interner for Interner {
|
impl chalk_ir::interner::Interner for Interner {
|
||||||
type InternedType = Interned<InternedWrapper<chalk_ir::TyData<Self>>>;
|
type InternedType = Interned<InternedWrapper<TyData>>;
|
||||||
type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
|
type InternedLifetime = Interned<InternedWrapper<LifetimeData>>;
|
||||||
type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
|
type InternedConst = Interned<InternedWrapper<ConstData>>;
|
||||||
type InternedConcreteConst = ConstScalar;
|
type InternedConcreteConst = ConstScalar;
|
||||||
type InternedGenericArg = chalk_ir::GenericArgData<Self>;
|
type InternedGenericArg = GenericArgData;
|
||||||
type InternedGoal = Arc<GoalData<Self>>;
|
// We could do the following, but that saves "only" 20mb on self while increasing inferecene
|
||||||
type InternedGoals = Vec<Goal<Self>>;
|
// time by ~2.5%
|
||||||
|
// type InternedGoal = Interned<InternedWrapper<GoalData>>;
|
||||||
|
// type InternedGoal = Interned<InternedWrapper<PreHashedWrapper<GoalData>>>;
|
||||||
|
type InternedGoal = Arc<GoalData>;
|
||||||
|
type InternedGoals = Vec<Goal>;
|
||||||
type InternedSubstitution = Interned<InternedWrapper<SmallVec<[GenericArg; 2]>>>;
|
type InternedSubstitution = Interned<InternedWrapper<SmallVec<[GenericArg; 2]>>>;
|
||||||
type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
|
type InternedProgramClauses = Interned<InternedWrapper<Vec<ProgramClause>>>;
|
||||||
type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
|
type InternedProgramClause = ProgramClauseData;
|
||||||
type InternedQuantifiedWhereClauses =
|
type InternedQuantifiedWhereClauses = Interned<InternedWrapper<Vec<QuantifiedWhereClause>>>;
|
||||||
Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
|
type InternedVariableKinds = Interned<InternedWrapper<Vec<VariableKind>>>;
|
||||||
type InternedVariableKinds = Interned<InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>>;
|
type InternedCanonicalVarKinds = Interned<InternedWrapper<Vec<CanonicalVarKind>>>;
|
||||||
type InternedCanonicalVarKinds =
|
// type InternedConstraints = SmallVec<[InEnvironment<Constraint>; 1]>;
|
||||||
Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
|
type InternedConstraints = Vec<InEnvironment<Constraint>>;
|
||||||
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
|
type InternedVariances = SmallVec<[Variance; 16]>;
|
||||||
type InternedVariances = Interned<InternedWrapper<Vec<chalk_ir::Variance>>>;
|
|
||||||
type DefId = InternId;
|
type DefId = InternId;
|
||||||
type InternedAdtId = hir_def::AdtId;
|
type InternedAdtId = hir_def::AdtId;
|
||||||
type Identifier = TypeAliasId;
|
type Identifier = TypeAliasId;
|
||||||
@ -88,68 +127,51 @@ fn debug_assoc_type_id(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn debug_opaque_ty_id(
|
fn debug_opaque_ty_id(
|
||||||
opaque_ty_id: chalk_ir::OpaqueTyId<Self>,
|
opaque_ty_id: OpaqueTyId,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "OpaqueTy#{}", opaque_ty_id.0))
|
Some(write!(fmt, "OpaqueTy#{}", opaque_ty_id.0))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_fn_def_id(
|
fn debug_fn_def_id(fn_def_id: FnDefId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
fn_def_id: chalk_ir::FnDefId<Self>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
tls::with_current_program(|prog| Some(prog?.debug_fn_def_id(fn_def_id, fmt)))
|
tls::with_current_program(|prog| Some(prog?.debug_fn_def_id(fn_def_id, fmt)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_closure_id(
|
fn debug_closure_id(
|
||||||
_fn_def_id: chalk_ir::ClosureId<Self>,
|
_fn_def_id: ClosureId,
|
||||||
_fmt: &mut fmt::Formatter<'_>,
|
_fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_alias(
|
fn debug_alias(alias: &AliasTy, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
alias: &chalk_ir::AliasTy<Interner>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
match alias {
|
match alias {
|
||||||
chalk_ir::AliasTy::Projection(projection_ty) => {
|
AliasTy::Projection(projection_ty) => Interner::debug_projection_ty(projection_ty, fmt),
|
||||||
Interner::debug_projection_ty(projection_ty, fmt)
|
AliasTy::Opaque(opaque_ty) => Some(opaque_ty.fmt(fmt)),
|
||||||
}
|
|
||||||
chalk_ir::AliasTy::Opaque(opaque_ty) => Some(opaque_ty.fmt(fmt)),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_projection_ty(
|
fn debug_projection_ty(
|
||||||
proj: &chalk_ir::ProjectionTy<Interner>,
|
proj: &ProjectionTy,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
tls::with_current_program(|prog| Some(prog?.debug_projection_ty(proj, fmt)))
|
tls::with_current_program(|prog| Some(prog?.debug_projection_ty(proj, fmt)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_opaque_ty(
|
fn debug_opaque_ty(opaque_ty: &OpaqueTy, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
opaque_ty: &chalk_ir::OpaqueTy<Interner>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
Some(write!(fmt, "{:?}", opaque_ty.opaque_ty_id))
|
Some(write!(fmt, "{:?}", opaque_ty.opaque_ty_id))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_ty(ty: &chalk_ir::Ty<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
fn debug_ty(ty: &Ty, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", ty.data(Interner)))
|
Some(write!(fmt, "{:?}", ty.data(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_lifetime(
|
fn debug_lifetime(lifetime: &Lifetime, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
lifetime: &chalk_ir::Lifetime<Interner>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
Some(write!(fmt, "{:?}", lifetime.data(Interner)))
|
Some(write!(fmt, "{:?}", lifetime.data(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_const(
|
fn debug_const(constant: &Const, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
constant: &chalk_ir::Const<Self>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
Some(write!(fmt, "{:?}", constant.data(Interner)))
|
Some(write!(fmt, "{:?}", constant.data(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,102 +183,99 @@ fn debug_generic_arg(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn debug_variable_kinds(
|
fn debug_variable_kinds(
|
||||||
variable_kinds: &chalk_ir::VariableKinds<Self>,
|
variable_kinds: &VariableKinds,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", variable_kinds.as_slice(Interner)))
|
Some(write!(fmt, "{:?}", variable_kinds.as_slice(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_variable_kinds_with_angles(
|
fn debug_variable_kinds_with_angles(
|
||||||
variable_kinds: &chalk_ir::VariableKinds<Self>,
|
variable_kinds: &VariableKinds,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", variable_kinds.inner_debug(Interner)))
|
Some(write!(fmt, "{:?}", variable_kinds.inner_debug(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_canonical_var_kinds(
|
fn debug_canonical_var_kinds(
|
||||||
canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Self>,
|
canonical_var_kinds: &CanonicalVarKinds,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", canonical_var_kinds.as_slice(Interner)))
|
Some(write!(fmt, "{:?}", canonical_var_kinds.as_slice(Interner)))
|
||||||
}
|
}
|
||||||
fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
fn debug_goal(goal: &Goal, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
let goal_data = goal.data(Interner);
|
let goal_data = goal.data(Interner);
|
||||||
Some(write!(fmt, "{goal_data:?}"))
|
Some(write!(fmt, "{goal_data:?}"))
|
||||||
}
|
}
|
||||||
fn debug_goals(
|
fn debug_goals(goals: &Goals, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
||||||
goals: &chalk_ir::Goals<Interner>,
|
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
|
||||||
) -> Option<fmt::Result> {
|
|
||||||
Some(write!(fmt, "{:?}", goals.debug(Interner)))
|
Some(write!(fmt, "{:?}", goals.debug(Interner)))
|
||||||
}
|
}
|
||||||
fn debug_program_clause_implication(
|
fn debug_program_clause_implication(
|
||||||
pci: &chalk_ir::ProgramClauseImplication<Interner>,
|
pci: &ProgramClauseImplication<Self>,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", pci.debug(Interner)))
|
Some(write!(fmt, "{:?}", pci.debug(Interner)))
|
||||||
}
|
}
|
||||||
fn debug_program_clause(
|
fn debug_program_clause(
|
||||||
clause: &chalk_ir::ProgramClause<Self>,
|
clause: &ProgramClause,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", clause.data(Interner)))
|
Some(write!(fmt, "{:?}", clause.data(Interner)))
|
||||||
}
|
}
|
||||||
fn debug_program_clauses(
|
fn debug_program_clauses(
|
||||||
clauses: &chalk_ir::ProgramClauses<Self>,
|
clauses: &ProgramClauses,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", clauses.as_slice(Interner)))
|
Some(write!(fmt, "{:?}", clauses.as_slice(Interner)))
|
||||||
}
|
}
|
||||||
fn debug_substitution(
|
fn debug_substitution(
|
||||||
substitution: &chalk_ir::Substitution<Interner>,
|
substitution: &Substitution,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", substitution.debug(Interner)))
|
Some(write!(fmt, "{:?}", substitution.debug(Interner)))
|
||||||
}
|
}
|
||||||
fn debug_separator_trait_ref(
|
fn debug_separator_trait_ref(
|
||||||
separator_trait_ref: &chalk_ir::SeparatorTraitRef<'_, Interner>,
|
separator_trait_ref: &SeparatorTraitRef<'_, Interner>,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", separator_trait_ref.debug(Interner)))
|
Some(write!(fmt, "{:?}", separator_trait_ref.debug(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_quantified_where_clauses(
|
fn debug_quantified_where_clauses(
|
||||||
clauses: &chalk_ir::QuantifiedWhereClauses<Self>,
|
clauses: &QuantifiedWhereClauses,
|
||||||
fmt: &mut fmt::Formatter<'_>,
|
fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
Some(write!(fmt, "{:?}", clauses.as_slice(Interner)))
|
Some(write!(fmt, "{:?}", clauses.as_slice(Interner)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn debug_constraints(
|
fn debug_constraints(
|
||||||
_clauses: &chalk_ir::Constraints<Self>,
|
_clauses: &Constraints,
|
||||||
_fmt: &mut fmt::Formatter<'_>,
|
_fmt: &mut fmt::Formatter<'_>,
|
||||||
) -> Option<fmt::Result> {
|
) -> Option<fmt::Result> {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_ty(self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
|
fn intern_ty(self, kind: TyKind) -> Self::InternedType {
|
||||||
let flags = kind.compute_flags(self);
|
let flags = kind.compute_flags(self);
|
||||||
Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags }))
|
Interned::new(InternedWrapper(TyData { kind, flags }))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ty_data(self, ty: &Self::InternedType) -> &chalk_ir::TyData<Self> {
|
fn ty_data(self, ty: &Self::InternedType) -> &TyData {
|
||||||
&ty.0
|
&ty.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_lifetime(self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
|
fn intern_lifetime(self, lifetime: LifetimeData) -> Self::InternedLifetime {
|
||||||
Interned::new(InternedWrapper(lifetime))
|
Interned::new(InternedWrapper(lifetime))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &chalk_ir::LifetimeData<Self> {
|
fn lifetime_data(self, lifetime: &Self::InternedLifetime) -> &LifetimeData {
|
||||||
&lifetime.0
|
&lifetime.0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_const(self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
|
fn intern_const(self, constant: ConstData) -> Self::InternedConst {
|
||||||
Interned::new(InternedWrapper(constant))
|
Interned::new(InternedWrapper(constant))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn const_data(self, constant: &Self::InternedConst) -> &chalk_ir::ConstData<Self> {
|
fn const_data(self, constant: &Self::InternedConst) -> &ConstData {
|
||||||
&constant.0
|
&constant.0
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -269,36 +288,33 @@ fn const_eq(
|
|||||||
!matches!(c1, ConstScalar::Bytes(..)) || !matches!(c2, ConstScalar::Bytes(..)) || (c1 == c2)
|
!matches!(c1, ConstScalar::Bytes(..)) || !matches!(c2, ConstScalar::Bytes(..)) || (c1 == c2)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_generic_arg(
|
fn intern_generic_arg(self, parameter: GenericArgData) -> Self::InternedGenericArg {
|
||||||
self,
|
|
||||||
parameter: chalk_ir::GenericArgData<Self>,
|
|
||||||
) -> Self::InternedGenericArg {
|
|
||||||
parameter
|
parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
fn generic_arg_data(
|
fn generic_arg_data(self, parameter: &Self::InternedGenericArg) -> &GenericArgData {
|
||||||
self,
|
|
||||||
parameter: &Self::InternedGenericArg,
|
|
||||||
) -> &chalk_ir::GenericArgData<Self> {
|
|
||||||
parameter
|
parameter
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_goal(self, goal: GoalData<Self>) -> Self::InternedGoal {
|
fn intern_goal(self, goal: GoalData) -> Self::InternedGoal {
|
||||||
Arc::new(goal)
|
Arc::new(goal)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn goal_data(self, goal: &Self::InternedGoal) -> &GoalData<Self> {
|
fn goal_data(self, goal: &Self::InternedGoal) -> &GoalData {
|
||||||
goal
|
goal
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_goals<E>(
|
fn intern_goals<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<Goal<Self>, E>>,
|
data: impl IntoIterator<Item = Result<Goal, E>>,
|
||||||
) -> Result<Self::InternedGoals, E> {
|
) -> Result<Self::InternedGoals, E> {
|
||||||
|
// let hash =
|
||||||
|
// std::hash::BuildHasher::hash_one(&BuildHasherDefault::<FxHasher>::default(), &goal);
|
||||||
|
// Interned::new(InternedWrapper(PreHashedWrapper(goal, hash)))
|
||||||
data.into_iter().collect()
|
data.into_iter().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn goals_data(self, goals: &Self::InternedGoals) -> &[Goal<Interner>] {
|
fn goals_data(self, goals: &Self::InternedGoals) -> &[Goal] {
|
||||||
goals
|
goals
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -313,37 +329,28 @@ fn substitution_data(self, substitution: &Self::InternedSubstitution) -> &[Gener
|
|||||||
&substitution.as_ref().0
|
&substitution.as_ref().0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_program_clause(
|
fn intern_program_clause(self, data: ProgramClauseData) -> Self::InternedProgramClause {
|
||||||
self,
|
|
||||||
data: chalk_ir::ProgramClauseData<Self>,
|
|
||||||
) -> Self::InternedProgramClause {
|
|
||||||
data
|
data
|
||||||
}
|
}
|
||||||
|
|
||||||
fn program_clause_data(
|
fn program_clause_data(self, clause: &Self::InternedProgramClause) -> &ProgramClauseData {
|
||||||
self,
|
|
||||||
clause: &Self::InternedProgramClause,
|
|
||||||
) -> &chalk_ir::ProgramClauseData<Self> {
|
|
||||||
clause
|
clause
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_program_clauses<E>(
|
fn intern_program_clauses<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>,
|
data: impl IntoIterator<Item = Result<ProgramClause, E>>,
|
||||||
) -> Result<Self::InternedProgramClauses, E> {
|
) -> Result<Self::InternedProgramClauses, E> {
|
||||||
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn program_clauses_data(
|
fn program_clauses_data(self, clauses: &Self::InternedProgramClauses) -> &[ProgramClause] {
|
||||||
self,
|
|
||||||
clauses: &Self::InternedProgramClauses,
|
|
||||||
) -> &[chalk_ir::ProgramClause<Self>] {
|
|
||||||
clauses
|
clauses
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_quantified_where_clauses<E>(
|
fn intern_quantified_where_clauses<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>,
|
data: impl IntoIterator<Item = Result<QuantifiedWhereClause, E>>,
|
||||||
) -> Result<Self::InternedQuantifiedWhereClauses, E> {
|
) -> Result<Self::InternedQuantifiedWhereClauses, E> {
|
||||||
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
||||||
}
|
}
|
||||||
@ -351,27 +358,24 @@ fn intern_quantified_where_clauses<E>(
|
|||||||
fn quantified_where_clauses_data(
|
fn quantified_where_clauses_data(
|
||||||
self,
|
self,
|
||||||
clauses: &Self::InternedQuantifiedWhereClauses,
|
clauses: &Self::InternedQuantifiedWhereClauses,
|
||||||
) -> &[chalk_ir::QuantifiedWhereClause<Self>] {
|
) -> &[QuantifiedWhereClause] {
|
||||||
clauses
|
clauses
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_generic_arg_kinds<E>(
|
fn intern_generic_arg_kinds<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
|
data: impl IntoIterator<Item = Result<VariableKind, E>>,
|
||||||
) -> Result<Self::InternedVariableKinds, E> {
|
) -> Result<Self::InternedVariableKinds, E> {
|
||||||
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn variable_kinds_data(
|
fn variable_kinds_data(self, parameter_kinds: &Self::InternedVariableKinds) -> &[VariableKind] {
|
||||||
self,
|
|
||||||
parameter_kinds: &Self::InternedVariableKinds,
|
|
||||||
) -> &[chalk_ir::VariableKind<Self>] {
|
|
||||||
¶meter_kinds.as_ref().0
|
¶meter_kinds.as_ref().0
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_canonical_var_kinds<E>(
|
fn intern_canonical_var_kinds<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
|
data: impl IntoIterator<Item = Result<CanonicalVarKind, E>>,
|
||||||
) -> Result<Self::InternedCanonicalVarKinds, E> {
|
) -> Result<Self::InternedCanonicalVarKinds, E> {
|
||||||
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
||||||
}
|
}
|
||||||
@ -379,30 +383,30 @@ fn intern_canonical_var_kinds<E>(
|
|||||||
fn canonical_var_kinds_data(
|
fn canonical_var_kinds_data(
|
||||||
self,
|
self,
|
||||||
canonical_var_kinds: &Self::InternedCanonicalVarKinds,
|
canonical_var_kinds: &Self::InternedCanonicalVarKinds,
|
||||||
) -> &[chalk_ir::CanonicalVarKind<Self>] {
|
) -> &[CanonicalVarKind] {
|
||||||
canonical_var_kinds
|
canonical_var_kinds
|
||||||
}
|
}
|
||||||
fn intern_constraints<E>(
|
fn intern_constraints<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>, E>>,
|
data: impl IntoIterator<Item = Result<InEnvironment<Constraint>, E>>,
|
||||||
) -> Result<Self::InternedConstraints, E> {
|
) -> Result<Self::InternedConstraints, E> {
|
||||||
data.into_iter().collect()
|
data.into_iter().collect()
|
||||||
}
|
}
|
||||||
fn constraints_data(
|
fn constraints_data(
|
||||||
self,
|
self,
|
||||||
constraints: &Self::InternedConstraints,
|
constraints: &Self::InternedConstraints,
|
||||||
) -> &[chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
|
) -> &[InEnvironment<Constraint>] {
|
||||||
constraints
|
constraints
|
||||||
}
|
}
|
||||||
|
|
||||||
fn intern_variances<E>(
|
fn intern_variances<E>(
|
||||||
self,
|
self,
|
||||||
data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>,
|
data: impl IntoIterator<Item = Result<Variance, E>>,
|
||||||
) -> Result<Self::InternedVariances, E> {
|
) -> Result<Self::InternedVariances, E> {
|
||||||
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
data.into_iter().collect::<Result<_, _>>()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn variances_data(self, variances: &Self::InternedVariances) -> &[chalk_ir::Variance] {
|
fn variances_data(self, variances: &Self::InternedVariances) -> &[Variance] {
|
||||||
variances
|
variances
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,7 +45,7 @@ macro_rules! eprintln {
|
|||||||
fold::{Shift, TypeFoldable},
|
fold::{Shift, TypeFoldable},
|
||||||
interner::HasInterner,
|
interner::HasInterner,
|
||||||
visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor},
|
visit::{TypeSuperVisitable, TypeVisitable, TypeVisitor},
|
||||||
NoSolution, TyData,
|
NoSolution,
|
||||||
};
|
};
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir_def::{hir::ExprId, type_ref::Rawness, GeneralConstId, TypeOrConstParamId};
|
use hir_def::{hir::ExprId, type_ref::Rawness, GeneralConstId, TypeOrConstParamId};
|
||||||
@ -152,10 +152,21 @@ macro_rules! eprintln {
|
|||||||
pub type Goal = chalk_ir::Goal<Interner>;
|
pub type Goal = chalk_ir::Goal<Interner>;
|
||||||
pub type AliasEq = chalk_ir::AliasEq<Interner>;
|
pub type AliasEq = chalk_ir::AliasEq<Interner>;
|
||||||
pub type Solution = chalk_solve::Solution<Interner>;
|
pub type Solution = chalk_solve::Solution<Interner>;
|
||||||
|
pub type Constraint = chalk_ir::Constraint<Interner>;
|
||||||
|
pub type Constraints = chalk_ir::Constraints<Interner>;
|
||||||
pub type ConstrainedSubst = chalk_ir::ConstrainedSubst<Interner>;
|
pub type ConstrainedSubst = chalk_ir::ConstrainedSubst<Interner>;
|
||||||
pub type Guidance = chalk_solve::Guidance<Interner>;
|
pub type Guidance = chalk_solve::Guidance<Interner>;
|
||||||
pub type WhereClause = chalk_ir::WhereClause<Interner>;
|
pub type WhereClause = chalk_ir::WhereClause<Interner>;
|
||||||
|
|
||||||
|
pub type CanonicalVarKind = chalk_ir::CanonicalVarKind<Interner>;
|
||||||
|
pub type GoalData = chalk_ir::GoalData<Interner>;
|
||||||
|
pub type Goals = chalk_ir::Goals<Interner>;
|
||||||
|
pub type ProgramClauseData = chalk_ir::ProgramClauseData<Interner>;
|
||||||
|
pub type ProgramClause = chalk_ir::ProgramClause<Interner>;
|
||||||
|
pub type ProgramClauses = chalk_ir::ProgramClauses<Interner>;
|
||||||
|
pub type TyData = chalk_ir::TyData<Interner>;
|
||||||
|
pub type Variances = chalk_ir::Variances<Interner>;
|
||||||
|
|
||||||
/// A constant can have reference to other things. Memory map job is holding
|
/// A constant can have reference to other things. Memory map job is holding
|
||||||
/// the necessary bits of memory of the const eval session to keep the constant
|
/// the necessary bits of memory of the const eval session to keep the constant
|
||||||
/// meaningful.
|
/// meaningful.
|
||||||
|
Loading…
Reference in New Issue
Block a user