2020-05-22 10:14:53 -05:00
|
|
|
//! Implementation of the Chalk `Interner` trait, which allows customizing the
|
|
|
|
//! representation of the various objects Chalk deals with (types, goals etc.).
|
|
|
|
|
|
|
|
use super::tls;
|
2020-08-13 09:25:38 -05:00
|
|
|
use base_db::salsa::InternId;
|
2021-04-08 11:25:18 -05:00
|
|
|
use chalk_ir::{Goal, GoalData};
|
2021-04-08 11:13:02 -05:00
|
|
|
use hir_def::{
|
|
|
|
intern::{impl_internable, InternStorage, Internable, Interned},
|
|
|
|
TypeAliasId,
|
|
|
|
};
|
2021-04-08 11:25:18 -05:00
|
|
|
use crate::GenericArg;
|
2021-03-15 13:13:49 -05:00
|
|
|
use smallvec::SmallVec;
|
2020-05-22 10:14:53 -05:00
|
|
|
use std::{fmt, sync::Arc};
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, Hash, PartialOrd, Ord, PartialEq, Eq)]
|
|
|
|
pub struct Interner;
|
|
|
|
|
2020-11-02 09:31:38 -06:00
|
|
|
pub(crate) type AssocTypeId = chalk_ir::AssocTypeId<Interner>;
|
|
|
|
pub(crate) type AssociatedTyDatum = chalk_solve::rust_ir::AssociatedTyDatum<Interner>;
|
|
|
|
pub(crate) type TraitId = chalk_ir::TraitId<Interner>;
|
|
|
|
pub(crate) type TraitDatum = chalk_solve::rust_ir::TraitDatum<Interner>;
|
|
|
|
pub(crate) type AdtId = chalk_ir::AdtId<Interner>;
|
|
|
|
pub(crate) type StructDatum = chalk_solve::rust_ir::AdtDatum<Interner>;
|
|
|
|
pub(crate) type ImplId = chalk_ir::ImplId<Interner>;
|
|
|
|
pub(crate) type ImplDatum = chalk_solve::rust_ir::ImplDatum<Interner>;
|
|
|
|
pub(crate) type AssociatedTyValueId = chalk_solve::rust_ir::AssociatedTyValueId<Interner>;
|
|
|
|
pub(crate) type AssociatedTyValue = chalk_solve::rust_ir::AssociatedTyValue<Interner>;
|
|
|
|
pub(crate) type FnDefDatum = chalk_solve::rust_ir::FnDefDatum<Interner>;
|
|
|
|
pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
|
|
|
|
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
|
2020-11-20 11:00:34 -06:00
|
|
|
pub(crate) type Variances = chalk_ir::Variances<Interner>;
|
2020-05-22 10:14:53 -05:00
|
|
|
|
2021-04-08 11:13:02 -05:00
|
|
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub struct InternedVariableKindsInner(Vec<chalk_ir::VariableKind<Interner>>);
|
|
|
|
|
2021-04-08 11:25:18 -05:00
|
|
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub struct InternedSubstitutionInner(SmallVec<[GenericArg; 2]>);
|
|
|
|
|
2021-04-08 11:32:20 -05:00
|
|
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub struct InternedTypeInner(chalk_ir::TyData<Interner>);
|
|
|
|
|
2021-04-08 11:45:07 -05:00
|
|
|
#[derive(PartialEq, Eq, Hash, Debug)]
|
|
|
|
pub struct InternedWrapper<T>(T);
|
|
|
|
|
|
|
|
impl<T> std::ops::Deref for InternedWrapper<T> {
|
|
|
|
type Target = T;
|
|
|
|
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
|
|
&self.0
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-08 11:25:18 -05:00
|
|
|
impl_internable!(
|
|
|
|
InternedVariableKindsInner,
|
|
|
|
InternedSubstitutionInner,
|
2021-04-08 11:32:20 -05:00
|
|
|
InternedTypeInner,
|
2021-04-08 11:45:07 -05:00
|
|
|
InternedWrapper<chalk_ir::LifetimeData<Interner>>,
|
|
|
|
InternedWrapper<chalk_ir::ConstData<Interner>>,
|
2021-04-08 13:06:19 -05:00
|
|
|
InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
|
2021-04-08 13:13:21 -05:00
|
|
|
InternedWrapper<Vec<chalk_ir::ProgramClause<Interner>>>,
|
2021-04-08 13:18:51 -05:00
|
|
|
InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Interner>>>,
|
2021-04-08 11:25:18 -05:00
|
|
|
);
|
2021-04-08 11:13:02 -05:00
|
|
|
|
2020-05-22 10:14:53 -05:00
|
|
|
impl chalk_ir::interner::Interner for Interner {
|
2021-04-08 11:32:20 -05:00
|
|
|
type InternedType = Interned<InternedTypeInner>;
|
2021-04-08 11:45:07 -05:00
|
|
|
type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
|
|
|
|
type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
|
2020-05-22 10:14:53 -05:00
|
|
|
type InternedConcreteConst = ();
|
|
|
|
type InternedGenericArg = chalk_ir::GenericArgData<Self>;
|
|
|
|
type InternedGoal = Arc<GoalData<Self>>;
|
|
|
|
type InternedGoals = Vec<Goal<Self>>;
|
2021-04-08 11:25:18 -05:00
|
|
|
type InternedSubstitution = Interned<InternedSubstitutionInner>;
|
2021-04-08 13:39:43 -05:00
|
|
|
type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
|
2021-04-08 13:13:21 -05:00
|
|
|
type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
|
2021-04-08 13:18:51 -05:00
|
|
|
type InternedQuantifiedWhereClauses = Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
|
2021-04-08 11:13:02 -05:00
|
|
|
type InternedVariableKinds = Interned<InternedVariableKindsInner>;
|
2021-04-08 13:06:19 -05:00
|
|
|
type InternedCanonicalVarKinds = Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
|
2020-07-11 08:22:46 -05:00
|
|
|
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
|
2020-11-20 11:00:34 -06:00
|
|
|
type InternedVariances = Arc<[chalk_ir::Variance]>;
|
2020-05-22 10:14:53 -05:00
|
|
|
type DefId = InternId;
|
2020-07-15 14:47:45 -05:00
|
|
|
type InternedAdtId = hir_def::AdtId;
|
2020-05-22 10:14:53 -05:00
|
|
|
type Identifier = TypeAliasId;
|
2020-06-22 06:18:10 -05:00
|
|
|
type FnAbi = ();
|
2020-05-22 10:14:53 -05:00
|
|
|
|
2020-05-22 10:50:58 -05:00
|
|
|
fn debug_adt_id(type_kind_id: AdtId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
2020-05-22 10:14:53 -05:00
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_struct_id(type_kind_id, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_trait_id(type_kind_id: TraitId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_trait_id(type_kind_id, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_assoc_type_id(id: AssocTypeId, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_assoc_type_id(id, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_alias(
|
|
|
|
alias: &chalk_ir::AliasTy<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_alias(alias, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_projection_ty(
|
|
|
|
proj: &chalk_ir::ProjectionTy<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_projection_ty(proj, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_opaque_ty(
|
|
|
|
opaque_ty: &chalk_ir::OpaqueTy<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_opaque_ty(opaque_ty, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_opaque_ty_id(
|
|
|
|
opaque_ty_id: chalk_ir::OpaqueTyId<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_opaque_ty_id(opaque_ty_id, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_ty(ty: &chalk_ir::Ty<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_ty(ty, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_lifetime(
|
|
|
|
lifetime: &chalk_ir::Lifetime<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_lifetime(lifetime, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_generic_arg(
|
2021-04-08 11:25:18 -05:00
|
|
|
parameter: &GenericArg,
|
2020-05-22 10:14:53 -05:00
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_generic_arg(parameter, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_goal(goal: &Goal<Interner>, fmt: &mut fmt::Formatter<'_>) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_goal(goal, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_goals(
|
|
|
|
goals: &chalk_ir::Goals<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_goals(goals, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_program_clause_implication(
|
|
|
|
pci: &chalk_ir::ProgramClauseImplication<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_program_clause_implication(pci, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_substitution(
|
|
|
|
substitution: &chalk_ir::Substitution<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_substitution(substitution, fmt)))
|
|
|
|
}
|
|
|
|
|
|
|
|
fn debug_separator_trait_ref(
|
|
|
|
separator_trait_ref: &chalk_ir::SeparatorTraitRef<Interner>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| {
|
|
|
|
Some(prog?.debug_separator_trait_ref(separator_trait_ref, fmt))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2020-05-22 11:05:48 -05:00
|
|
|
fn debug_fn_def_id(
|
|
|
|
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)))
|
|
|
|
}
|
|
|
|
fn debug_const(
|
|
|
|
constant: &chalk_ir::Const<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_const(constant, fmt)))
|
|
|
|
}
|
|
|
|
fn debug_variable_kinds(
|
|
|
|
variable_kinds: &chalk_ir::VariableKinds<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_variable_kinds(variable_kinds, fmt)))
|
|
|
|
}
|
|
|
|
fn debug_variable_kinds_with_angles(
|
|
|
|
variable_kinds: &chalk_ir::VariableKinds<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| {
|
|
|
|
Some(prog?.debug_variable_kinds_with_angles(variable_kinds, fmt))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
fn debug_canonical_var_kinds(
|
|
|
|
canonical_var_kinds: &chalk_ir::CanonicalVarKinds<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| {
|
|
|
|
Some(prog?.debug_canonical_var_kinds(canonical_var_kinds, fmt))
|
|
|
|
})
|
|
|
|
}
|
|
|
|
fn debug_program_clause(
|
|
|
|
clause: &chalk_ir::ProgramClause<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_program_clause(clause, fmt)))
|
|
|
|
}
|
|
|
|
fn debug_program_clauses(
|
|
|
|
clauses: &chalk_ir::ProgramClauses<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_program_clauses(clauses, fmt)))
|
|
|
|
}
|
|
|
|
fn debug_quantified_where_clauses(
|
|
|
|
clauses: &chalk_ir::QuantifiedWhereClauses<Self>,
|
|
|
|
fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt)))
|
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
|
2021-02-08 10:38:51 -06:00
|
|
|
let flags = kind.compute_flags(self);
|
2021-04-08 11:32:20 -05:00
|
|
|
Interned::new(InternedTypeInner(chalk_ir::TyData { kind, flags }))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
|
2021-04-08 11:32:20 -05:00
|
|
|
&ty.0
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
|
2021-04-08 11:45:07 -05:00
|
|
|
Interned::new(InternedWrapper(lifetime))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn lifetime_data<'a>(
|
|
|
|
&self,
|
2021-04-05 13:15:07 -05:00
|
|
|
lifetime: &'a Self::InternedLifetime,
|
2020-05-22 10:14:53 -05:00
|
|
|
) -> &'a chalk_ir::LifetimeData<Self> {
|
2021-04-08 11:45:07 -05:00
|
|
|
&lifetime.0
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
|
2021-04-08 11:45:07 -05:00
|
|
|
Interned::new(InternedWrapper(constant))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
|
2021-04-08 11:45:07 -05:00
|
|
|
&constant.0
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn const_eq(
|
|
|
|
&self,
|
|
|
|
_ty: &Self::InternedType,
|
|
|
|
_c1: &Self::InternedConcreteConst,
|
|
|
|
_c2: &Self::InternedConcreteConst,
|
|
|
|
) -> bool {
|
2020-05-22 10:14:53 -05:00
|
|
|
true
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_generic_arg(
|
|
|
|
&self,
|
|
|
|
parameter: chalk_ir::GenericArgData<Self>,
|
2021-04-05 13:15:07 -05:00
|
|
|
) -> Self::InternedGenericArg {
|
2020-05-22 10:14:53 -05:00
|
|
|
parameter
|
|
|
|
}
|
|
|
|
|
|
|
|
fn generic_arg_data<'a>(
|
|
|
|
&self,
|
2021-04-05 13:15:07 -05:00
|
|
|
parameter: &'a Self::InternedGenericArg,
|
2020-05-22 10:14:53 -05:00
|
|
|
) -> &'a chalk_ir::GenericArgData<Self> {
|
|
|
|
parameter
|
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn intern_goal(&self, goal: GoalData<Self>) -> Self::InternedGoal {
|
2020-05-22 10:14:53 -05:00
|
|
|
Arc::new(goal)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_goals<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<Goal<Self>, E>>,
|
|
|
|
) -> Result<Self::InternedGoals, E> {
|
|
|
|
data.into_iter().collect()
|
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
|
2020-05-22 10:14:53 -05:00
|
|
|
goal
|
|
|
|
}
|
|
|
|
|
2021-04-05 13:15:07 -05:00
|
|
|
fn goals_data<'a>(&self, goals: &'a Self::InternedGoals) -> &'a [Goal<Interner>] {
|
2020-05-22 10:14:53 -05:00
|
|
|
goals
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_substitution<E>(
|
|
|
|
&self,
|
2021-04-08 11:25:18 -05:00
|
|
|
data: impl IntoIterator<Item = Result<GenericArg, E>>,
|
2021-03-15 13:13:49 -05:00
|
|
|
) -> Result<Self::InternedSubstitution, E> {
|
2021-04-08 11:25:18 -05:00
|
|
|
Ok(Interned::new(InternedSubstitutionInner(data.into_iter().collect::<Result<SmallVec<_>, _>>()?)))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn substitution_data<'a>(
|
|
|
|
&self,
|
2021-03-15 13:13:49 -05:00
|
|
|
substitution: &'a Self::InternedSubstitution,
|
2021-04-08 11:25:18 -05:00
|
|
|
) -> &'a [GenericArg] {
|
|
|
|
&substitution.as_ref().0
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_program_clause(
|
|
|
|
&self,
|
|
|
|
data: chalk_ir::ProgramClauseData<Self>,
|
2021-04-05 13:15:07 -05:00
|
|
|
) -> Self::InternedProgramClause {
|
2021-04-08 13:39:43 -05:00
|
|
|
data
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn program_clause_data<'a>(
|
|
|
|
&self,
|
2021-04-05 13:15:07 -05:00
|
|
|
clause: &'a Self::InternedProgramClause,
|
2020-05-22 10:14:53 -05:00
|
|
|
) -> &'a chalk_ir::ProgramClauseData<Self> {
|
|
|
|
clause
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_program_clauses<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>,
|
2021-04-05 13:15:07 -05:00
|
|
|
) -> Result<Self::InternedProgramClauses, E> {
|
2021-04-08 13:13:21 -05:00
|
|
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn program_clauses_data<'a>(
|
|
|
|
&self,
|
2021-04-05 13:15:07 -05:00
|
|
|
clauses: &'a Self::InternedProgramClauses,
|
2020-05-22 10:14:53 -05:00
|
|
|
) -> &'a [chalk_ir::ProgramClause<Self>] {
|
|
|
|
&clauses
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_quantified_where_clauses<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>,
|
|
|
|
) -> Result<Self::InternedQuantifiedWhereClauses, E> {
|
2021-04-08 13:18:51 -05:00
|
|
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn quantified_where_clauses_data<'a>(
|
|
|
|
&self,
|
|
|
|
clauses: &'a Self::InternedQuantifiedWhereClauses,
|
|
|
|
) -> &'a [chalk_ir::QuantifiedWhereClause<Self>] {
|
|
|
|
clauses
|
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_generic_arg_kinds<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
|
|
|
|
) -> Result<Self::InternedVariableKinds, E> {
|
2021-04-08 11:13:02 -05:00
|
|
|
Ok(Interned::new(InternedVariableKindsInner(
|
|
|
|
data.into_iter().collect::<Result<Vec<_>, E>>()?,
|
|
|
|
)))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn variable_kinds_data<'a>(
|
|
|
|
&self,
|
|
|
|
parameter_kinds: &'a Self::InternedVariableKinds,
|
|
|
|
) -> &'a [chalk_ir::VariableKind<Self>] {
|
2021-04-08 11:13:02 -05:00
|
|
|
¶meter_kinds.as_ref().0
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn intern_canonical_var_kinds<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
|
|
|
|
) -> Result<Self::InternedCanonicalVarKinds, E> {
|
2021-04-08 13:06:19 -05:00
|
|
|
Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn canonical_var_kinds_data<'a>(
|
|
|
|
&self,
|
|
|
|
canonical_var_kinds: &'a Self::InternedCanonicalVarKinds,
|
|
|
|
) -> &'a [chalk_ir::CanonicalVarKind<Self>] {
|
|
|
|
&canonical_var_kinds
|
|
|
|
}
|
2020-07-11 08:22:46 -05:00
|
|
|
|
|
|
|
fn intern_constraints<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>, E>>,
|
|
|
|
) -> Result<Self::InternedConstraints, E> {
|
|
|
|
data.into_iter().collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn constraints_data<'a>(
|
|
|
|
&self,
|
|
|
|
constraints: &'a Self::InternedConstraints,
|
|
|
|
) -> &'a [chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>] {
|
|
|
|
constraints
|
|
|
|
}
|
2020-07-15 14:47:45 -05:00
|
|
|
fn debug_closure_id(
|
|
|
|
_fn_def_id: chalk_ir::ClosureId<Self>,
|
|
|
|
_fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
None
|
|
|
|
}
|
|
|
|
fn debug_constraints(
|
|
|
|
_clauses: &chalk_ir::Constraints<Self>,
|
|
|
|
_fmt: &mut fmt::Formatter<'_>,
|
|
|
|
) -> Option<fmt::Result> {
|
|
|
|
None
|
|
|
|
}
|
2020-11-20 11:00:34 -06:00
|
|
|
|
|
|
|
fn intern_variances<E>(
|
|
|
|
&self,
|
|
|
|
data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>,
|
|
|
|
) -> Result<Self::InternedVariances, E> {
|
|
|
|
data.into_iter().collect()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn variances_data<'a>(
|
|
|
|
&self,
|
|
|
|
variances: &'a Self::InternedVariances,
|
|
|
|
) -> &'a [chalk_ir::Variance] {
|
|
|
|
&variances
|
|
|
|
}
|
2020-05-22 10:14:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
impl chalk_ir::interner::HasInterner for Interner {
|
|
|
|
type Interner = Self;
|
|
|
|
}
|