diff options
author | Lukas Wirth <[email protected]> | 2021-04-06 10:45:41 +0100 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-04-06 10:45:41 +0100 |
commit | 9fbba7bc45ec6bea9468931d9d9fdd0141826f0a (patch) | |
tree | 266da1eafcd60457fa99cc422a415e27992c08d7 /crates/hir_ty/src/traits/chalk | |
parent | 047b5313013383fc4fafaef6d6d8d6a64549e3cb (diff) |
Add chalk_ir::Const to TyKind::Array
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 9267e32b5..cf73cb078 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -10,9 +10,10 @@ use base_db::salsa::InternKey; | |||
10 | use hir_def::{GenericDefId, TypeAliasId}; | 10 | use hir_def::{GenericDefId, TypeAliasId}; |
11 | 11 | ||
12 | use crate::{ | 12 | use crate::{ |
13 | chalk_ext::ProjectionTyExt, db::HirDatabase, primitive::UintTy, static_lifetime, AliasTy, | 13 | chalk_ext::ProjectionTyExt, db::HirDatabase, dummy_usize_const, static_lifetime, AliasTy, |
14 | CallableDefId, Canonical, DomainGoal, FnPointer, GenericArg, InEnvironment, Lifetime, OpaqueTy, | 14 | CallableDefId, Canonical, Const, DomainGoal, FnPointer, GenericArg, InEnvironment, Lifetime, |
15 | ProjectionTy, QuantifiedWhereClause, Scalar, Substitution, TraitRef, Ty, TypeWalk, WhereClause, | 15 | OpaqueTy, ProjectionTy, QuantifiedWhereClause, Substitution, TraitRef, Ty, TypeWalk, |
16 | WhereClause, | ||
16 | }; | 17 | }; |
17 | 18 | ||
18 | use super::interner::*; | 19 | use super::interner::*; |
@@ -23,7 +24,7 @@ impl ToChalk for Ty { | |||
23 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { | 24 | fn to_chalk(self, db: &dyn HirDatabase) -> chalk_ir::Ty<Interner> { |
24 | match self.into_inner() { | 25 | match self.into_inner() { |
25 | TyKind::Ref(m, lt, ty) => ref_to_chalk(db, m, lt, ty), | 26 | TyKind::Ref(m, lt, ty) => ref_to_chalk(db, m, lt, ty), |
26 | TyKind::Array(ty) => array_to_chalk(db, ty), | 27 | TyKind::Array(ty, size) => array_to_chalk(db, ty, size), |
27 | TyKind::Function(FnPointer { sig, substitution: substs, .. }) => { | 28 | TyKind::Function(FnPointer { sig, substitution: substs, .. }) => { |
28 | let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); | 29 | let substitution = chalk_ir::FnSubst(substs.0.to_chalk(db)); |
29 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { | 30 | chalk_ir::TyKind::Function(chalk_ir::FnPointer { |
@@ -110,7 +111,7 @@ impl ToChalk for Ty { | |||
110 | fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { | 111 | fn from_chalk(db: &dyn HirDatabase, chalk: chalk_ir::Ty<Interner>) -> Self { |
111 | match chalk.data(&Interner).kind.clone() { | 112 | match chalk.data(&Interner).kind.clone() { |
112 | chalk_ir::TyKind::Error => TyKind::Error, | 113 | chalk_ir::TyKind::Error => TyKind::Error, |
113 | chalk_ir::TyKind::Array(ty, _size) => TyKind::Array(from_chalk(db, ty)), | 114 | chalk_ir::TyKind::Array(ty, size) => TyKind::Array(from_chalk(db, ty), size), |
114 | chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx), | 115 | chalk_ir::TyKind::Placeholder(idx) => TyKind::Placeholder(idx), |
115 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { | 116 | chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { |
116 | let associated_ty = proj.associated_ty_id; | 117 | let associated_ty = proj.associated_ty_id; |
@@ -203,15 +204,9 @@ fn ref_to_chalk( | |||
203 | 204 | ||
204 | /// We currently don't model constants, but Chalk does. So, we have to insert a | 205 | /// We currently don't model constants, but Chalk does. So, we have to insert a |
205 | /// fake constant here, because Chalks built-in logic may expect it to be there. | 206 | /// fake constant here, because Chalks built-in logic may expect it to be there. |
206 | fn array_to_chalk(db: &dyn HirDatabase, ty: Ty) -> chalk_ir::Ty<Interner> { | 207 | fn array_to_chalk(db: &dyn HirDatabase, ty: Ty, _: Const) -> chalk_ir::Ty<Interner> { |
207 | let arg = ty.to_chalk(db); | 208 | let arg = ty.to_chalk(db); |
208 | let usize_ty = chalk_ir::TyKind::Scalar(Scalar::Uint(UintTy::Usize)).intern(&Interner); | 209 | chalk_ir::TyKind::Array(arg, dummy_usize_const()).intern(&Interner) |
209 | let const_ = chalk_ir::ConstData { | ||
210 | ty: usize_ty, | ||
211 | value: chalk_ir::ConstValue::Concrete(chalk_ir::ConcreteConst { interned: () }), | ||
212 | } | ||
213 | .intern(&Interner); | ||
214 | chalk_ir::TyKind::Array(arg, const_).intern(&Interner) | ||
215 | } | 210 | } |
216 | 211 | ||
217 | impl ToChalk for GenericArg { | 212 | impl ToChalk for GenericArg { |