diff options
Diffstat (limited to 'crates/hir_ty/src/traits')
-rw-r--r-- | crates/hir_ty/src/traits/chalk.rs | 5 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 28 |
2 files changed, 14 insertions, 19 deletions
diff --git a/crates/hir_ty/src/traits/chalk.rs b/crates/hir_ty/src/traits/chalk.rs index c53e327da..3f5f5091f 100644 --- a/crates/hir_ty/src/traits/chalk.rs +++ b/crates/hir_ty/src/traits/chalk.rs | |||
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | display::HirDisplay, | 19 | display::HirDisplay, |
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, DebruijnIndex, FnSig, GenericPredicate, ProjectionPredicate, | 22 | BoundVar, CallableDefId, CallableSig, DebruijnIndex, GenericPredicate, ProjectionPredicate, |
23 | ProjectionTy, Substs, TraitRef, Ty, | 23 | ProjectionTy, Substs, TraitRef, Ty, |
24 | }; | 24 | }; |
25 | use mapping::{ | 25 | use mapping::{ |
@@ -286,9 +286,8 @@ impl<'a> chalk_solve::RustIrDatabase<Interner> for ChalkContext<'a> { | |||
286 | ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> { | 286 | ) -> chalk_ir::Binders<rust_ir::FnDefInputsAndOutputDatum<Interner>> { |
287 | let sig_ty: Ty = | 287 | let sig_ty: Ty = |
288 | from_chalk(self.db, substs.at(&Interner, 0).assert_ty_ref(&Interner).clone()); | 288 | from_chalk(self.db, substs.at(&Interner, 0).assert_ty_ref(&Interner).clone()); |
289 | let sig = FnSig::from_fn_ptr_substs( | 289 | let sig = CallableSig::from_substs( |
290 | &sig_ty.substs().expect("first closure param should be fn ptr"), | 290 | &sig_ty.substs().expect("first closure param should be fn ptr"), |
291 | false, | ||
292 | ); | 291 | ); |
293 | let io = rust_ir::FnDefInputsAndOutputDatum { | 292 | let io = rust_ir::FnDefInputsAndOutputDatum { |
294 | argument_types: sig.params().iter().map(|ty| ty.clone().to_chalk(self.db)).collect(), | 293 | argument_types: sig.params().iter().map(|ty| ty.clone().to_chalk(self.db)).collect(), |
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) => { |