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:
Florian Diebold 2021-03-13 14:44:51 +01:00
parent 7accf6bc37
commit 6c32bbf3ca
20 changed files with 756 additions and 620 deletions

View file

@ -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())
}