Skip to content

Commit a169fa6

Browse files
committed
Intern VariableKinds
1 parent 63726a9 commit a169fa6

File tree

1 file changed

+14
-4
lines changed

1 file changed

+14
-4
lines changed

crates/hir_ty/src/traits/chalk/interner.rs

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44
use super::tls;
55
use base_db::salsa::InternId;
66
use chalk_ir::{GenericArg, Goal, GoalData};
7-
use hir_def::TypeAliasId;
7+
use hir_def::{
8+
intern::{impl_internable, InternStorage, Internable, Interned},
9+
TypeAliasId,
10+
};
811
use smallvec::SmallVec;
912
use std::{fmt, sync::Arc};
1013

@@ -26,6 +29,11 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
2629
pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
2730
pub(crate) type Variances = chalk_ir::Variances<Interner>;
2831

32+
#[derive(PartialEq, Eq, Hash, Debug)]
33+
pub struct InternedVariableKindsInner(Vec<chalk_ir::VariableKind<Interner>>);
34+
35+
impl_internable!(InternedVariableKindsInner,);
36+
2937
impl chalk_ir::interner::Interner for Interner {
3038
type InternedType = Arc<chalk_ir::TyData<Self>>;
3139
type InternedLifetime = chalk_ir::LifetimeData<Self>;
@@ -38,7 +46,7 @@ impl chalk_ir::interner::Interner for Interner {
3846
type InternedProgramClause = Arc<chalk_ir::ProgramClauseData<Self>>;
3947
type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>;
4048
type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
41-
type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>;
49+
type InternedVariableKinds = Interned<InternedVariableKindsInner>;
4250
type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
4351
type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
4452
type InternedVariances = Arc<[chalk_ir::Variance]>;
@@ -322,14 +330,16 @@ impl chalk_ir::interner::Interner for Interner {
322330
&self,
323331
data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
324332
) -> Result<Self::InternedVariableKinds, E> {
325-
data.into_iter().collect()
333+
Ok(Interned::new(InternedVariableKindsInner(
334+
data.into_iter().collect::<Result<Vec<_>, E>>()?,
335+
)))
326336
}
327337

328338
fn variable_kinds_data<'a>(
329339
&self,
330340
parameter_kinds: &'a Self::InternedVariableKinds,
331341
) -> &'a [chalk_ir::VariableKind<Self>] {
332-
&parameter_kinds
342+
&parameter_kinds.as_ref().0
333343
}
334344

335345
fn intern_canonical_var_kinds<E>(

0 commit comments

Comments
 (0)