Skip to content

Commit cd2347e

Browse files
committed
Skip match diagnostics for partially unknown types
1 parent bbb441e commit cd2347e

File tree

2 files changed

+18
-5
lines changed

2 files changed

+18
-5
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ impl ExprValidator {
182182
db: &dyn HirDatabase,
183183
) {
184184
let scrut_ty = &self.infer[scrutinee_expr];
185-
if scrut_ty.is_unknown() {
185+
if scrut_ty.contains_unknown() {
186186
return;
187187
}
188188

@@ -267,6 +267,9 @@ impl ExprValidator {
267267
};
268268
let Some(initializer) = initializer else { continue };
269269
let ty = &self.infer[initializer];
270+
if ty.contains_unknown() {
271+
continue;
272+
}
270273

271274
let mut have_errors = false;
272275
let deconstructed_pat = self.lower_pattern(&cx, pat, db, &mut have_errors);

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -597,28 +597,38 @@ fn bang(never: !) {
597597

598598
#[test]
599599
fn unknown_type() {
600-
cov_mark::check_count!(validate_match_bailed_out, 1);
601-
602-
check_diagnostics(
600+
check_diagnostics_no_bails(
603601
r#"
604602
enum Option<T> { Some(T), None }
605603
606604
#[allow(unused)]
607605
fn main() {
608606
// `Never` is deliberately not defined so that it's an uninferred type.
607+
// We ignore these to avoid triggering bugs in the analysis.
609608
match Option::<Never>::None {
610609
None => (),
611610
Some(never) => match never {},
612611
}
613612
match Option::<Never>::None {
614-
//^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `None` not covered
615613
Option::Some(_never) => {},
616614
}
617615
}
618616
"#,
619617
);
620618
}
621619

620+
#[test]
621+
fn arity_mismatch_issue_16746() {
622+
check_diagnostics_with_disabled(
623+
r#"
624+
fn main() {
625+
let (a, ) = (0, 0);
626+
}
627+
"#,
628+
&["E0308"],
629+
);
630+
}
631+
622632
#[test]
623633
fn tuple_of_bools_with_ellipsis_at_end_missing_arm() {
624634
check_diagnostics_no_bails(

0 commit comments

Comments
 (0)