Fix missing match arm false error on unknown type

This commit is contained in:
CAD97 2020-08-17 13:27:12 -04:00
parent 2eaf79cfbb
commit c822bb68ce
2 changed files with 2 additions and 4 deletions

View File

@ -223,10 +223,10 @@ impl<'a, 'b> ExprValidator<'a, 'b> {
db.body_with_source_map(self.owner.into());
let match_expr_ty = match infer.type_of_expr.get(match_expr) {
Some(ty) => ty,
// If we can't resolve the type of the match expression
// we cannot perform exhaustiveness checks.
None => return,
None | Some(Ty::Unknown) => return,
Some(ty) => ty,
};
let cx = MatchCheckCtx { match_expr, body, infer: infer.clone(), db };

View File

@ -1342,12 +1342,10 @@ fn panic(a: Category, b: Category) {
enum Option<T> { Some(T), None }
fn main() {
// FIXME: This is a false positive, as the `Never` type is not known here.
// `Never` is deliberately not defined so that it's an uninferred type.
match Option::<Never>::None {
None => (),
Some(never) => match never {},
// ^^^^^ Missing match arm
}
}
"#,