diff options
Diffstat (limited to 'crates/hir_ty/src/traits/chalk')
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 28 |
1 files changed, 12 insertions, 16 deletions
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index c17c19638..60d74e21a 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -16,8 +16,8 @@ use crate::{ | |||
16 | db::HirDatabase, | 16 | db::HirDatabase, |
17 | primitive::UintTy, | 17 | primitive::UintTy, |
18 | traits::{Canonical, Obligation}, | 18 | traits::{Canonical, Obligation}, |
19 | CallableDefId, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, ProjectionPredicate, | 19 | CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, OpaqueTyId, |
20 | ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, TyKind, | 20 | ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitEnvironment, TraitRef, Ty, TyKind, |
21 | }; | 21 | }; |
22 | 22 | ||
23 | use super::interner::*; | 23 | use super::interner::*; |
@@ -29,15 +29,11 @@ impl ToChalk for Ty { | |||
29 | match self { | 29 | match self { |
30 | Ty::Ref(m, parameters) => ref_to_chalk(db, m, parameters), | 30 | Ty::Ref(m, parameters) => ref_to_chalk(db, m, parameters), |
31 | Ty::Array(parameters) => array_to_chalk(db, parameters), | 31 | Ty::Array(parameters) => array_to_chalk(db, parameters), |
32 | Ty::FnPtr { num_args: _, is_varargs, substs } => { | 32 | Ty::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, |
36 | sig: chalk_ir::FnSig { | 36 | sig: chalk_ir::FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic }, |
37 | abi: (), | ||
38 | safety: chalk_ir::Safety::Safe, | ||
39 | variadic: is_varargs, | ||
40 | }, | ||
41 | substitution, | 37 | substitution, |
42 | }) | 38 | }) |
43 | .intern(&Interner) | 39 | .intern(&Interner) |
@@ -82,7 +78,7 @@ impl ToChalk for Ty { | |||
82 | } | 78 | } |
83 | Ty::Never => chalk_ir::TyKind::Never.intern(&Interner), | 79 | Ty::Never => chalk_ir::TyKind::Never.intern(&Interner), |
84 | 80 | ||
85 | Ty::Closure { def, expr, substs } => { | 81 | Ty::Closure(def, expr, substs) => { |
86 | let closure_id = db.intern_closure((def, expr)); | 82 | let closure_id = db.intern_closure((def, expr)); |
87 | let substitution = substs.to_chalk(db); | 83 | let substitution = substs.to_chalk(db); |
88 | chalk_ir::TyKind::Closure(closure_id.into(), substitution).intern(&Interner) | 84 | chalk_ir::TyKind::Closure(closure_id.into(), substitution).intern(&Interner) |
@@ -164,15 +160,15 @@ impl ToChalk for Ty { | |||
164 | .. | 160 | .. |
165 | }) => { | 161 | }) => { |
166 | assert_eq!(num_binders, 0); | 162 | assert_eq!(num_binders, 0); |
167 | let parameters: Substs = from_chalk( | 163 | let substs: Substs = from_chalk( |
168 | db, | 164 | db, |
169 | 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"), |
170 | ); | 166 | ); |
171 | Ty::FnPtr { | 167 | Ty::Function(FnPointer { |
172 | num_args: (parameters.len() - 1) as u16, | 168 | num_args: (substs.len() - 1), |
173 | is_varargs: variadic, | 169 | sig: FnSig { variadic }, |
174 | substs: parameters, | 170 | substs, |
175 | } | 171 | }) |
176 | } | 172 | } |
177 | chalk_ir::TyKind::BoundVar(idx) => Ty::Bound(idx), | 173 | chalk_ir::TyKind::BoundVar(idx) => Ty::Bound(idx), |
178 | chalk_ir::TyKind::InferenceVar(_iv, _kind) => Ty::Unknown, | 174 | chalk_ir::TyKind::InferenceVar(_iv, _kind) => Ty::Unknown, |
@@ -218,7 +214,7 @@ impl ToChalk for Ty { | |||
218 | chalk_ir::TyKind::Closure(id, subst) => { | 214 | chalk_ir::TyKind::Closure(id, subst) => { |
219 | let id: crate::db::ClosureId = id.into(); | 215 | let id: crate::db::ClosureId = id.into(); |
220 | let (def, expr) = db.lookup_intern_closure(id); | 216 | let (def, expr) = db.lookup_intern_closure(id); |
221 | Ty::Closure { def, expr, substs: from_chalk(db, subst) } | 217 | Ty::Closure(def, expr, from_chalk(db, subst)) |
222 | } | 218 | } |
223 | 219 | ||
224 | chalk_ir::TyKind::Foreign(foreign_def_id) => { | 220 | chalk_ir::TyKind::Foreign(foreign_def_id) => { |