From f48dd154a588b44568dcba9f50983c0578837f04 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Mon, 5 Apr 2021 20:15:07 +0200 Subject: Use more assoc. type aliases in the chalk interner Makes it sligthly easier to swap out these types --- crates/hir_ty/src/traits/chalk/interner.rs | 43 +++++++++++++++--------------- 1 file changed, 21 insertions(+), 22 deletions(-) (limited to 'crates') diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index 94e94a26d..bd9395b7e 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs @@ -192,59 +192,58 @@ impl chalk_ir::interner::Interner for Interner { tls::with_current_program(|prog| Some(prog?.debug_quantified_where_clauses(clauses, fmt))) } - fn intern_ty(&self, kind: chalk_ir::TyKind) -> Arc> { + fn intern_ty(&self, kind: chalk_ir::TyKind) -> Self::InternedType { let flags = kind.compute_flags(self); Arc::new(chalk_ir::TyData { kind, flags }) } - fn ty_data<'a>(&self, ty: &'a Arc>) -> &'a chalk_ir::TyData { + fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData { ty } - fn intern_lifetime( - &self, - lifetime: chalk_ir::LifetimeData, - ) -> chalk_ir::LifetimeData { + fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData) -> Self::InternedLifetime { lifetime } fn lifetime_data<'a>( &self, - lifetime: &'a chalk_ir::LifetimeData, + lifetime: &'a Self::InternedLifetime, ) -> &'a chalk_ir::LifetimeData { lifetime } - fn intern_const(&self, constant: chalk_ir::ConstData) -> Arc> { + fn intern_const(&self, constant: chalk_ir::ConstData) -> Self::InternedConst { Arc::new(constant) } - fn const_data<'a>( - &self, - constant: &'a Arc>, - ) -> &'a chalk_ir::ConstData { + fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData { constant } - fn const_eq(&self, _ty: &Arc>, _c1: &(), _c2: &()) -> bool { + fn const_eq( + &self, + _ty: &Self::InternedType, + _c1: &Self::InternedConcreteConst, + _c2: &Self::InternedConcreteConst, + ) -> bool { true } fn intern_generic_arg( &self, parameter: chalk_ir::GenericArgData, - ) -> chalk_ir::GenericArgData { + ) -> Self::InternedGenericArg { parameter } fn generic_arg_data<'a>( &self, - parameter: &'a chalk_ir::GenericArgData, + parameter: &'a Self::InternedGenericArg, ) -> &'a chalk_ir::GenericArgData { parameter } - fn intern_goal(&self, goal: GoalData) -> Arc> { + fn intern_goal(&self, goal: GoalData) -> Self::InternedGoal { Arc::new(goal) } @@ -255,11 +254,11 @@ impl chalk_ir::interner::Interner for Interner { data.into_iter().collect() } - fn goal_data<'a>(&self, goal: &'a Arc>) -> &'a GoalData { + fn goal_data<'a>(&self, goal: &'a Self::InternedGoal) -> &'a GoalData { goal } - fn goals_data<'a>(&self, goals: &'a Vec>) -> &'a [Goal] { + fn goals_data<'a>(&self, goals: &'a Self::InternedGoals) -> &'a [Goal] { goals } @@ -280,13 +279,13 @@ impl chalk_ir::interner::Interner for Interner { fn intern_program_clause( &self, data: chalk_ir::ProgramClauseData, - ) -> Arc> { + ) -> Self::InternedProgramClause { Arc::new(data) } fn program_clause_data<'a>( &self, - clause: &'a Arc>, + clause: &'a Self::InternedProgramClause, ) -> &'a chalk_ir::ProgramClauseData { clause } @@ -294,13 +293,13 @@ impl chalk_ir::interner::Interner for Interner { fn intern_program_clauses( &self, data: impl IntoIterator, E>>, - ) -> Result]>, E> { + ) -> Result { data.into_iter().collect() } fn program_clauses_data<'a>( &self, - clauses: &'a Arc<[chalk_ir::ProgramClause]>, + clauses: &'a Self::InternedProgramClauses, ) -> &'a [chalk_ir::ProgramClause] { &clauses } -- cgit v1.2.3