aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/traits
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r--crates/hir_ty/src/traits/chalk.rs32
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs91
2 files changed, 65 insertions, 58 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs
index 1a2a3a8c7..55181cc49 100644
--- a/crates/hir_ty/src/traits/chalk.rs
+++ b/crates/hir_ty/src/traits/chalk.rs
@@ -20,13 +20,14 @@ use crate::{
20 method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS}, 20 method_resolution::{TyFingerprint, ALL_FLOAT_FPS, ALL_INT_FPS},
21 utils::generics, 21 utils::generics,
22 BoundVar, CallableDefId, CallableSig, DebruijnIndex, GenericPredicate, ProjectionPredicate, 22 BoundVar, CallableDefId, CallableSig, DebruijnIndex, GenericPredicate, ProjectionPredicate,
23 ProjectionTy, Substs, TraitRef, Ty, 23 ProjectionTy, Substs, TraitRef, Ty, TyKind,
24}; 24};
25use mapping::{ 25use mapping::{
26 convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsAssocType, 26 convert_where_clauses, generic_predicate_to_inline_bound, make_binders, TypeAliasAsAssocType,
27 TypeAliasAsValue, 27 TypeAliasAsValue,
28}; 28};
29 29
30pub use self::interner::Interner;
30pub(crate) use self::interner::*; 31pub(crate) use self::interner::*;
31 32
32pub(super) mod tls; 33pub(super) mod tls;
@@ -90,7 +91,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
90 ty: &Ty, 91 ty: &Ty,
91 binders: &CanonicalVarKinds<Interner>, 92 binders: &CanonicalVarKinds<Interner>,
92 ) -> Option<chalk_ir::TyVariableKind> { 93 ) -> Option<chalk_ir::TyVariableKind> {
93 if let Ty::BoundVar(bv) = ty { 94 if let TyKind::BoundVar(bv) = ty.interned(&Interner) {
94 let binders = binders.as_slice(&Interner); 95 let binders = binders.as_slice(&Interner);
95 if bv.debruijn == DebruijnIndex::INNERMOST { 96 if bv.debruijn == DebruijnIndex::INNERMOST {
96 if let chalk_ir::VariableKind::Ty(tk) = binders[bv.index].kind { 97 if let chalk_ir::VariableKind::Ty(tk) = binders[bv.index].kind {
@@ -220,21 +221,25 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
220 let impl_bound = GenericPredicate::Implemented(TraitRef { 221 let impl_bound = GenericPredicate::Implemented(TraitRef {
221 trait_: future_trait, 222 trait_: future_trait,
222 // Self type as the first parameter. 223 // Self type as the first parameter.
223 substs: Substs::single(Ty::BoundVar(BoundVar { 224 substs: Substs::single(
224 debruijn: DebruijnIndex::INNERMOST, 225 TyKind::BoundVar(BoundVar {
225 index: 0, 226 debruijn: DebruijnIndex::INNERMOST,
226 })), 227 index: 0,
228 })
229 .intern(&Interner),
230 ),
227 }); 231 });
228 let proj_bound = GenericPredicate::Projection(ProjectionPredicate { 232 let proj_bound = GenericPredicate::Projection(ProjectionPredicate {
229 // The parameter of the opaque type. 233 // The parameter of the opaque type.
230 ty: Ty::BoundVar(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 }), 234 ty: TyKind::BoundVar(BoundVar { debruijn: DebruijnIndex::ONE, index: 0 })
235 .intern(&Interner),
231 projection_ty: ProjectionTy { 236 projection_ty: ProjectionTy {
232 associated_ty: future_output, 237 associated_ty: future_output,
233 // Self type as the first parameter. 238 // Self type as the first parameter.
234 parameters: Substs::single(Ty::BoundVar(BoundVar::new( 239 parameters: Substs::single(
235 DebruijnIndex::INNERMOST, 240 TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, 0))
236 0, 241 .intern(&Interner),
237 ))), 242 ),
238 }, 243 },
239 }); 244 });
240 let bound = OpaqueTyDatumBound { 245 let bound = OpaqueTyDatumBound {
@@ -263,7 +268,7 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> {
263 268
264 fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> { 269 fn hidden_opaque_type(&self, _id: chalk_ir::OpaqueTyId<Interner>) -> chalk_ir::Ty<Interner> {
265 // FIXME: actually provide the hidden type; it is relevant for auto traits 270 // FIXME: actually provide the hidden type; it is relevant for auto traits
266 Ty::Unknown.to_chalk(self.db) 271 TyKind::Unknown.intern(&Interner).to_chalk(self.db)
267 } 272 }
268 273
269 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool { 274 fn is_object_safe(&self, _trait_id: chalk_ir::TraitId<Interner>) -> bool {
@@ -391,7 +396,8 @@ pub(crate) fn associated_ty_data_query(
391 let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast()); 396 let resolver = hir_def::resolver::HasResolver::resolver(type_alias, db.upcast());
392 let ctx = crate::TyLoweringContext::new(db, &resolver) 397 let ctx = crate::TyLoweringContext::new(db, &resolver)
393 .with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable); 398 .with_type_param_mode(crate::lower::TypeParamLoweringMode::Variable);
394 let self_ty = Ty::BoundVar(crate::BoundVar::new(crate::DebruijnIndex::INNERMOST, 0)); 399 let self_ty =
400 TyKind::BoundVar(BoundVar::new(crate::DebruijnIndex::INNERMOST, 0)).intern(&Interner);
395 let bounds = type_alias_data 401 let bounds = type_alias_data
396 .bounds 402 .bounds
397 .iter() 403 .iter()
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index b0415e8b0..44cfb9359 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -26,10 +26,10 @@ use super::*;
26impl ToChalk for Ty { 26impl ToChalk for Ty {
27 type Chalk = chalk_ir::Ty<Interner>; 27 type Chalk = chalk_ir::Ty<Interner>;
28 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { 28 fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> {
29 match self { 29 match self.0 {
30 Ty::Ref(m, parameters) => ref_to_chalk(db, m, parameters), 30 TyKind::Ref(m, parameters) => ref_to_chalk(db, m, parameters),
31 Ty::Array(parameters) => array_to_chalk(db, parameters), 31 TyKind::Array(parameters) => array_to_chalk(db, parameters),
32 Ty::Function(FnPointer { sig: FnSig { variadic }, substs, .. }) => { 32 TyKind::Function(FnPointer { sig: FnSig { variadic }, substs, .. }) => {
33 let substitution = chalk_ir::FnSubst(substs.to_chalk(db).shifted_in(&Interner)); 33 let substitution = chalk_ir::FnSubst(substs.to_chalk(db).shifted_in(&Interner));
34 chalk_ir::TyKind::Function(chalk_ir::FnPointer { 34 chalk_ir::TyKind::Function(chalk_ir::FnPointer {
35 num_binders: 0, 35 num_binders: 0,
@@ -38,57 +38,57 @@ impl ToChalk for Ty {
38 }) 38 })
39 .intern(&Interner) 39 .intern(&Interner)
40 } 40 }
41 Ty::AssociatedType(type_alias, substs) => { 41 TyKind::AssociatedType(type_alias, substs) => {
42 let assoc_type = TypeAliasAsAssocType(type_alias); 42 let assoc_type = TypeAliasAsAssocType(type_alias);
43 let assoc_type_id = assoc_type.to_chalk(db); 43 let assoc_type_id = assoc_type.to_chalk(db);
44 let substitution = substs.to_chalk(db); 44 let substitution = substs.to_chalk(db);
45 chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner) 45 chalk_ir::TyKind::AssociatedType(assoc_type_id, substitution).intern(&Interner)
46 } 46 }
47 47
48 Ty::OpaqueType(impl_trait_id, substs) => { 48 TyKind::OpaqueType(impl_trait_id, substs) => {
49 let id = impl_trait_id.to_chalk(db); 49 let id = impl_trait_id.to_chalk(db);
50 let substitution = substs.to_chalk(db); 50 let substitution = substs.to_chalk(db);
51 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner) 51 chalk_ir::TyKind::OpaqueType(id, substitution).intern(&Interner)
52 } 52 }
53 53
54 Ty::ForeignType(type_alias) => { 54 TyKind::ForeignType(type_alias) => {
55 let foreign_type = TypeAliasAsForeignType(type_alias); 55 let foreign_type = TypeAliasAsForeignType(type_alias);
56 let foreign_type_id = foreign_type.to_chalk(db); 56 let foreign_type_id = foreign_type.to_chalk(db);
57 chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner) 57 chalk_ir::TyKind::Foreign(foreign_type_id).intern(&Interner)
58 } 58 }
59 59
60 Ty::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), 60 TyKind::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner),
61 61
62 Ty::Tuple(cardinality, substs) => { 62 TyKind::Tuple(cardinality, substs) => {
63 let substitution = substs.to_chalk(db); 63 let substitution = substs.to_chalk(db);
64 chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner) 64 chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner)
65 } 65 }
66 Ty::Raw(mutability, substs) => { 66 TyKind::Raw(mutability, substs) => {
67 let ty = substs[0].clone().to_chalk(db); 67 let ty = substs[0].clone().to_chalk(db);
68 chalk_ir::TyKind::Raw(mutability, ty).intern(&Interner) 68 chalk_ir::TyKind::Raw(mutability, ty).intern(&Interner)
69 } 69 }
70 Ty::Slice(substs) => { 70 TyKind::Slice(substs) => {
71 chalk_ir::TyKind::Slice(substs[0].clone().to_chalk(db)).intern(&Interner) 71 chalk_ir::TyKind::Slice(substs[0].clone().to_chalk(db)).intern(&Interner)
72 } 72 }
73 Ty::Str => chalk_ir::TyKind::Str.intern(&Interner), 73 TyKind::Str => chalk_ir::TyKind::Str.intern(&Interner),
74 Ty::FnDef(callable_def, substs) => { 74 TyKind::FnDef(callable_def, substs) => {
75 let id = callable_def.to_chalk(db); 75 let id = callable_def.to_chalk(db);
76 let substitution = substs.to_chalk(db); 76 let substitution = substs.to_chalk(db);
77 chalk_ir::TyKind::FnDef(id, substitution).intern(&Interner) 77 chalk_ir::TyKind::FnDef(id, substitution).intern(&Interner)
78 } 78 }
79 Ty::Never => chalk_ir::TyKind::Never.intern(&Interner), 79 TyKind::Never => chalk_ir::TyKind::Never.intern(&Interner),
80 80
81 Ty::Closure(def, expr, substs) => { 81 TyKind::Closure(def, expr, substs) => {
82 let closure_id = db.intern_closure((def, expr)); 82 let closure_id = db.intern_closure((def, expr));
83 let substitution = substs.to_chalk(db); 83 let substitution = substs.to_chalk(db);
84 chalk_ir::TyKind::Closure(closure_id.into(), substitution).intern(&Interner) 84 chalk_ir::TyKind::Closure(closure_id.into(), substitution).intern(&Interner)
85 } 85 }
86 86
87 Ty::Adt(adt_id, substs) => { 87 TyKind::Adt(adt_id, substs) => {
88 let substitution = substs.to_chalk(db); 88 let substitution = substs.to_chalk(db);
89 chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner) 89 chalk_ir::TyKind::Adt(adt_id, substitution).intern(&Interner)
90 } 90 }
91 Ty::Alias(AliasTy::Projection(proj_ty)) => { 91 TyKind::Alias(AliasTy::Projection(proj_ty)) => {
92 let associated_ty_id = TypeAliasAsAssocType(proj_ty.associated_ty).to_chalk(db); 92 let associated_ty_id = TypeAliasAsAssocType(proj_ty.associated_ty).to_chalk(db);
93 let substitution = proj_ty.parameters.to_chalk(db); 93 let substitution = proj_ty.parameters.to_chalk(db);
94 chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy { 94 chalk_ir::AliasTy::Projection(chalk_ir::ProjectionTy {
@@ -98,7 +98,7 @@ impl ToChalk for Ty {
98 .cast(&Interner) 98 .cast(&Interner)
99 .intern(&Interner) 99 .intern(&Interner)
100 } 100 }
101 Ty::Placeholder(id) => { 101 TyKind::Placeholder(id) => {
102 let interned_id = db.intern_type_param_id(id); 102 let interned_id = db.intern_type_param_id(id);
103 PlaceholderIndex { 103 PlaceholderIndex {
104 ui: UniverseIndex::ROOT, 104 ui: UniverseIndex::ROOT,
@@ -106,9 +106,9 @@ impl ToChalk for Ty {
106 } 106 }
107 .to_ty::<Interner>(&Interner) 107 .to_ty::<Interner>(&Interner)
108 } 108 }
109 Ty::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner), 109 TyKind::BoundVar(idx) => chalk_ir::TyKind::BoundVar(idx).intern(&Interner),
110 Ty::InferenceVar(..) => panic!("uncanonicalized infer ty"), 110 TyKind::InferenceVar(..) => panic!("uncanonicalized infer ty"),
111 Ty::Dyn(predicates) => { 111 TyKind::Dyn(predicates) => {
112 let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter( 112 let where_clauses = chalk_ir::QuantifiedWhereClauses::from_iter(
113 &Interner, 113 &Interner,
114 predicates.iter().filter(|p| !p.is_error()).cloned().map(|p| p.to_chalk(db)), 114 predicates.iter().filter(|p| !p.is_error()).cloned().map(|p| p.to_chalk(db)),
@@ -119,7 +119,7 @@ impl ToChalk for Ty {
119 }; 119 };
120 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner) 120 chalk_ir::TyKind::Dyn(bounded_ty).intern(&Interner)
121 } 121 }
122 Ty::Alias(AliasTy::Opaque(opaque_ty)) => { 122 TyKind::Alias(AliasTy::Opaque(opaque_ty)) => {
123 let opaque_ty_id = opaque_ty.opaque_ty_id.to_chalk(db); 123 let opaque_ty_id = opaque_ty.opaque_ty_id.to_chalk(db);
124 let substitution = opaque_ty.parameters.to_chalk(db); 124 let substitution = opaque_ty.parameters.to_chalk(db);
125 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy { 125 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(chalk_ir::OpaqueTy {
@@ -128,30 +128,30 @@ impl ToChalk for Ty {
128 })) 128 }))
129 .intern(&Interner) 129 .intern(&Interner)
130 } 130 }
131 Ty::Unknown => chalk_ir::TyKind::Error.intern(&Interner), 131 TyKind::Unknown => chalk_ir::TyKind::Error.intern(&Interner),
132 } 132 }
133 } 133 }
134 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { 134 fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self {
135 match chalk.data(&Interner).kind.clone() { 135 match chalk.data(&Interner).kind.clone() {
136 chalk_ir::TyKind::Error => Ty::Unknown, 136 chalk_ir::TyKind::Error => TyKind::Unknown,
137 chalk_ir::TyKind::Array(ty, _size) => Ty::Array(Substs::single(from_chalk(db, ty))), 137 chalk_ir::TyKind::Array(ty, _size) => TyKind::Array(Substs::single(from_chalk(db, ty))),
138 chalk_ir::TyKind::Placeholder(idx) => { 138 chalk_ir::TyKind::Placeholder(idx) => {
139 assert_eq!(idx.ui, UniverseIndex::ROOT); 139 assert_eq!(idx.ui, UniverseIndex::ROOT);
140 let interned_id = crate::db::GlobalTypeParamId::from_intern_id( 140 let interned_id = crate::db::GlobalTypeParamId::from_intern_id(
141 crate::salsa::InternId::from(idx.idx), 141 crate::salsa::InternId::from(idx.idx),
142 ); 142 );
143 Ty::Placeholder(db.lookup_intern_type_param_id(interned_id)) 143 TyKind::Placeholder(db.lookup_intern_type_param_id(interned_id))
144 } 144 }
145 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { 145 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => {
146 let associated_ty = 146 let associated_ty =
147 from_chalk::<TypeAliasAsAssocType, _>(db, proj.associated_ty_id).0; 147 from_chalk::<TypeAliasAsAssocType, _>(db, proj.associated_ty_id).0;
148 let parameters = from_chalk(db, proj.substitution); 148 let parameters = from_chalk(db, proj.substitution);
149 Ty::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters })) 149 TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty, parameters }))
150 } 150 }
151 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { 151 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => {
152 let impl_trait_id = from_chalk(db, opaque_ty.opaque_ty_id); 152 let impl_trait_id = from_chalk(db, opaque_ty.opaque_ty_id);
153 let parameters = from_chalk(db, opaque_ty.substitution); 153 let parameters = from_chalk(db, opaque_ty.substitution);
154 Ty::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id: impl_trait_id, parameters })) 154 TyKind::Alias(AliasTy::Opaque(OpaqueTy { opaque_ty_id: impl_trait_id, parameters }))
155 } 155 }
156 chalk_ir::TyKind::Function(chalk_ir::FnPointer { 156 chalk_ir::TyKind::Function(chalk_ir::FnPointer {
157 num_binders, 157 num_binders,
@@ -164,14 +164,14 @@ impl ToChalk for Ty {
164 db, 164 db,
165 substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), 165 substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"),
166 ); 166 );
167 Ty::Function(FnPointer { 167 TyKind::Function(FnPointer {
168 num_args: (substs.len() - 1), 168 num_args: (substs.len() - 1),
169 sig: FnSig { variadic }, 169 sig: FnSig { variadic },
170 substs, 170 substs,
171 }) 171 })
172 } 172 }
173 chalk_ir::TyKind::BoundVar(idx) => Ty::BoundVar(idx), 173 chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx),
174 chalk_ir::TyKind::InferenceVar(_iv, _kind) => Ty::Unknown, 174 chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Unknown,
175 chalk_ir::TyKind::Dyn(where_clauses) => { 175 chalk_ir::TyKind::Dyn(where_clauses) => {
176 assert_eq!(where_clauses.bounds.binders.len(&Interner), 1); 176 assert_eq!(where_clauses.bounds.binders.len(&Interner), 1);
177 let predicates = where_clauses 177 let predicates = where_clauses
@@ -180,49 +180,50 @@ impl ToChalk for Ty {
180 .iter(&Interner) 180 .iter(&Interner)
181 .map(|c| from_chalk(db, c.clone())) 181 .map(|c| from_chalk(db, c.clone()))
182 .collect(); 182 .collect();
183 Ty::Dyn(predicates) 183 TyKind::Dyn(predicates)
184 } 184 }
185 185
186 chalk_ir::TyKind::Adt(adt_id, subst) => Ty::Adt(adt_id, from_chalk(db, subst)), 186 chalk_ir::TyKind::Adt(adt_id, subst) => TyKind::Adt(adt_id, from_chalk(db, subst)),
187 chalk_ir::TyKind::AssociatedType(type_id, subst) => Ty::AssociatedType( 187 chalk_ir::TyKind::AssociatedType(type_id, subst) => TyKind::AssociatedType(
188 from_chalk::<TypeAliasAsAssocType, _>(db, type_id).0, 188 from_chalk::<TypeAliasAsAssocType, _>(db, type_id).0,
189 from_chalk(db, subst), 189 from_chalk(db, subst),
190 ), 190 ),
191 191
192 chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => { 192 chalk_ir::TyKind::OpaqueType(opaque_type_id, subst) => {
193 Ty::OpaqueType(from_chalk(db, opaque_type_id), from_chalk(db, subst)) 193 TyKind::OpaqueType(from_chalk(db, opaque_type_id), from_chalk(db, subst))
194 } 194 }
195 195
196 chalk_ir::TyKind::Scalar(scalar) => Ty::Scalar(scalar), 196 chalk_ir::TyKind::Scalar(scalar) => TyKind::Scalar(scalar),
197 chalk_ir::TyKind::Tuple(cardinality, subst) => { 197 chalk_ir::TyKind::Tuple(cardinality, subst) => {
198 Ty::Tuple(cardinality, from_chalk(db, subst)) 198 TyKind::Tuple(cardinality, from_chalk(db, subst))
199 } 199 }
200 chalk_ir::TyKind::Raw(mutability, ty) => { 200 chalk_ir::TyKind::Raw(mutability, ty) => {
201 Ty::Raw(mutability, Substs::single(from_chalk(db, ty))) 201 TyKind::Raw(mutability, Substs::single(from_chalk(db, ty)))
202 } 202 }
203 chalk_ir::TyKind::Slice(ty) => Ty::Slice(Substs::single(from_chalk(db, ty))), 203 chalk_ir::TyKind::Slice(ty) => TyKind::Slice(Substs::single(from_chalk(db, ty))),
204 chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => { 204 chalk_ir::TyKind::Ref(mutability, _lifetime, ty) => {
205 Ty::Ref(mutability, Substs::single(from_chalk(db, ty))) 205 TyKind::Ref(mutability, Substs::single(from_chalk(db, ty)))
206 } 206 }
207 chalk_ir::TyKind::Str => Ty::Str, 207 chalk_ir::TyKind::Str => TyKind::Str,
208 chalk_ir::TyKind::Never => Ty::Never, 208 chalk_ir::TyKind::Never => TyKind::Never,
209 209
210 chalk_ir::TyKind::FnDef(fn_def_id, subst) => { 210 chalk_ir::TyKind::FnDef(fn_def_id, subst) => {
211 Ty::FnDef(from_chalk(db, fn_def_id), from_chalk(db, subst)) 211 TyKind::FnDef(from_chalk(db, fn_def_id), from_chalk(db, subst))
212 } 212 }
213 213
214 chalk_ir::TyKind::Closure(id, subst) => { 214 chalk_ir::TyKind::Closure(id, subst) => {
215 let id: crate::db::ClosureId = id.into(); 215 let id: crate::db::ClosureId = id.into();
216 let (def, expr) = db.lookup_intern_closure(id); 216 let (def, expr) = db.lookup_intern_closure(id);
217 Ty::Closure(def, expr, from_chalk(db, subst)) 217 TyKind::Closure(def, expr, from_chalk(db, subst))
218 } 218 }
219 219
220 chalk_ir::TyKind::Foreign(foreign_def_id) => { 220 chalk_ir::TyKind::Foreign(foreign_def_id) => {
221 Ty::ForeignType(from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0) 221 TyKind::ForeignType(from_chalk::<TypeAliasAsForeignType, _>(db, foreign_def_id).0)
222 } 222 }
223 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME 223 chalk_ir::TyKind::Generator(_, _) => unimplemented!(), // FIXME
224 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME 224 chalk_ir::TyKind::GeneratorWitness(_, _) => unimplemented!(), // FIXME
225 } 225 }
226 .intern(&Interner)
226 } 227 }
227} 228}
228 229