aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src')
-rw-r--r--crates/hir_ty/src/chalk_ext.rs2
-rw-r--r--crates/hir_ty/src/display.rs20
-rw-r--r--crates/hir_ty/src/infer/expr.rs6
-rw-r--r--crates/hir_ty/src/infer/pat.rs4
-rw-r--r--crates/hir_ty/src/infer/path.rs2
-rw-r--r--crates/hir_ty/src/lib.rs4
-rw-r--r--crates/hir_ty/src/traits/chalk/interner.rs89
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs4
8 files changed, 82 insertions, 49 deletions
diff --git a/crates/hir_ty/src/chalk_ext.rs b/crates/hir_ty/src/chalk_ext.rs
index 28ed3aac6..8c4542956 100644
--- a/crates/hir_ty/src/chalk_ext.rs
+++ b/crates/hir_ty/src/chalk_ext.rs
@@ -75,7 +75,7 @@ impl TyExt for Ty {
75 } 75 }
76 fn as_reference(&self) -> Option<(&Ty, Lifetime, Mutability)> { 76 fn as_reference(&self) -> Option<(&Ty, Lifetime, Mutability)> {
77 match self.kind(&Interner) { 77 match self.kind(&Interner) {
78 TyKind::Ref(mutability, lifetime, ty) => Some((ty, *lifetime, *mutability)), 78 TyKind::Ref(mutability, lifetime, ty) => Some((ty, lifetime.clone(), *mutability)),
79 _ => None, 79 _ => None,
80 } 80 }
81 } 81 }
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs
index d7a3977e5..92224b46b 100644
--- a/crates/hir_ty/src/display.rs
+++ b/crates/hir_ty/src/display.rs
@@ -265,7 +265,7 @@ impl HirDisplay for ProjectionTy {
265 write!(f, " as {}", trait_.name)?; 265 write!(f, " as {}", trait_.name)?;
266 if self.substitution.len(&Interner) > 1 { 266 if self.substitution.len(&Interner) > 1 {
267 write!(f, "<")?; 267 write!(f, "<")?;
268 f.write_joined(&self.substitution.interned()[1..], ", ")?; 268 f.write_joined(&self.substitution.as_slice(&Interner)[1..], ", ")?;
269 write!(f, ">")?; 269 write!(f, ">")?;
270 } 270 }
271 write!(f, ">::{}", f.db.type_alias_data(from_assoc_type_id(self.associated_ty_id)).name)?; 271 write!(f, ">::{}", f.db.type_alias_data(from_assoc_type_id(self.associated_ty_id)).name)?;
@@ -416,7 +416,7 @@ impl HirDisplay for Ty {
416 write!(f, ",)")?; 416 write!(f, ",)")?;
417 } else { 417 } else {
418 write!(f, "(")?; 418 write!(f, "(")?;
419 f.write_joined(&*substs.interned(), ", ")?; 419 f.write_joined(&*substs.as_slice(&Interner), ", ")?;
420 write!(f, ")")?; 420 write!(f, ")")?;
421 } 421 }
422 } 422 }
@@ -444,7 +444,7 @@ impl HirDisplay for Ty {
444 // We print all params except implicit impl Trait params. Still a bit weird; should we leave out parent and self? 444 // We print all params except implicit impl Trait params. Still a bit weird; should we leave out parent and self?
445 if total_len > 0 { 445 if total_len > 0 {
446 write!(f, "<")?; 446 write!(f, "<")?;
447 f.write_joined(&parameters.interned()[..total_len], ", ")?; 447 f.write_joined(&parameters.as_slice(&Interner)[..total_len], ", ")?;
448 write!(f, ">")?; 448 write!(f, ">")?;
449 } 449 }
450 } 450 }
@@ -491,7 +491,7 @@ impl HirDisplay for Ty {
491 .map(|generic_def_id| f.db.generic_defaults(generic_def_id)) 491 .map(|generic_def_id| f.db.generic_defaults(generic_def_id))
492 .filter(|defaults| !defaults.is_empty()) 492 .filter(|defaults| !defaults.is_empty())
493 { 493 {
494 None => parameters.interned().as_ref(), 494 None => parameters.as_slice(&Interner),
495 Some(default_parameters) => { 495 Some(default_parameters) => {
496 let mut default_from = 0; 496 let mut default_from = 0;
497 for (i, parameter) in parameters.iter(&Interner).enumerate() { 497 for (i, parameter) in parameters.iter(&Interner).enumerate() {
@@ -515,11 +515,11 @@ impl HirDisplay for Ty {
515 } 515 }
516 } 516 }
517 } 517 }
518 &parameters.interned()[0..default_from] 518 &parameters.as_slice(&Interner)[0..default_from]
519 } 519 }
520 } 520 }
521 } else { 521 } else {
522 parameters.interned().as_ref() 522 parameters.as_slice(&Interner)
523 }; 523 };
524 if !parameters_to_write.is_empty() { 524 if !parameters_to_write.is_empty() {
525 write!(f, "<")?; 525 write!(f, "<")?;
@@ -542,7 +542,7 @@ impl HirDisplay for Ty {
542 write!(f, "{}::{}", trait_.name, type_alias_data.name)?; 542 write!(f, "{}::{}", trait_.name, type_alias_data.name)?;
543 if parameters.len(&Interner) > 0 { 543 if parameters.len(&Interner) > 0 {
544 write!(f, "<")?; 544 write!(f, "<")?;
545 f.write_joined(&*parameters.interned(), ", ")?; 545 f.write_joined(&*parameters.as_slice(&Interner), ", ")?;
546 write!(f, ">")?; 546 write!(f, ">")?;
547 } 547 }
548 } else { 548 } else {
@@ -749,13 +749,13 @@ fn write_bounds_like_dyn_trait(
749 // existential) here, which is the only thing that's 749 // existential) here, which is the only thing that's
750 // possible in actual Rust, and hence don't print it 750 // possible in actual Rust, and hence don't print it
751 write!(f, "{}", f.db.trait_data(trait_).name)?; 751 write!(f, "{}", f.db.trait_data(trait_).name)?;
752 if let [_, params @ ..] = &*trait_ref.substitution.interned().as_slice() { 752 if let [_, params @ ..] = &*trait_ref.substitution.as_slice(&Interner) {
753 if is_fn_trait { 753 if is_fn_trait {
754 if let Some(args) = 754 if let Some(args) =
755 params.first().and_then(|it| it.assert_ty_ref(&Interner).as_tuple()) 755 params.first().and_then(|it| it.assert_ty_ref(&Interner).as_tuple())
756 { 756 {
757 write!(f, "(")?; 757 write!(f, "(")?;
758 f.write_joined(&*args.interned(), ", ")?; 758 f.write_joined(args.as_slice(&Interner), ", ")?;
759 write!(f, ")")?; 759 write!(f, ")")?;
760 } 760 }
761 } else if !params.is_empty() { 761 } else if !params.is_empty() {
@@ -814,7 +814,7 @@ fn fmt_trait_ref(tr: &TraitRef, f: &mut HirFormatter, use_as: bool) -> Result<()
814 write!(f, "{}", f.db.trait_data(tr.hir_trait_id()).name)?; 814 write!(f, "{}", f.db.trait_data(tr.hir_trait_id()).name)?;
815 if tr.substitution.len(&Interner) > 1 { 815 if tr.substitution.len(&Interner) > 1 {
816 write!(f, "<")?; 816 write!(f, "<")?;
817 f.write_joined(&tr.substitution.interned()[1..], ", ")?; 817 f.write_joined(&tr.substitution.as_slice(&Interner)[1..], ", ")?;
818 write!(f, ">")?; 818 write!(f, ">")?;
819 } 819 }
820 Ok(()) 820 Ok(())
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index cbbfa8b5c..7961f4a52 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -462,7 +462,11 @@ impl<'a> InferenceContext<'a> {
462 }; 462 };
463 match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) { 463 match canonicalized.decanonicalize_ty(derefed_ty.value).kind(&Interner) {
464 TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| { 464 TyKind::Tuple(_, substs) => name.as_tuple_index().and_then(|idx| {
465 substs.interned().get(idx).map(|a| a.assert_ty_ref(&Interner)).cloned() 465 substs
466 .as_slice(&Interner)
467 .get(idx)
468 .map(|a| a.assert_ty_ref(&Interner))
469 .cloned()
466 }), 470 }),
467 TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => { 471 TyKind::Adt(AdtId(hir_def::AdtId::StructId(s)), parameters) => {
468 let local_id = self.db.struct_data(*s).variant_data.field(name)?; 472 let local_id = self.db.struct_data(*s).variant_data.field(name)?;
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs
index a41e8e116..aea354cde 100644
--- a/crates/hir_ty/src/infer/pat.rs
+++ b/crates/hir_ty/src/infer/pat.rs
@@ -122,7 +122,7 @@ impl<'a> InferenceContext<'a> {
122 let ty = match &body[pat] { 122 let ty = match &body[pat] {
123 &Pat::Tuple { ref args, ellipsis } => { 123 &Pat::Tuple { ref args, ellipsis } => {
124 let expectations = match expected.as_tuple() { 124 let expectations = match expected.as_tuple() {
125 Some(parameters) => &*parameters.interned().as_slice(), 125 Some(parameters) => &*parameters.as_slice(&Interner),
126 _ => &[], 126 _ => &[],
127 }; 127 };
128 128
@@ -242,7 +242,7 @@ impl<'a> InferenceContext<'a> {
242 let (inner_ty, alloc_ty) = match expected.as_adt() { 242 let (inner_ty, alloc_ty) = match expected.as_adt() {
243 Some((adt, subst)) if adt == box_adt => ( 243 Some((adt, subst)) if adt == box_adt => (
244 subst.at(&Interner, 0).assert_ty_ref(&Interner).clone(), 244 subst.at(&Interner, 0).assert_ty_ref(&Interner).clone(),
245 subst.interned().get(1).and_then(|a| a.ty(&Interner).cloned()), 245 subst.as_slice(&Interner).get(1).and_then(|a| a.ty(&Interner).cloned()),
246 ), 246 ),
247 _ => (self.result.standard_types.unknown.clone(), None), 247 _ => (self.result.standard_types.unknown.clone(), None),
248 }; 248 };
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs
index f8955aa32..495282eba 100644
--- a/crates/hir_ty/src/infer/path.rs
+++ b/crates/hir_ty/src/infer/path.rs
@@ -101,7 +101,7 @@ impl<'a> InferenceContext<'a> {
101 let substs = ctx.substs_from_path(path, typable, true); 101 let substs = ctx.substs_from_path(path, typable, true);
102 let ty = TyBuilder::value_ty(self.db, typable) 102 let ty = TyBuilder::value_ty(self.db, typable)
103 .use_parent_substs(&parent_substs) 103 .use_parent_substs(&parent_substs)
104 .fill(substs.interned()[parent_substs.len(&Interner)..].iter().cloned()) 104 .fill(substs.as_slice(&Interner)[parent_substs.len(&Interner)..].iter().cloned())
105 .build(); 105 .build();
106 Some(ty) 106 Some(ty)
107 } 107 }
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index 874c95411..beb58d711 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -109,7 +109,7 @@ pub type WhereClause = chalk_ir::WhereClause<Interner>;
109pub fn subst_prefix(s: &Substitution, n: usize) -> Substitution { 109pub fn subst_prefix(s: &Substitution, n: usize) -> Substitution {
110 Substitution::from_iter( 110 Substitution::from_iter(
111 &Interner, 111 &Interner,
112 s.interned()[..std::cmp::min(s.len(&Interner), n)].iter().cloned(), 112 s.as_slice(&Interner)[..std::cmp::min(s.len(&Interner), n)].iter().cloned(),
113 ) 113 )
114} 114}
115 115
@@ -187,7 +187,7 @@ impl CallableSig {
187 .shifted_out_to(&Interner, DebruijnIndex::ONE) 187 .shifted_out_to(&Interner, DebruijnIndex::ONE)
188 .expect("unexpected lifetime vars in fn ptr") 188 .expect("unexpected lifetime vars in fn ptr")
189 .0 189 .0
190 .interned() 190 .as_slice(&Interner)
191 .iter() 191 .iter()
192 .map(|arg| arg.assert_ty_ref(&Interner).clone()) 192 .map(|arg| arg.assert_ty_ref(&Interner).clone())
193 .collect(), 193 .collect(),
diff --git a/crates/hir_ty/src/traits/chalk/interner.rs b/crates/hir_ty/src/traits/chalk/interner.rs
index bd9395b7e..b6a3cec6d 100644
--- a/crates/hir_ty/src/traits/chalk/interner.rs
+++ b/crates/hir_ty/src/traits/chalk/interner.rs
@@ -2,9 +2,13 @@
2//! representation of the various objects Chalk deals with (types, goals etc.). 2//! representation of the various objects Chalk deals with (types, goals etc.).
3 3
4use super::tls; 4use super::tls;
5use crate::GenericArg;
5use base_db::salsa::InternId; 6use base_db::salsa::InternId;
6use chalk_ir::{GenericArg, Goal, GoalData}; 7use chalk_ir::{Goal, GoalData};
7use hir_def::TypeAliasId; 8use hir_def::{
9 intern::{impl_internable, InternStorage, Internable, Interned},
10 TypeAliasId,
11};
8use smallvec::SmallVec; 12use smallvec::SmallVec;
9use std::{fmt, sync::Arc}; 13use std::{fmt, sync::Arc};
10 14
@@ -26,22 +30,47 @@ pub(crate) type OpaqueTyId = chalk_ir::OpaqueTyId<Interner>;
26pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>; 30pub(crate) type OpaqueTyDatum = chalk_solve::rust_ir::OpaqueTyDatum<Interner>;
27pub(crate) type Variances = chalk_ir::Variances<Interner>; 31pub(crate) type Variances = chalk_ir::Variances<Interner>;
28 32
33#[derive(PartialEq, Eq, Hash, Debug)]
34pub struct InternedWrapper<T>(T);
35
36impl<T> std::ops::Deref for InternedWrapper<T> {
37 type Target = T;
38
39 fn deref(&self) -> &Self::Target {
40 &self.0
41 }
42}
43
44impl_internable!(
45 InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>,
46 InternedWrapper<SmallVec<[GenericArg; 2]>>,
47 InternedWrapper<chalk_ir::TyData<Interner>>,
48 InternedWrapper<chalk_ir::LifetimeData<Interner>>,
49 InternedWrapper<chalk_ir::ConstData<Interner>>,
50 InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Interner>>>,
51 InternedWrapper<Vec<chalk_ir::ProgramClause<Interner>>>,
52 InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Interner>>>,
53 InternedWrapper<Vec<chalk_ir::Variance>>,
54);
55
29impl chalk_ir::interner::Interner for Interner { 56impl chalk_ir::interner::Interner for Interner {
30 type InternedType = Arc<chalk_ir::TyData<Self>>; 57 type InternedType = Interned<InternedWrapper<chalk_ir::TyData<Interner>>>;
31 type InternedLifetime = chalk_ir::LifetimeData<Self>; 58 type InternedLifetime = Interned<InternedWrapper<chalk_ir::LifetimeData<Self>>>;
32 type InternedConst = Arc<chalk_ir::ConstData<Self>>; 59 type InternedConst = Interned<InternedWrapper<chalk_ir::ConstData<Self>>>;
33 type InternedConcreteConst = (); 60 type InternedConcreteConst = ();
34 type InternedGenericArg = chalk_ir::GenericArgData<Self>; 61 type InternedGenericArg = chalk_ir::GenericArgData<Self>;
35 type InternedGoal = Arc<GoalData<Self>>; 62 type InternedGoal = Arc<GoalData<Self>>;
36 type InternedGoals = Vec<Goal<Self>>; 63 type InternedGoals = Vec<Goal<Self>>;
37 type InternedSubstitution = SmallVec<[GenericArg<Self>; 2]>; 64 type InternedSubstitution = Interned<InternedWrapper<SmallVec<[GenericArg; 2]>>>;
38 type InternedProgramClause = Arc<chalk_ir::ProgramClauseData<Self>>; 65 type InternedProgramClause = chalk_ir::ProgramClauseData<Self>;
39 type InternedProgramClauses = Arc<[chalk_ir::ProgramClause<Self>]>; 66 type InternedProgramClauses = Interned<InternedWrapper<Vec<chalk_ir::ProgramClause<Self>>>>;
40 type InternedQuantifiedWhereClauses = Vec<chalk_ir::QuantifiedWhereClause<Self>>; 67 type InternedQuantifiedWhereClauses =
41 type InternedVariableKinds = Vec<chalk_ir::VariableKind<Self>>; 68 Interned<InternedWrapper<Vec<chalk_ir::QuantifiedWhereClause<Self>>>>;
42 type InternedCanonicalVarKinds = Vec<chalk_ir::CanonicalVarKind<Self>>; 69 type InternedVariableKinds = Interned<InternedWrapper<Vec<chalk_ir::VariableKind<Interner>>>>;
70 type InternedCanonicalVarKinds =
71 Interned<InternedWrapper<Vec<chalk_ir::CanonicalVarKind<Self>>>>;
43 type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>; 72 type InternedConstraints = Vec<chalk_ir::InEnvironment<chalk_ir::Constraint<Self>>>;
44 type InternedVariances = Arc<[chalk_ir::Variance]>; 73 type InternedVariances = Interned<InternedWrapper<Vec<chalk_ir::Variance>>>;
45 type DefId = InternId; 74 type DefId = InternId;
46 type InternedAdtId = hir_def::AdtId; 75 type InternedAdtId = hir_def::AdtId;
47 type Identifier = TypeAliasId; 76 type Identifier = TypeAliasId;
@@ -99,7 +128,7 @@ impl chalk_ir::interner::Interner for Interner {
99 } 128 }
100 129
101 fn debug_generic_arg( 130 fn debug_generic_arg(
102 parameter: &GenericArg<Interner>, 131 parameter: &GenericArg,
103 fmt: &mut fmt::Formatter<'_>, 132 fmt: &mut fmt::Formatter<'_>,
104 ) -> Option<fmt::Result> { 133 ) -> Option<fmt::Result> {
105 tls::with_current_program(|prog| Some(prog?.debug_generic_arg(parameter, fmt))) 134 tls::with_current_program(|prog| Some(prog?.debug_generic_arg(parameter, fmt)))
@@ -194,30 +223,30 @@ impl chalk_ir::interner::Interner for Interner {
194 223
195 fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType { 224 fn intern_ty(&self, kind: chalk_ir::TyKind<Self>) -> Self::InternedType {
196 let flags = kind.compute_flags(self); 225 let flags = kind.compute_flags(self);
197 Arc::new(chalk_ir::TyData { kind, flags }) 226 Interned::new(InternedWrapper(chalk_ir::TyData { kind, flags }))
198 } 227 }
199 228
200 fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> { 229 fn ty_data<'a>(&self, ty: &'a Self::InternedType) -> &'a chalk_ir::TyData<Self> {
201 ty 230 &ty.0
202 } 231 }
203 232
204 fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime { 233 fn intern_lifetime(&self, lifetime: chalk_ir::LifetimeData<Self>) -> Self::InternedLifetime {
205 lifetime 234 Interned::new(InternedWrapper(lifetime))
206 } 235 }
207 236
208 fn lifetime_data<'a>( 237 fn lifetime_data<'a>(
209 &self, 238 &self,
210 lifetime: &'a Self::InternedLifetime, 239 lifetime: &'a Self::InternedLifetime,
211 ) -> &'a chalk_ir::LifetimeData<Self> { 240 ) -> &'a chalk_ir::LifetimeData<Self> {
212 lifetime 241 &lifetime.0
213 } 242 }
214 243
215 fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst { 244 fn intern_const(&self, constant: chalk_ir::ConstData<Self>) -> Self::InternedConst {
216 Arc::new(constant) 245 Interned::new(InternedWrapper(constant))
217 } 246 }
218 247
219 fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> { 248 fn const_data<'a>(&self, constant: &'a Self::InternedConst) -> &'a chalk_ir::ConstData<Self> {
220 constant 249 &constant.0
221 } 250 }
222 251
223 fn const_eq( 252 fn const_eq(
@@ -264,23 +293,23 @@ impl chalk_ir::interner::Interner for Interner {
264 293
265 fn intern_substitution<E>( 294 fn intern_substitution<E>(
266 &self, 295 &self,
267 data: impl IntoIterator<Item = Result<GenericArg<Self>, E>>, 296 data: impl IntoIterator<Item = Result<GenericArg, E>>,
268 ) -> Result<Self::InternedSubstitution, E> { 297 ) -> Result<Self::InternedSubstitution, E> {
269 data.into_iter().collect() 298 Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
270 } 299 }
271 300
272 fn substitution_data<'a>( 301 fn substitution_data<'a>(
273 &self, 302 &self,
274 substitution: &'a Self::InternedSubstitution, 303 substitution: &'a Self::InternedSubstitution,
275 ) -> &'a [GenericArg<Self>] { 304 ) -> &'a [GenericArg] {
276 substitution 305 &substitution.as_ref().0
277 } 306 }
278 307
279 fn intern_program_clause( 308 fn intern_program_clause(
280 &self, 309 &self,
281 data: chalk_ir::ProgramClauseData<Self>, 310 data: chalk_ir::ProgramClauseData<Self>,
282 ) -> Self::InternedProgramClause { 311 ) -> Self::InternedProgramClause {
283 Arc::new(data) 312 data
284 } 313 }
285 314
286 fn program_clause_data<'a>( 315 fn program_clause_data<'a>(
@@ -294,7 +323,7 @@ impl chalk_ir::interner::Interner for Interner {
294 &self, 323 &self,
295 data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>, 324 data: impl IntoIterator<Item = Result<chalk_ir::ProgramClause<Self>, E>>,
296 ) -> Result<Self::InternedProgramClauses, E> { 325 ) -> Result<Self::InternedProgramClauses, E> {
297 data.into_iter().collect() 326 Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
298 } 327 }
299 328
300 fn program_clauses_data<'a>( 329 fn program_clauses_data<'a>(
@@ -308,7 +337,7 @@ impl chalk_ir::interner::Interner for Interner {
308 &self, 337 &self,
309 data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>, 338 data: impl IntoIterator<Item = Result<chalk_ir::QuantifiedWhereClause<Self>, E>>,
310 ) -> Result<Self::InternedQuantifiedWhereClauses, E> { 339 ) -> Result<Self::InternedQuantifiedWhereClauses, E> {
311 data.into_iter().collect() 340 Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
312 } 341 }
313 342
314 fn quantified_where_clauses_data<'a>( 343 fn quantified_where_clauses_data<'a>(
@@ -322,21 +351,21 @@ impl chalk_ir::interner::Interner for Interner {
322 &self, 351 &self,
323 data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>, 352 data: impl IntoIterator<Item = Result<chalk_ir::VariableKind<Self>, E>>,
324 ) -> Result<Self::InternedVariableKinds, E> { 353 ) -> Result<Self::InternedVariableKinds, E> {
325 data.into_iter().collect() 354 Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
326 } 355 }
327 356
328 fn variable_kinds_data<'a>( 357 fn variable_kinds_data<'a>(
329 &self, 358 &self,
330 parameter_kinds: &'a Self::InternedVariableKinds, 359 parameter_kinds: &'a Self::InternedVariableKinds,
331 ) -> &'a [chalk_ir::VariableKind<Self>] { 360 ) -> &'a [chalk_ir::VariableKind<Self>] {
332 &parameter_kinds 361 &parameter_kinds.as_ref().0
333 } 362 }
334 363
335 fn intern_canonical_var_kinds<E>( 364 fn intern_canonical_var_kinds<E>(
336 &self, 365 &self,
337 data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>, 366 data: impl IntoIterator<Item = Result<chalk_ir::CanonicalVarKind<Self>, E>>,
338 ) -> Result<Self::InternedCanonicalVarKinds, E> { 367 ) -> Result<Self::InternedCanonicalVarKinds, E> {
339 data.into_iter().collect() 368 Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
340 } 369 }
341 370
342 fn canonical_var_kinds_data<'a>( 371 fn canonical_var_kinds_data<'a>(
@@ -376,7 +405,7 @@ impl chalk_ir::interner::Interner for Interner {
376 &self, 405 &self,
377 data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>, 406 data: impl IntoIterator<Item = Result<chalk_ir::Variance, E>>,
378 ) -> Result<Self::InternedVariances, E> { 407 ) -> Result<Self::InternedVariances, E> {
379 data.into_iter().collect() 408 Ok(Interned::new(InternedWrapper(data.into_iter().collect::<Result<_, _>>()?)))
380 } 409 }
381 410
382 fn variances_data<'a>( 411 fn variances_data<'a>(
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 7818f6387..e78581ea5 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -99,7 +99,7 @@ pub(super) fn generic_predicate_to_inline_bound(
99 // have the expected self type 99 // have the expected self type
100 return None; 100 return None;
101 } 101 }
102 let args_no_self = trait_ref.substitution.interned()[1..] 102 let args_no_self = trait_ref.substitution.as_slice(&Interner)[1..]
103 .iter() 103 .iter()
104 .map(|ty| ty.clone().cast(&Interner)) 104 .map(|ty| ty.clone().cast(&Interner))
105 .collect(); 105 .collect();
@@ -111,7 +111,7 @@ pub(super) fn generic_predicate_to_inline_bound(
111 return None; 111 return None;
112 } 112 }
113 let trait_ = projection_ty.trait_(db); 113 let trait_ = projection_ty.trait_(db);
114 let args_no_self = projection_ty.substitution.interned()[1..] 114 let args_no_self = projection_ty.substitution.as_slice(&Interner)[1..]
115 .iter() 115 .iter()
116 .map(|ty| ty.clone().cast(&Interner)) 116 .map(|ty| ty.clone().cast(&Interner))
117 .collect(); 117 .collect();