aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer/expr.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer/expr.rs')
-rw-r--r--crates/hir_ty/src/infer/expr.rs13
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);