From a169fa6a832a513cd1534d1a6566e4584ca5fb6a Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 18:13:02 +0200 Subject: Intern VariableKinds --- crates/hir_ty/src/traits/chalk/interner.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'crates/hir_ty') diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs index bd9395b7e..7a3bd41d4 100644 --- a/crates/hir_ty/src/traits/chalk/interner.rs +++ b/crates/hir_ty/src/traits/chalk/interner.rs @@ -4,7 +4,10 @@ use super::tls; use base_db::salsa::InternId; use chalk_ir::{GenericArg, Goal, GoalData}; -use hir_def::TypeAliasId; +use hir_def::{ + intern::{impl_internable, InternStorage, Internable, Interned}, + TypeAliasId, +}; use smallvec::SmallVec; use std::{fmt, sync::Arc}; @@ -26,6 +29,11 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId; pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum; pub(crate) type Variances = chalk_ir::Variances; +#[derive(PartialEq, Eq, Hash, Debug)] +pub struct InternedVariableKindsInner(Vec>); + +impl_internable!(InternedVariableKindsInner,); + impl chalk_ir::interner::Interner for Interner { type InternedType = Arc>; type InternedLifetime = chalk_ir::LifetimeData; @@ -38,7 +46,7 @@ impl chalk_ir::interner::Interner for Interner { type InternedProgramClause = Arc>; type InternedProgramClauses = Arc<[chalk_ir::ProgramClause]>; type InternedQuantifiedWhereClauses = Vec>; - type InternedVariableKinds = Vec>; + type InternedVariableKinds = Interned; type InternedCanonicalVarKinds = Vec>; type InternedConstraints = Vec>>; type InternedVariances = Arc<[chalk_ir::Variance]>; @@ -322,14 +330,16 @@ impl chalk_ir::interner::Interner for Interner { &self, data: impl IntoIterator, E>>, ) -> Result { - data.into_iter().collect() + Ok(Interned::new(InternedVariableKindsInner( + data.into_iter().collect::, E>>()?, + ))) } fn variable_kinds_data<'a>( &self, parameter_kinds: &'a Self::InternedVariableKinds, ) -> &'a [chalk_ir::VariableKind] { - ¶meter_kinds + ¶meter_kinds.as_ref().0 } fn intern_canonical_var_kinds( -- cgit v1.2.3