From 0e995adcf690778739fe94fb94ae317d42b4e51b Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 28 Feb 2021 20:39:43 +0100 Subject: Turn Ty::Tuple variant into a tuple-variant --- crates/hir_ty/src/infer/expr.rs | 8 ++++---- crates/hir_ty/src/infer/pat.rs | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 2369c9bef..13240f790 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -82,7 +82,7 @@ impl<'a> InferenceContext<'a> { arg_tys.push(arg); } let parameters = param_builder.build(); - let arg_ty = Ty::Tuple { cardinality: num_args as u16, substs: parameters }; + let arg_ty = Ty::Tuple(num_args, parameters); let substs = Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); @@ -424,7 +424,7 @@ impl<'a> InferenceContext<'a> { }, ) .find_map(|derefed_ty| match canonicalized.decanonicalize_ty(derefed_ty.value) { - Ty::Tuple { substs, .. } => { + Ty::Tuple(_, substs) => { name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) } Ty::Adt(AdtId::StructId(s), parameters) => { @@ -635,7 +635,7 @@ impl<'a> InferenceContext<'a> { } Expr::Tuple { exprs } => { let mut tys = match &expected.ty { - Ty::Tuple { substs, .. } => substs + Ty::Tuple(_, substs) => substs .iter() .cloned() .chain(repeat_with(|| self.table.new_type_var())) @@ -648,7 +648,7 @@ impl<'a> InferenceContext<'a> { self.infer_expr_coerce(*expr, &Expectation::has_type(ty.clone())); } - Ty::Tuple { cardinality: tys.len() as u16, substs: Substs(tys.into()) } + Ty::Tuple(tys.len(), Substs(tys.into())) } Expr::Array(array) => { let elem_ty = match &expected.ty { diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index e96e08c3c..a318e47f3 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -138,7 +138,7 @@ impl<'a> InferenceContext<'a> { inner_tys.extend(expectations_iter.by_ref().take(n_uncovered_patterns).cloned()); inner_tys.extend(post.iter().zip(expectations_iter).map(infer_pat)); - Ty::Tuple { cardinality: inner_tys.len() as u16, substs: Substs(inner_tys.into()) } + Ty::Tuple(inner_tys.len(), Substs(inner_tys.into())) } Pat::Or(ref pats) => { if let Some((first_pat, rest)) = pats.split_first() { -- cgit v1.2.3