mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 14:21:44 +00:00
Separate Ty
and TyKind
like in Chalk
Currently `Ty` just wraps `TyKind`, but this allows us to change most places to already use `intern` / `interned`.
This commit is contained in:
parent
7accf6bc37
commit
6c32bbf3ca
20 changed files with 756 additions and 620 deletions
|
@ -15,7 +15,7 @@ use crate::{
|
|||
MissingPatFields, RemoveThisSemicolon,
|
||||
},
|
||||
utils::variant_data,
|
||||
AdtId, InferenceResult, Ty,
|
||||
AdtId, InferenceResult, Interner, Ty, TyKind,
|
||||
};
|
||||
|
||||
pub(crate) use hir_def::{
|
||||
|
@ -289,11 +289,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
let (body, source_map): (Arc<Body>, Arc<BodySourceMap>) =
|
||||
db.body_with_source_map(self.owner.into());
|
||||
|
||||
let match_expr_ty = match infer.type_of_expr.get(match_expr) {
|
||||
// If we can't resolve the type of the match expression
|
||||
// we cannot perform exhaustiveness checks.
|
||||
None | Some(Ty::Unknown) => return,
|
||||
Some(ty) => ty,
|
||||
let match_expr_ty = if infer.type_of_expr[match_expr].is_unknown() {
|
||||
return;
|
||||
} else {
|
||||
&infer.type_of_expr[match_expr]
|
||||
};
|
||||
|
||||
let cx = MatchCheckCtx { match_expr, body, infer: infer.clone(), db };
|
||||
|
@ -379,14 +378,14 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
|
|||
_ => return,
|
||||
};
|
||||
|
||||
let (params, required) = match mismatch.expected {
|
||||
Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters)
|
||||
if enum_id == core_result_enum =>
|
||||
let (params, required) = match mismatch.expected.interned(&Interner) {
|
||||
TyKind::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters)
|
||||
if *enum_id == core_result_enum =>
|
||||
{
|
||||
(parameters, "Ok".to_string())
|
||||
}
|
||||
Ty::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters)
|
||||
if enum_id == core_option_enum =>
|
||||
TyKind::Adt(AdtId(hir_def::AdtId::EnumId(enum_id)), ref parameters)
|
||||
if *enum_id == core_option_enum =>
|
||||
{
|
||||
(parameters, "Some".to_string())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue