Skip to content

Commit 522823f

Browse files
committed
Fix text fixtures of missing_match_arms diagnostics
1 parent 44e2c6e commit 522823f

File tree

3 files changed

+11
-3
lines changed

3 files changed

+11
-3
lines changed

crates/hir-ty/src/infer/expr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ impl<'a> InferenceContext<'a> {
398398
for arm in arms.iter() {
399399
self.diverges = Diverges::Maybe;
400400
let input_ty = self.resolve_ty_shallow(&input_ty);
401-
let _pat_ty = self.infer_top_pat(arm.pat, &input_ty);
401+
self.infer_top_pat(arm.pat, &input_ty);
402402
if let Some(guard_expr) = arm.guard {
403403
self.infer_expr(
404404
guard_expr,

crates/hir-ty/src/infer/pat.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,8 @@ impl<'a> InferenceContext<'a> {
293293
};
294294
// use a new type variable if we got error type here
295295
let ty = self.insert_type_vars_shallow(ty);
296-
if !self.unify(&ty, &expected) {
296+
// FIXME: This never check is odd, but required with out we do inference right now
297+
if !expected.is_never() && !self.unify(&ty, &expected) {
297298
self.result
298299
.type_mismatches
299300
.insert(pat.into(), TypeMismatch { expected, actual: ty.clone() });

crates/ide-diagnostics/src/handlers/missing_match_arms.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,15 +273,20 @@ enum Either2 { C, D }
273273
fn main() {
274274
match Either::A {
275275
Either2::C => (),
276+
// ^^^^^^^^^^ error: expected Either, found Either2
276277
Either2::D => (),
278+
// ^^^^^^^^^^ error: expected Either, found Either2
277279
}
278280
match (true, false) {
279281
(true, false, true) => (),
282+
// ^^^^^^^^^^^^^^^^^^^ error: expected (bool, bool), found (bool, bool, bool)
280283
(true) => (),
281284
// ^^^^ error: expected (bool, bool), found bool
282285
}
283286
match (true, false) { (true,) => {} }
287+
// ^^^^^^^ error: expected (bool, bool), found (bool,)
284288
match (0) { () => () }
289+
// ^^ error: expected i32, found ()
285290
match Unresolved::Bar { Unresolved::Baz => () }
286291
}
287292
"#,
@@ -295,7 +300,9 @@ fn main() {
295300
r#"
296301
fn main() {
297302
match false { true | () => {} }
303+
// ^^ error: expected bool, found ()
298304
match (false,) { (true | (),) => {} }
305+
// ^^ error: expected bool, found ()
299306
}
300307
"#,
301308
);
@@ -1038,12 +1045,12 @@ fn main() {
10381045
#[test]
10391046
fn reference_patterns_in_fields() {
10401047
cov_mark::check_count!(validate_match_bailed_out, 2);
1041-
10421048
check_diagnostics(
10431049
r#"
10441050
fn main() {
10451051
match (&false,) {
10461052
(true,) => {}
1053+
// ^^^^^^^ error: expected (&bool,), found (bool,)
10471054
}
10481055
match (&false,) {
10491056
(&true,) => {}

0 commit comments

Comments
 (0)