diff options
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/display.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 8 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 16 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 4 |
7 files changed, 18 insertions, 20 deletions
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index cd9dcf6c0..666bb1f9d 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -330,7 +330,7 @@ impl HirDisplay for Ty { | |||
330 | write!(f, "{}", ty_display)?; | 330 | write!(f, "{}", ty_display)?; |
331 | } | 331 | } |
332 | } | 332 | } |
333 | Ty::Tuple { substs, .. } => { | 333 | Ty::Tuple(_, substs) => { |
334 | if substs.len() == 1 { | 334 | if substs.len() == 1 { |
335 | write!(f, "(")?; | 335 | write!(f, "(")?; |
336 | substs[0].hir_fmt(f)?; | 336 | substs[0].hir_fmt(f)?; |
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> { | |||
82 | arg_tys.push(arg); | 82 | arg_tys.push(arg); |
83 | } | 83 | } |
84 | let parameters = param_builder.build(); | 84 | let parameters = param_builder.build(); |
85 | let arg_ty = Ty::Tuple { cardinality: num_args as u16, substs: parameters }; | 85 | let arg_ty = Ty::Tuple(num_args, parameters); |
86 | let substs = | 86 | let substs = |
87 | Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); | 87 | Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); |
88 | 88 | ||
@@ -424,7 +424,7 @@ impl<'a> InferenceContext<'a> { | |||
424 | }, | 424 | }, |
425 | ) | 425 | ) |
426 | .find_map(|derefed_ty| match canonicalized.decanonicalize_ty(derefed_ty.value) { | 426 | .find_map(|derefed_ty| match canonicalized.decanonicalize_ty(derefed_ty.value) { |
427 | Ty::Tuple { substs, .. } => { | 427 | Ty::Tuple(_, substs) => { |
428 | name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) | 428 | name.as_tuple_index().and_then(|idx| substs.0.get(idx).cloned()) |
429 | } | 429 | } |
430 | Ty::Adt(AdtId::StructId(s), parameters) => { | 430 | Ty::Adt(AdtId::StructId(s), parameters) => { |
@@ -635,7 +635,7 @@ impl<'a> InferenceContext<'a> { | |||
635 | } | 635 | } |
636 | Expr::Tuple { exprs } => { | 636 | Expr::Tuple { exprs } => { |
637 | let mut tys = match &expected.ty { | 637 | let mut tys = match &expected.ty { |
638 | Ty::Tuple { substs, .. } => substs | 638 | Ty::Tuple(_, substs) => substs |
639 | .iter() | 639 | .iter() |
640 | .cloned() | 640 | .cloned() |
641 | .chain(repeat_with(|| self.table.new_type_var())) | 641 | .chain(repeat_with(|| self.table.new_type_var())) |
@@ -648,7 +648,7 @@ impl<'a> InferenceContext<'a> { | |||
648 | self.infer_expr_coerce(*expr, &Expectation::has_type(ty.clone())); | 648 | self.infer_expr_coerce(*expr, &Expectation::has_type(ty.clone())); |
649 | } | 649 | } |
650 | 650 | ||
651 | Ty::Tuple { cardinality: tys.len() as u16, substs: Substs(tys.into()) } | 651 | Ty::Tuple(tys.len(), Substs(tys.into())) |
652 | } | 652 | } |
653 | Expr::Array(array) => { | 653 | Expr::Array(array) => { |
654 | let elem_ty = match &expected.ty { | 654 | 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> { | |||
138 | inner_tys.extend(expectations_iter.by_ref().take(n_uncovered_patterns).cloned()); | 138 | inner_tys.extend(expectations_iter.by_ref().take(n_uncovered_patterns).cloned()); |
139 | inner_tys.extend(post.iter().zip(expectations_iter).map(infer_pat)); | 139 | inner_tys.extend(post.iter().zip(expectations_iter).map(infer_pat)); |
140 | 140 | ||
141 | Ty::Tuple { cardinality: inner_tys.len() as u16, substs: Substs(inner_tys.into()) } | 141 | Ty::Tuple(inner_tys.len(), Substs(inner_tys.into())) |
142 | } | 142 | } |
143 | Pat::Or(ref pats) => { | 143 | Pat::Or(ref pats) => { |
144 | if let Some((first_pat, rest)) = pats.split_first() { | 144 | if let Some((first_pat, rest)) = pats.split_first() { |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 117d69f01..3d134453f 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -120,7 +120,7 @@ pub enum Ty { | |||
120 | Scalar(Scalar), | 120 | Scalar(Scalar), |
121 | 121 | ||
122 | /// A tuple type. For example, `(i32, bool)`. | 122 | /// A tuple type. For example, `(i32, bool)`. |
123 | Tuple { cardinality: u16, substs: Substs }, | 123 | Tuple(usize, Substs), |
124 | 124 | ||
125 | /// An array with the given length. Written as `[T; n]`. | 125 | /// An array with the given length. Written as `[T; n]`. |
126 | Array(Substs), | 126 | Array(Substs), |
@@ -582,7 +582,7 @@ impl TypeWalk for FnSig { | |||
582 | 582 | ||
583 | impl Ty { | 583 | impl Ty { |
584 | pub fn unit() -> Self { | 584 | pub fn unit() -> Self { |
585 | Ty::Tuple { cardinality: 0, substs: Substs::empty() } | 585 | Ty::Tuple(0, Substs::empty()) |
586 | } | 586 | } |
587 | 587 | ||
588 | pub fn fn_ptr(sig: FnSig) -> Self { | 588 | pub fn fn_ptr(sig: FnSig) -> Self { |
@@ -642,7 +642,7 @@ impl Ty { | |||
642 | 642 | ||
643 | pub fn as_tuple(&self) -> Option<&Substs> { | 643 | pub fn as_tuple(&self) -> Option<&Substs> { |
644 | match self { | 644 | match self { |
645 | Ty::Tuple { substs: parameters, .. } => Some(parameters), | 645 | Ty::Tuple(_, substs) => Some(substs), |
646 | _ => None, | 646 | _ => None, |
647 | } | 647 | } |
648 | } | 648 | } |
@@ -684,9 +684,7 @@ impl Ty { | |||
684 | Ty::FnPtr { num_args, is_varargs, .. }, | 684 | Ty::FnPtr { num_args, is_varargs, .. }, |
685 | Ty::FnPtr { num_args: num_args2, is_varargs: is_varargs2, .. }, | 685 | Ty::FnPtr { num_args: num_args2, is_varargs: is_varargs2, .. }, |
686 | ) => num_args == num_args2 && is_varargs == is_varargs2, | 686 | ) => num_args == num_args2 && is_varargs == is_varargs2, |
687 | (Ty::Tuple { cardinality, .. }, Ty::Tuple { cardinality: cardinality2, .. }) => { | 687 | (Ty::Tuple(cardinality, _), Ty::Tuple(cardinality2, _)) => cardinality == cardinality2, |
688 | cardinality == cardinality2 | ||
689 | } | ||
690 | (Ty::Str, Ty::Str) | (Ty::Never, Ty::Never) => true, | 688 | (Ty::Str, Ty::Str) | (Ty::Never, Ty::Never) => true, |
691 | (Ty::Scalar(scalar), Ty::Scalar(scalar2)) => scalar == scalar2, | 689 | (Ty::Scalar(scalar), Ty::Scalar(scalar2)) => scalar == scalar2, |
692 | _ => false, | 690 | _ => false, |
@@ -754,7 +752,7 @@ impl Ty { | |||
754 | | Ty::Ref(_, substs) | 752 | | Ty::Ref(_, substs) |
755 | | Ty::FnDef(_, substs) | 753 | | Ty::FnDef(_, substs) |
756 | | Ty::FnPtr { substs, .. } | 754 | | Ty::FnPtr { substs, .. } |
757 | | Ty::Tuple { substs, .. } | 755 | | Ty::Tuple(_, substs) |
758 | | Ty::OpaqueType(_, substs) | 756 | | Ty::OpaqueType(_, substs) |
759 | | Ty::AssociatedType(_, substs) | 757 | | Ty::AssociatedType(_, substs) |
760 | | Ty::ForeignType(_, substs) | 758 | | Ty::ForeignType(_, substs) |
@@ -778,7 +776,7 @@ impl Ty { | |||
778 | | Ty::Ref(_, substs) | 776 | | Ty::Ref(_, substs) |
779 | | Ty::FnDef(_, substs) | 777 | | Ty::FnDef(_, substs) |
780 | | Ty::FnPtr { substs, .. } | 778 | | Ty::FnPtr { substs, .. } |
781 | | Ty::Tuple { substs, .. } | 779 | | Ty::Tuple(_, substs) |
782 | | Ty::OpaqueType(_, substs) | 780 | | Ty::OpaqueType(_, substs) |
783 | | Ty::AssociatedType(_, substs) | 781 | | Ty::AssociatedType(_, substs) |
784 | | Ty::ForeignType(_, substs) | 782 | | Ty::ForeignType(_, substs) |
@@ -796,7 +794,7 @@ impl Ty { | |||
796 | | Ty::Ref(_, substs) | 794 | | Ty::Ref(_, substs) |
797 | | Ty::FnDef(_, substs) | 795 | | Ty::FnDef(_, substs) |
798 | | Ty::FnPtr { substs, .. } | 796 | | Ty::FnPtr { substs, .. } |
799 | | Ty::Tuple { substs, .. } | 797 | | Ty::Tuple(_, substs) |
800 | | Ty::OpaqueType(_, substs) | 798 | | Ty::OpaqueType(_, substs) |
801 | | Ty::AssociatedType(_, substs) | 799 | | Ty::AssociatedType(_, substs) |
802 | | Ty::ForeignType(_, substs) | 800 | | Ty::ForeignType(_, substs) |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 6b919a09e..8295f4c31 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -148,7 +148,7 @@ impl Ty { | |||
148 | TypeRef::Never => Ty::Never, | 148 | TypeRef::Never => Ty::Never, |
149 | TypeRef::Tuple(inner) => { | 149 | TypeRef::Tuple(inner) => { |
150 | let inner_tys: Arc<[Ty]> = inner.iter().map(|tr| Ty::from_hir(ctx, tr)).collect(); | 150 | let inner_tys: Arc<[Ty]> = inner.iter().map(|tr| Ty::from_hir(ctx, tr)).collect(); |
151 | Ty::Tuple { cardinality: inner_tys.len() as u16, substs: Substs(inner_tys) } | 151 | Ty::Tuple(inner_tys.len(), Substs(inner_tys)) |
152 | } | 152 | } |
153 | TypeRef::Path(path) => { | 153 | TypeRef::Path(path) => { |
154 | let (ty, res_) = Ty::from_hir_path(ctx, path); | 154 | let (ty, res_) = Ty::from_hir_path(ctx, path); |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 087b67935..422e61f0a 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -33,7 +33,7 @@ pub enum TyFingerprint { | |||
33 | Scalar(Scalar), | 33 | Scalar(Scalar), |
34 | Adt(AdtId), | 34 | Adt(AdtId), |
35 | Dyn(TraitId), | 35 | Dyn(TraitId), |
36 | Tuple { cardinality: u16 }, | 36 | Tuple(usize), |
37 | ForeignType(TypeAliasId), | 37 | ForeignType(TypeAliasId), |
38 | FnPtr { num_args: u16, is_varargs: bool }, | 38 | FnPtr { num_args: u16, is_varargs: bool }, |
39 | } | 39 | } |
@@ -50,7 +50,7 @@ impl TyFingerprint { | |||
50 | &Ty::Array(..) => TyFingerprint::Array, | 50 | &Ty::Array(..) => TyFingerprint::Array, |
51 | &Ty::Scalar(scalar) => TyFingerprint::Scalar(scalar), | 51 | &Ty::Scalar(scalar) => TyFingerprint::Scalar(scalar), |
52 | &Ty::Adt(adt, _) => TyFingerprint::Adt(adt), | 52 | &Ty::Adt(adt, _) => TyFingerprint::Adt(adt), |
53 | &Ty::Tuple { cardinality: u16, .. } => TyFingerprint::Tuple { cardinality: u16 }, | 53 | &Ty::Tuple(cardinality, _) => TyFingerprint::Tuple(cardinality), |
54 | &Ty::RawPtr(mutability, ..) => TyFingerprint::RawPtr(mutability), | 54 | &Ty::RawPtr(mutability, ..) => TyFingerprint::RawPtr(mutability), |
55 | &Ty::ForeignType(alias_id, ..) => TyFingerprint::ForeignType(alias_id), | 55 | &Ty::ForeignType(alias_id, ..) => TyFingerprint::ForeignType(alias_id), |
56 | &Ty::FnPtr { num_args, is_varargs, .. } => { | 56 | &Ty::FnPtr { num_args, is_varargs, .. } => { |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 297ddeabd..09e5a82b8 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -63,7 +63,7 @@ impl ToChalk for Ty { | |||
63 | 63 | ||
64 | Ty::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), | 64 | Ty::Scalar(scalar) => chalk_ir::TyKind::Scalar(scalar).intern(&Interner), |
65 | 65 | ||
66 | Ty::Tuple { cardinality, substs } => { | 66 | Ty::Tuple(cardinality, substs) => { |
67 | let substitution = substs.to_chalk(db); | 67 | let substitution = substs.to_chalk(db); |
68 | chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner) | 68 | chalk_ir::TyKind::Tuple(cardinality.into(), substitution).intern(&Interner) |
69 | } | 69 | } |
@@ -199,7 +199,7 @@ impl ToChalk for Ty { | |||
199 | 199 | ||
200 | chalk_ir::TyKind::Scalar(scalar) => Ty::Scalar(scalar), | 200 | chalk_ir::TyKind::Scalar(scalar) => Ty::Scalar(scalar), |
201 | chalk_ir::TyKind::Tuple(cardinality, subst) => { | 201 | chalk_ir::TyKind::Tuple(cardinality, subst) => { |
202 | Ty::Tuple { cardinality: cardinality as u16, substs: from_chalk(db, subst) } | 202 | Ty::Tuple(cardinality, from_chalk(db, subst)) |
203 | } | 203 | } |
204 | chalk_ir::TyKind::Raw(mutability, ty) => { | 204 | chalk_ir::TyKind::Raw(mutability, ty) => { |
205 | Ty::RawPtr(from_chalk(db, mutability), Substs::single(from_chalk(db, ty))) | 205 | Ty::RawPtr(from_chalk(db, mutability), Substs::single(from_chalk(db, ty))) |