aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ty/infer.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-05-04 18:07:25 +0100
committerFlorian Diebold <[email protected]>2019-05-04 18:11:21 +0100
commita4eb1a546c7623f65823c5e249cd3c6d8c90fd8c (patch)
tree0942d7a4976bb444031d044beb1ea786adabcaeb /crates/ra_hir/src/ty/infer.rs
parent19fbd919986e99287168f40aa11003a11aa43d3a (diff)
Differentiate Tuple / FnPtr type constructors by cardinality
This is necessary because Chalk (reasonably) expects each 'struct' to know how many type parameters it takes.
Diffstat (limited to 'crates/ra_hir/src/ty/infer.rs')
-rw-r--r--crates/ra_hir/src/ty/infer.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/crates/ra_hir/src/ty/infer.rs b/crates/ra_hir/src/ty/infer.rs
index cc74c6322..edce1afe7 100644
--- a/crates/ra_hir/src/ty/infer.rs
+++ b/crates/ra_hir/src/ty/infer.rs
@@ -739,14 +739,14 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
739 }; 739 };
740 let expectations_iter = expectations.iter().chain(repeat(&Ty::Unknown)); 740 let expectations_iter = expectations.iter().chain(repeat(&Ty::Unknown));
741 741
742 let inner_tys = args 742 let inner_tys: Substs = args
743 .iter() 743 .iter()
744 .zip(expectations_iter) 744 .zip(expectations_iter)
745 .map(|(&pat, ty)| self.infer_pat(pat, ty, default_bm)) 745 .map(|(&pat, ty)| self.infer_pat(pat, ty, default_bm))
746 .collect::<Vec<_>>() 746 .collect::<Vec<_>>()
747 .into(); 747 .into();
748 748
749 Ty::apply(TypeCtor::Tuple, Substs(inner_tys)) 749 Ty::apply(TypeCtor::Tuple { cardinality: inner_tys.len() as u16 }, inner_tys)
750 } 750 }
751 Pat::Ref { pat, mutability } => { 751 Pat::Ref { pat, mutability } => {
752 let expectation = match expected.as_reference() { 752 let expectation = match expected.as_reference() {
@@ -1073,7 +1073,7 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1073 .autoderef(self.db) 1073 .autoderef(self.db)
1074 .find_map(|derefed_ty| match derefed_ty { 1074 .find_map(|derefed_ty| match derefed_ty {
1075 Ty::Apply(a_ty) => match a_ty.ctor { 1075 Ty::Apply(a_ty) => match a_ty.ctor {
1076 TypeCtor::Tuple => { 1076 TypeCtor::Tuple { .. } => {
1077 let i = name.to_string().parse::<usize>().ok(); 1077 let i = name.to_string().parse::<usize>().ok();
1078 i.and_then(|i| a_ty.parameters.0.get(i).cloned()) 1078 i.and_then(|i| a_ty.parameters.0.get(i).cloned())
1079 } 1079 }
@@ -1184,7 +1184,10 @@ impl<'a, D: HirDatabase> InferenceContext<'a, D> {
1184 ty_vec.push(self.infer_expr(*arg, &Expectation::none())); 1184 ty_vec.push(self.infer_expr(*arg, &Expectation::none()));
1185 } 1185 }
1186 1186
1187 Ty::apply(TypeCtor::Tuple, Substs(ty_vec.into())) 1187 Ty::apply(
1188 TypeCtor::Tuple { cardinality: ty_vec.len() as u16 },
1189 Substs(ty_vec.into()),
1190 )
1188 } 1191 }
1189 Expr::Array(array) => { 1192 Expr::Array(array) => {
1190 let elem_ty = match &expected.ty { 1193 let elem_ty = match &expected.ty {