aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs18
1 files changed, 14 insertions, 4 deletions
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 @@
4use super::tls; 4use super::tls;
5use base_db::salsa::InternId; 5use base_db::salsa::InternId;
6use chalk_ir::{GenericArg, Goal, GoalData}; 6use chalk_ir::{GenericArg, Goal, GoalData};
7use hir_def::TypeAliasId; 7use hir_def::{
8 intern::{impl_internable, InternStorage, Internable, Interned},
9 TypeAliasId,
10};
8use smallvec::SmallVec; 11use smallvec::SmallVec;
9use std::{fmt, sync::Arc}; 12use std::{fmt, sync::Arc};
10 13
@@ -26,6 +29,11 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
26pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>; 29pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
27pub(crate) type Variances = chalk_ir::Variances<Interner>; 30pub(crate) type Variances = chalk_ir::Variances<Interner>;
28 31
32#[derive(PartialEq, Eq, Hash, Debug)]
33pub struct InternedVariableKindsInner(Vec<chalk_ir::VariableKind<Interner>>);
34
35impl_internable!(InternedVariableKindsInner,);
36
29impl chalk_ir::interner::Interner for Interner { 37impl chalk_ir::interner::Interner for Interner {
30 type InternedType = Arc<chalk_ir::TyData<Self>>; 38 type InternedType = Arc<chalk_ir::TyData<Self>>;
31 type InternedLifetime = chalk_ir::LifetimeData<Self>; 39 type InternedLifetime = chalk_ir::LifetimeData<Self>;
@@ -38,7 +46,7 @@ impl chalk_ir::interner::Interner for Interner {
38 type InternedProgramClause = Arc<chalk_ir::ProgramClauseData<Self>>; 46 type InternedProgramClause = Arc<chalk_ir::ProgramClauseData<Self>>;
39 type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>; 47 type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>;
40 type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>; 48 type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>;
41 type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>; 49 type InternedVariableKinds = Interned<InternedVariableKindsInner>;
42 type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>; 50 type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>;
43 type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>; 51 type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
44 type InternedVariances = Arc<[chalk_ir::Variance]>; 52 type InternedVariances = Arc<[chalk_ir::Variance]>;
@@ -322,14 +330,16 @@ impl chalk_ir::interner::Interner for Interner {
322 &self, 330 &self,
323 data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>, 331 data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
324 ) -> Result<Self::InternedVariableKinds, E> { 332 ) -> Result<Self::InternedVariableKinds, E> {
325 data.into_iter().collect() 333 Ok(Interned::new(InternedVariableKindsInner(
334 data.into_iter().collect::<Result<Vec<_>, E>>()?,
335 )))
326 } 336 }
327 337
328 fn variable_kinds_data<'a>( 338 fn variable_kinds_data<'a>(
329 &self, 339 &self,
330 parameter_kinds: &'a Self::InternedVariableKinds, 340 parameter_kinds: &'a Self::InternedVariableKinds,
331 ) -> &'a [chalk_ir::VariableKind<Self>] { 341 ) -> &'a [chalk_ir::VariableKind<Self>] {
332 &parameter_kinds 342 &parameter_kinds.as_ref().0
333 } 343 }
334 344
335 fn intern_canonical_var_kinds<E>( 345 fn intern_canonical_var_kinds<E>(