aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/hir_ty/src/autoderef.rs5
-rw-r--r--crates/hir_ty/src/infer/expr.rs2
-rw-r--r--crates/hir_ty/src/lib.rs13
-rw-r--r--crates/hir_ty/src/lower.rs4
-rw-r--r--crates/hir_ty/src/traits/chalk/mapping.rs19
5 files changed, 22 insertions, 21 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs
index d5c2b9a20..56c6b92d4 100644
--- a/crates/hir_ty/src/autoderef.rs
+++ b/crates/hir_ty/src/autoderef.rs
@@ -84,7 +84,10 @@ fn deref_by_trait(
84 let projection = super::traits::ProjectionPredicate { 84 let projection = super::traits::ProjectionPredicate {
85 ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len())) 85 ty: TyKind::BoundVar(BoundVar::new(DebruijnIndex::INNERMOST, ty.value.kinds.len()))
86 .intern(&Interner), 86 .intern(&Interner),
87 projection_ty: super::ProjectionTy { associated_ty_id: to_assoc_type_id(target), substitution: parameters }, 87 projection_ty: super::ProjectionTy {
88 associated_ty_id: to_assoc_type_id(target),
89 substitution: parameters,
90 },
88 }; 91 };
89 92
90 let obligation = super::Obligation::Projection(projection); 93 let obligation = super::Obligation::Projection(projection);
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index b7870e771..55163c963 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -261,7 +261,7 @@ impl<'a> InferenceContext<'a> {
261 sig_tys.push(ret_ty.clone()); 261 sig_tys.push(ret_ty.clone());
262 let sig_ty = TyKind::Function(FnPointer { 262 let sig_ty = TyKind::Function(FnPointer {
263 num_args: sig_tys.len() - 1, 263 num_args: sig_tys.len() - 1,
264 sig: FnSig { variadic: false }, 264 sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false },
265 substs: Substs(sig_tys.clone().into()), 265 substs: Substs(sig_tys.clone().into()),
266 }) 266 })
267 .intern(&Interner); 267 .intern(&Interner);
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs
index ddcee2084..bc7a7369a 100644
--- a/crates/hir_ty/src/lib.rs
+++ b/crates/hir_ty/src/lib.rs
@@ -46,7 +46,7 @@ pub use lower::{
46}; 46};
47pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment}; 47pub use traits::{InEnvironment, Obligation, ProjectionPredicate, TraitEnvironment};
48 48
49pub use chalk_ir::{AdtId, BoundVar, DebruijnIndex, Mutability, Scalar, TyVariableKind}; 49pub use chalk_ir::{AdtId, BoundVar, DebruijnIndex, Mutability, Safety, Scalar, TyVariableKind};
50 50
51pub use crate::traits::chalk::Interner; 51pub use crate::traits::chalk::Interner;
52 52
@@ -105,10 +105,7 @@ impl TypeWalk for ProjectionTy {
105 } 105 }
106} 106}
107 107
108#[derive(Clone, Copy, PartialEq, Eq, Debug, Hash)] 108pub type FnSig = chalk_ir::FnSig<Interner>;
109pub struct FnSig {
110 pub variadic: bool,
111}
112 109
113#[derive(Clone, PartialEq, Eq, Debug, Hash)] 110#[derive(Clone, PartialEq, Eq, Debug, Hash)]
114pub struct FnPointer { 111pub struct FnPointer {
@@ -643,7 +640,7 @@ impl Ty {
643 pub fn fn_ptr(sig: CallableSig) -> Self { 640 pub fn fn_ptr(sig: CallableSig) -> Self {
644 TyKind::Function(FnPointer { 641 TyKind::Function(FnPointer {
645 num_args: sig.params().len(), 642 num_args: sig.params().len(),
646 sig: FnSig { variadic: sig.is_varargs }, 643 sig: FnSig { abi: (), safety: Safety::Safe, variadic: sig.is_varargs },
647 substs: Substs(sig.params_and_return), 644 substs: Substs(sig.params_and_return),
648 }) 645 })
649 .intern(&Interner) 646 .intern(&Interner)
@@ -945,7 +942,9 @@ impl Ty {
945 } 942 }
946 } 943 }
947 TyKind::Alias(AliasTy::Projection(projection_ty)) => { 944 TyKind::Alias(AliasTy::Projection(projection_ty)) => {
948 match from_assoc_type_id(projection_ty.associated_ty_id).lookup(db.upcast()).container 945 match from_assoc_type_id(projection_ty.associated_ty_id)
946 .lookup(db.upcast())
947 .container
949 { 948 {
950 AssocContainerId::TraitId(trait_id) => Some(trait_id), 949 AssocContainerId::TraitId(trait_id) => Some(trait_id),
951 _ => None, 950 _ => None,
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs
index 17eb29911..76b2124af 100644
--- a/crates/hir_ty/src/lower.rs
+++ b/crates/hir_ty/src/lower.rs
@@ -8,7 +8,7 @@
8use std::{iter, sync::Arc}; 8use std::{iter, sync::Arc};
9 9
10use base_db::CrateId; 10use base_db::CrateId;
11use chalk_ir::{cast::Cast, Mutability}; 11use chalk_ir::{cast::Cast, Mutability, Safety};
12use hir_def::{ 12use hir_def::{
13 adt::StructKind, 13 adt::StructKind,
14 builtin_type::BuiltinType, 14 builtin_type::BuiltinType,
@@ -181,7 +181,7 @@ impl<'a> TyLoweringContext<'a> {
181 let substs = Substs(params.iter().map(|tr| self.lower_ty(tr)).collect()); 181 let substs = Substs(params.iter().map(|tr| self.lower_ty(tr)).collect());
182 TyKind::Function(FnPointer { 182 TyKind::Function(FnPointer {
183 num_args: substs.len() - 1, 183 num_args: substs.len() - 1,
184 sig: FnSig { variadic: *is_varargs }, 184 sig: FnSig { abi: (), safety: Safety::Safe, variadic: *is_varargs },
185 substs, 185 substs,
186 }) 186 })
187 .intern(&Interner) 187 .intern(&Interner)
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs
index 68effbbf3..1a6fca611 100644
--- a/crates/hir_ty/src/traits/chalk/mapping.rs
+++ b/crates/hir_ty/src/traits/chalk/mapping.rs
@@ -14,7 +14,7 @@ use crate::{
14 from_assoc_type_id, 14 from_assoc_type_id,
15 primitive::UintTy, 15 primitive::UintTy,
16 traits::{Canonical, Obligation}, 16 traits::{Canonical, Obligation},
17 AliasTy, CallableDefId, FnPointer, FnSig, GenericPredicate, InEnvironment, OpaqueTy, 17 AliasTy, CallableDefId, FnPointer, GenericPredicate, InEnvironment, OpaqueTy,
18 ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty, 18 ProjectionPredicate, ProjectionTy, Scalar, Substs, TraitRef, Ty,
19}; 19};
20 20
@@ -27,11 +27,11 @@ impl ToChalk for Ty {
27 match self.0 { 27 match self.0 {
28 TyKind::Ref(m, parameters) => ref_to_chalk(db, m, parameters), 28 TyKind::Ref(m, parameters) => ref_to_chalk(db, m, parameters),
29 TyKind::Array(parameters) => array_to_chalk(db, parameters), 29 TyKind::Array(parameters) => array_to_chalk(db, parameters),
30 TyKind::Function(FnPointer { sig: FnSig { variadic }, substs, .. }) => { 30 TyKind::Function(FnPointer { sig, substs, .. }) => {
31 let substitution = chalk_ir::FnSubst(substs.to_chalk(db).shifted_in(&Interner)); 31 let substitution = chalk_ir::FnSubst(substs.to_chalk(db).shifted_in(&Interner));
32 chalk_ir::TyKind::Function(chalk_ir::FnPointer { 32 chalk_ir::TyKind::Function(chalk_ir::FnPointer {
33 num_binders: 0, 33 num_binders: 0,
34 sig: chalk_ir::FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic }, 34 sig,
35 substitution, 35 substitution,
36 }) 36 })
37 .intern(&Interner) 37 .intern(&Interner)
@@ -121,7 +121,10 @@ impl ToChalk for Ty {
121 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => { 121 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Projection(proj)) => {
122 let associated_ty = proj.associated_ty_id; 122 let associated_ty = proj.associated_ty_id;
123 let parameters = from_chalk(db, proj.substitution); 123 let parameters = from_chalk(db, proj.substitution);
124 TyKind::Alias(AliasTy::Projection(ProjectionTy { associated_ty_id: associated_ty, substitution: parameters })) 124 TyKind::Alias(AliasTy::Projection(ProjectionTy {
125 associated_ty_id: associated_ty,
126 substitution: parameters,
127 }))
125 } 128 }
126 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => { 129 chalk_ir::TyKind::Alias(chalk_ir::AliasTy::Opaque(opaque_ty)) => {
127 let opaque_ty_id = opaque_ty.opaque_ty_id; 130 let opaque_ty_id = opaque_ty.opaque_ty_id;
@@ -130,7 +133,7 @@ impl ToChalk for Ty {
130 } 133 }
131 chalk_ir::TyKind::Function(chalk_ir::FnPointer { 134 chalk_ir::TyKind::Function(chalk_ir::FnPointer {
132 num_binders, 135 num_binders,
133 sig: chalk_ir::FnSig { variadic, .. }, 136 sig,
134 substitution, 137 substitution,
135 .. 138 ..
136 }) => { 139 }) => {
@@ -139,11 +142,7 @@ impl ToChalk for Ty {
139 db, 142 db,
140 substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"), 143 substitution.0.shifted_out(&Interner).expect("fn ptr should have no binders"),
141 ); 144 );
142 TyKind::Function(FnPointer { 145 TyKind::Function(FnPointer { num_args: (substs.len() - 1), sig, substs })
143 num_args: (substs.len() - 1),
144 sig: FnSig { variadic },
145 substs,
146 })
147 } 146 }
148 chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx), 147 chalk_ir::TyKind::BoundVar(idx) => TyKind::BoundVar(idx),
149 chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Unknown, 148 chalk_ir::TyKind::InferenceVar(_iv, _kind) => TyKind::Unknown,