Use more assoc. type aliases in the chalk interner

Makes it sligthly easier to swap out these types
This commit is contained in:
Jonas Schievink 2021-04-05 20:15:07 +02:00
parent c91b537683
commit f48dd154a5

View File

@ -192,59 +192,58 @@ impl chalk_ir::interner::Interner for Interner {
tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt))) tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt)))
} }
fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Arc<chalk_ir::TyData<Self>> { fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
let flags = kind.compute_flags(self); let flags = kind.compute_flags(self);
Arc::new(chalk_ir::TyData { kind, flags }) Arc::new(chalk_ir::TyData { kind, flags })
} }
fn ty_data<'a>(&self, ty: &'a Arc<chalk_ir::TyData<Self>>) -> &'a chalk_ir::TyData<Self> { fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
ty ty
} }
fn intern_lifetime( fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
&self,
lifetime: chalk_ir::LifetimeData<Self>,
) -> chalk_ir::LifetimeData<Self> {
lifetime lifetime
} }
fn lifetime_data<'a>( fn lifetime_data<'a>(
&self, &self,
lifetime: &'a chalk_ir::LifetimeData<Self>, lifetime: &'a Self::InternedLifetime,
) -> &'a chalk_ir::LifetimeData<Self> { ) -> &'a chalk_ir::LifetimeData<Self> {
lifetime lifetime
} }
fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Arc<chalk_ir::ConstData<Self>> { fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
Arc::new(constant) Arc::new(constant)
} }
fn const_data<'a>( fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
&self,
constant: &'a Arc<chalk_ir::ConstData<Self>>,
) -> &'a chalk_ir::ConstData<Self> {
constant constant
} }
fn const_eq(&self, _ty: &Arc<chalk_ir::TyData<Self>>, _c1: &(), _c2: &()) -> bool { fn const_eq(
&self,
_ty: &Self::InternedType,
_c1: &Self::InternedConcreteConst,
_c2: &Self::InternedConcreteConst,
) -> bool {
true true
} }
fn intern_generic_arg( fn intern_generic_arg(
&self, &self,
parameter: chalk_ir::GenericArgData<Self>, parameter: chalk_ir::GenericArgData<Self>,
) -> chalk_ir::GenericArgData<Self> { ) -> Self::InternedGenericArg {
parameter parameter
} }
fn generic_arg_data<'a>( fn generic_arg_data<'a>(
&self, &self,
parameter: &'a chalk_ir::GenericArgData<Self>, parameter: &'a Self::InternedGenericArg,
) -> &'a chalk_ir::GenericArgData<Self> { ) -> &'a chalk_ir::GenericArgData<Self> {
parameter parameter
} }
fn intern_goal(&self, goal: GoalData<Self>) -> Arc<GoalData<Self>> { fn intern_goal(&self, goal: GoalData<Self>) -> Self::InternedGoal {
Arc::new(goal) Arc::new(goal)
} }
@ -255,11 +254,11 @@ impl chalk_ir::interner::Interner for Interner {
data.into_iter().collect() data.into_iter().collect()
} }
fn goal_data<'a>(&self, goal: &'a Arc<GoalData<Self>>) -> &'a GoalData<Self> { fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData<Self> {
goal goal
} }
fn goals_data<'a>(&self, goals: &'a Vec<Goal<Interner>>) -> &'a [Goal<Interner>] { fn goals_data<'a>(&self, goals: &'a Self::InternedGoals) -> &'a [Goal<Interner>] {
goals goals
} }
@ -280,13 +279,13 @@ impl chalk_ir::interner::Interner for Interner {
fn intern_program_clause( fn intern_program_clause(
&self, &self,
data: chalk_ir::ProgramClauseData<Self>, data: chalk_ir::ProgramClauseData<Self>,
) -> Arc<chalk_ir::ProgramClauseData<Self>> { ) -> Self::InternedProgramClause {
Arc::new(data) Arc::new(data)
} }
fn program_clause_data<'a>( fn program_clause_data<'a>(
&self, &self,
clause: &'a Arc<chalk_ir::ProgramClauseData<Self>>, clause: &'a Self::InternedProgramClause,
) -> &'a chalk_ir::ProgramClauseData<Self> { ) -> &'a chalk_ir::ProgramClauseData<Self> {
clause clause
} }
@ -294,13 +293,13 @@ impl chalk_ir::interner::Interner for Interner {
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<chalk_ir::ProgramClause<Self>, E>>,
) -> Result<Arc<[chalk_ir::ProgramClause<Self>]>, E> { ) -> Result<Self::InternedProgramClauses, E> {
data.into_iter().collect() data.into_iter().collect()
} }
fn program_clauses_data<'a>( fn program_clauses_data<'a>(
&self, &self,
clauses: &'a Arc<[chalk_ir::ProgramClause<Self>]>, clauses: &'a Self::InternedProgramClauses,
) -> &'a [chalk_ir::ProgramClause<Self>] { ) -> &'a [chalk_ir::ProgramClause<Self>] {
&clauses &clauses
} }