Unnamed repository; edit this file 'description' to name the repository.
Auto merge of #16779 - lnicola:skip-unknown-types-match-diagnostics, r=Veykril
minor: Skip match diagnostics for partially unknown types CC https://github.com/rust-lang/rust-analyzer/issues/16746#issuecomment-1981071008
bors 2024-03-08
parent bbb441e · parent cd2347e · commit 7f19beb
-rw-r--r--crates/hir-ty/src/diagnostics/expr.rs5
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_match_arms.rs18
2 files changed, 18 insertions, 5 deletions
diff --git a/crates/hir-ty/src/diagnostics/expr.rs b/crates/hir-ty/src/diagnostics/expr.rs
index 69205f8fdd..67cfbc294d 100644
--- a/crates/hir-ty/src/diagnostics/expr.rs
+++ b/crates/hir-ty/src/diagnostics/expr.rs
@@ -182,7 +182,7 @@ impl ExprValidator {
db: &dyn HirDatabase,
) {
let scrut_ty = &self.infer[scrutinee_expr];
- if scrut_ty.is_unknown() {
+ if scrut_ty.contains_unknown() {
return;
}
@@ -267,6 +267,9 @@ impl ExprValidator {
};
let Some(initializer) = initializer else { continue };
let ty = &self.infer[initializer];
+ if ty.contains_unknown() {
+ continue;
+ }
let mut have_errors = false;
let deconstructed_pat = self.lower_pattern(&cx, pat, db, &mut have_errors);
diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
index 8596f5792e..67daa172b2 100644
--- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
@@ -597,21 +597,19 @@ fn bang(never: !) {
#[test]
fn unknown_type() {
- cov_mark::check_count!(validate_match_bailed_out, 1);
-
- check_diagnostics(
+ check_diagnostics_no_bails(
r#"
enum Option<T> { Some(T), None }
#[allow(unused)]
fn main() {
// `Never` is deliberately not defined so that it's an uninferred type.
+ // We ignore these to avoid triggering bugs in the analysis.
match Option::<Never>::None {
None => (),
Some(never) => match never {},
}
match Option::<Never>::None {
- //^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `None` not covered
Option::Some(_never) => {},
}
}
@@ -620,6 +618,18 @@ fn main() {
}
#[test]
+ fn arity_mismatch_issue_16746() {
+ check_diagnostics_with_disabled(
+ r#"
+fn main() {
+ let (a, ) = (0, 0);
+}
+"#,
+ &["E0308"],
+ );
+ }
+
+ #[test]
fn tuple_of_bools_with_ellipsis_at_end_missing_arm() {
check_diagnostics_no_bails(
r#"