mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
Don't use Substs for Ref/Raw/Array/Slice
This commit is contained in:
parent
af466f8542
commit
42217738e0
10 changed files with 103 additions and 116 deletions
|
@ -504,8 +504,8 @@ impl<'a> InferenceContext<'a> {
|
|||
};
|
||||
let inner_ty = self.infer_expr_inner(*expr, &expectation);
|
||||
match rawness {
|
||||
Rawness::RawPtr => TyKind::Raw(mutability, Substs::single(inner_ty)),
|
||||
Rawness::Ref => TyKind::Ref(mutability, Substs::single(inner_ty)),
|
||||
Rawness::RawPtr => TyKind::Raw(mutability, inner_ty),
|
||||
Rawness::Ref => TyKind::Ref(mutability, inner_ty),
|
||||
}
|
||||
.intern(&Interner)
|
||||
}
|
||||
|
@ -686,7 +686,7 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
Expr::Array(array) => {
|
||||
let elem_ty = match expected.ty.interned(&Interner) {
|
||||
TyKind::Array(st) | TyKind::Slice(st) => st.as_single().clone(),
|
||||
TyKind::Array(st) | TyKind::Slice(st) => st.clone(),
|
||||
_ => self.table.new_type_var(),
|
||||
};
|
||||
|
||||
|
@ -710,18 +710,17 @@ impl<'a> InferenceContext<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
TyKind::Array(Substs::single(elem_ty)).intern(&Interner)
|
||||
TyKind::Array(elem_ty).intern(&Interner)
|
||||
}
|
||||
Expr::Literal(lit) => match lit {
|
||||
Literal::Bool(..) => TyKind::Scalar(Scalar::Bool).intern(&Interner),
|
||||
Literal::String(..) => {
|
||||
TyKind::Ref(Mutability::Not, Substs::single(TyKind::Str.intern(&Interner)))
|
||||
.intern(&Interner)
|
||||
TyKind::Ref(Mutability::Not, TyKind::Str.intern(&Interner)).intern(&Interner)
|
||||
}
|
||||
Literal::ByteString(..) => {
|
||||
let byte_type = TyKind::Scalar(Scalar::Uint(UintTy::U8)).intern(&Interner);
|
||||
let array_type = TyKind::Array(Substs::single(byte_type)).intern(&Interner);
|
||||
TyKind::Ref(Mutability::Not, Substs::single(array_type)).intern(&Interner)
|
||||
let array_type = TyKind::Array(byte_type).intern(&Interner);
|
||||
TyKind::Ref(Mutability::Not, array_type).intern(&Interner)
|
||||
}
|
||||
Literal::Char(..) => TyKind::Scalar(Scalar::Char).intern(&Interner),
|
||||
Literal::Int(_v, ty) => match ty {
|
||||
|
@ -855,9 +854,7 @@ 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, Substs::single(derefed_receiver_ty)).intern(&Interner)
|
||||
}
|
||||
Some((_, mutability)) => TyKind::Ref(mutability, 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