mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Add Lifetime to TyKind::Ref
This commit is contained in:
parent
4bc8a01830
commit
96756f1b1d
13 changed files with 74 additions and 43 deletions
|
@ -23,7 +23,7 @@ use crate::{
|
|||
traits::{chalk::from_chalk, FnTrait},
|
||||
utils::{generics, variant_data, Generics},
|
||||
AdtId, Binders, CallableDefId, FnPointer, FnSig, FnSubst, InEnvironment, Interner,
|
||||
ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyKind, TypeWalk,
|
||||
LifetimeData, ProjectionTyExt, Rawness, Scalar, Substitution, TraitRef, Ty, TyBuilder, TyKind,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
@ -527,7 +527,9 @@ impl<'a> InferenceContext<'a> {
|
|||
let inner_ty = self.infer_expr_inner(*expr, &expectation);
|
||||
match rawness {
|
||||
Rawness::RawPtr => TyKind::Raw(mutability, inner_ty),
|
||||
Rawness::Ref => TyKind::Ref(mutability, inner_ty),
|
||||
Rawness::Ref => {
|
||||
TyKind::Ref(mutability, LifetimeData::Static.intern(&Interner), inner_ty)
|
||||
}
|
||||
}
|
||||
.intern(&Interner)
|
||||
}
|
||||
|
@ -730,13 +732,17 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
Expr::Literal(lit) => match lit {
|
||||
Literal::Bool(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner),
|
||||
Literal::String(..) => {
|
||||
TyKind::Ref(Mutability::Not, TyKind::Str.intern(&Interner)).intern(&Interner)
|
||||
}
|
||||
Literal::String(..) => TyKind::Ref(
|
||||
Mutability::Not,
|
||||
LifetimeData::Static.intern(&Interner),
|
||||
TyKind::Str.intern(&Interner),
|
||||
)
|
||||
.intern(&Interner),
|
||||
Literal::ByteString(..) => {
|
||||
let byte_type = TyKind::Scalar(Scalar::Uint(UintTy::U8)).intern(&Interner);
|
||||
let array_type = TyKind::Array(byte_type).intern(&Interner);
|
||||
TyKind::Ref(Mutability::Not, array_type).intern(&Interner)
|
||||
TyKind::Ref(Mutability::Not, LifetimeData::Static.intern(&Interner), array_type)
|
||||
.intern(&Interner)
|
||||
}
|
||||
Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(&Interner),
|
||||
Literal::Int(_v, ty) => match ty {
|
||||
|
@ -872,7 +878,9 @@ impl<'a> InferenceContext<'a> {
|
|||
// Apply autoref so the below unification works correctly
|
||||
// FIXME: return correct autorefs from lookup_method
|
||||
let actual_receiver_ty = match expected_receiver_ty.as_reference() {
|
||||
Some((_, mutability)) => TyKind::Ref(mutability, derefed_receiver_ty).intern(&Interner),
|
||||
Some((_, lifetime, mutability)) => {
|
||||
TyKind::Ref(mutability, lifetime, derefed_receiver_ty).intern(&Interner)
|
||||
}
|
||||
_ => derefed_receiver_ty,
|
||||
};
|
||||
self.unify(&expected_receiver_ty, &actual_receiver_ty);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue