diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-06 09:52:02 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-06 09:52:02 +0100 |
commit | 047b5313013383fc4fafaef6d6d8d6a64549e3cb (patch) | |
tree | f4951c835dd6f4840ae02ba5c06d5da44aedae94 /crates/hir_ty/src/infer/expr.rs | |
parent | 4bc8a018302d53951ae855ba57d07095a16ef182 (diff) | |
parent | 08dc69599efb4961319c0118b789d3abb264b7fa (diff) |
Merge #8359
8359: Add Lifetime to TyKind::Ref and DynTy r=flodiebold a=Veykril
CC #8313
Co-authored-by: Lukas Wirth <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index ff564106b..796487d02 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -19,7 +19,7 @@ use crate::{ | |||
19 | lower::lower_to_chalk_mutability, | 19 | lower::lower_to_chalk_mutability, |
20 | method_resolution, op, | 20 | method_resolution, op, |
21 | primitive::{self, UintTy}, | 21 | primitive::{self, UintTy}, |
22 | to_chalk_trait_id, | 22 | static_lifetime, to_chalk_trait_id, |
23 | traits::{chalk::from_chalk, FnTrait}, | 23 | traits::{chalk::from_chalk, FnTrait}, |
24 | utils::{generics, variant_data, Generics}, | 24 | utils::{generics, variant_data, Generics}, |
25 | AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner, | 25 | AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner, |
@@ -527,7 +527,7 @@ impl<'a> InferenceContext<'a> { | |||
527 | let inner_ty = self.infer_expr_inner(*expr, &expectation); | 527 | let inner_ty = self.infer_expr_inner(*expr, &expectation); |
528 | match rawness { | 528 | match rawness { |
529 | Rawness::RawPtr => TyKind::Raw(mutability, inner_ty), | 529 | Rawness::RawPtr => TyKind::Raw(mutability, inner_ty), |
530 | Rawness::Ref => TyKind::Ref(mutability, inner_ty), | 530 | Rawness::Ref => TyKind::Ref(mutability, static_lifetime(), inner_ty), |
531 | } | 531 | } |
532 | .intern(&Interner) | 532 | .intern(&Interner) |
533 | } | 533 | } |
@@ -731,12 +731,13 @@ impl<'a> InferenceContext<'a> { | |||
731 | Expr::Literal(lit) => match lit { | 731 | Expr::Literal(lit) => match lit { |
732 | Literal::Bool(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner), | 732 | Literal::Bool(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner), |
733 | Literal::String(..) => { | 733 | Literal::String(..) => { |
734 | TyKind::Ref(Mutability::Not, TyKind::Str.intern(&Interner)).intern(&Interner) | 734 | TyKind::Ref(Mutability::Not, static_lifetime(), TyKind::Str.intern(&Interner)) |
735 | .intern(&Interner) | ||
735 | } | 736 | } |
736 | Literal::ByteString(..) => { | 737 | Literal::ByteString(..) => { |
737 | let byte_type = TyKind::Scalar(Scalar::Uint(UintTy::U8)).intern(&Interner); | 738 | let byte_type = TyKind::Scalar(Scalar::Uint(UintTy::U8)).intern(&Interner); |
738 | let array_type = TyKind::Array(byte_type).intern(&Interner); | 739 | let array_type = TyKind::Array(byte_type).intern(&Interner); |
739 | TyKind::Ref(Mutability::Not, array_type).intern(&Interner) | 740 | TyKind::Ref(Mutability::Not, static_lifetime(), array_type).intern(&Interner) |
740 | } | 741 | } |
741 | Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(&Interner), | 742 | Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(&Interner), |
742 | Literal::Int(_v, ty) => match ty { | 743 | Literal::Int(_v, ty) => match ty { |
@@ -872,7 +873,9 @@ impl<'a> InferenceContext<'a> { | |||
872 | // Apply autoref so the below unification works correctly | 873 | // Apply autoref so the below unification works correctly |
873 | // FIXME: return correct autorefs from lookup_method | 874 | // FIXME: return correct autorefs from lookup_method |
874 | let actual_receiver_ty = match expected_receiver_ty.as_reference() { | 875 | let actual_receiver_ty = match expected_receiver_ty.as_reference() { |
875 | Some((_, mutability)) => TyKind::Ref(mutability, derefed_receiver_ty).intern(&Interner), | 876 | Some((_, lifetime, mutability)) => { |
877 | TyKind::Ref(mutability, lifetime, derefed_receiver_ty).intern(&Interner) | ||
878 | } | ||
876 | _ => derefed_receiver_ty, | 879 | _ => derefed_receiver_ty, |
877 | }; | 880 | }; |
878 | self.unify(&expected_receiver_ty, &actual_receiver_ty); | 881 | self.unify(&expected_receiver_ty, &actual_receiver_ty); |