diff options
author | Florian Diebold <[email protected]> | 2021-03-14 16:40:55 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-03-14 19:21:05 +0000 |
commit | 42217738e0b121a8e5d48a9a55cb51ef6c98975f (patch) | |
tree | 63b3fc22a011ae0ee37a91cb19f5dcfe390507f1 /crates/hir_ty/src/infer/expr.rs | |
parent | af466f8542173002361eb134e66102908c7cd024 (diff) |
Don't use Substs for Ref/Raw/Array/Slice
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index e9ca2b86f..8c58a1b6c 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -504,8 +504,8 @@ impl<'a> InferenceContext<'a> { | |||
504 | }; | 504 | }; |
505 | let inner_ty = self.infer_expr_inner(*expr, &expectation); | 505 | let inner_ty = self.infer_expr_inner(*expr, &expectation); |
506 | match rawness { | 506 | match rawness { |
507 | Rawness::RawPtr => TyKind::Raw(mutability, Substs::single(inner_ty)), | 507 | Rawness::RawPtr => TyKind::Raw(mutability, inner_ty), |
508 | Rawness::Ref => TyKind::Ref(mutability, Substs::single(inner_ty)), | 508 | Rawness::Ref => TyKind::Ref(mutability, inner_ty), |
509 | } | 509 | } |
510 | .intern(&Interner) | 510 | .intern(&Interner) |
511 | } | 511 | } |
@@ -686,7 +686,7 @@ impl<'a> InferenceContext<'a> { | |||
686 | } | 686 | } |
687 | Expr::Array(array) => { | 687 | Expr::Array(array) => { |
688 | let elem_ty = match expected.ty.interned(&Interner) { | 688 | let elem_ty = match expected.ty.interned(&Interner) { |
689 | TyKind::Array(st) | TyKind::Slice(st) => st.as_single().clone(), | 689 | TyKind::Array(st) | TyKind::Slice(st) => st.clone(), |
690 | _ => self.table.new_type_var(), | 690 | _ => self.table.new_type_var(), |
691 | }; | 691 | }; |
692 | 692 | ||
@@ -710,18 +710,17 @@ impl<'a> InferenceContext<'a> { | |||
710 | } | 710 | } |
711 | } | 711 | } |
712 | 712 | ||
713 | TyKind::Array(Substs::single(elem_ty)).intern(&Interner) | 713 | TyKind::Array(elem_ty).intern(&Interner) |
714 | } | 714 | } |
715 | Expr::Literal(lit) => match lit { | 715 | Expr::Literal(lit) => match lit { |
716 | Literal::Bool(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner), | 716 | Literal::Bool(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner), |
717 | Literal::String(..) => { | 717 | Literal::String(..) => { |
718 | TyKind::Ref(Mutability::Not, Substs::single(TyKind::Str.intern(&Interner))) | 718 | TyKind::Ref(Mutability::Not, TyKind::Str.intern(&Interner)).intern(&Interner) |
719 | .intern(&Interner) | ||
720 | } | 719 | } |
721 | Literal::ByteString(..) => { | 720 | Literal::ByteString(..) => { |
722 | let byte_type = TyKind::Scalar(Scalar::Uint(UintTy::U8)).intern(&Interner); | 721 | let byte_type = TyKind::Scalar(Scalar::Uint(UintTy::U8)).intern(&Interner); |
723 | let array_type = TyKind::Array(Substs::single(byte_type)).intern(&Interner); | 722 | let array_type = TyKind::Array(byte_type).intern(&Interner); |
724 | TyKind::Ref(Mutability::Not, Substs::single(array_type)).intern(&Interner) | 723 | TyKind::Ref(Mutability::Not, array_type).intern(&Interner) |
725 | } | 724 | } |
726 | Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(&Interner), | 725 | Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(&Interner), |
727 | Literal::Int(_v, ty) => match ty { | 726 | Literal::Int(_v, ty) => match ty { |
@@ -855,9 +854,7 @@ impl<'a> InferenceContext<'a> { | |||
855 | // Apply autoref so the below unification works correctly | 854 | // Apply autoref so the below unification works correctly |
856 | // FIXME: return correct autorefs from lookup_method | 855 | // FIXME: return correct autorefs from lookup_method |
857 | let actual_receiver_ty = match expected_receiver_ty.as_reference() { | 856 | let actual_receiver_ty = match expected_receiver_ty.as_reference() { |
858 | Some((_, mutability)) => { | 857 | Some((_, mutability)) => TyKind::Ref(mutability, derefed_receiver_ty).intern(&Interner), |
859 | TyKind::Ref(mutability, Substs::single(derefed_receiver_ty)).intern(&Interner) | ||
860 | } | ||
861 | _ => derefed_receiver_ty, | 858 | _ => derefed_receiver_ty, |
862 | }; | 859 | }; |
863 | self.unify(&expected_receiver_ty, &actual_receiver_ty); | 860 | self.unify(&expected_receiver_ty, &actual_receiver_ty); |