Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/missing_match_arms.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/missing_match_arms.rs34
1 files changed, 28 insertions, 6 deletions
diff --git a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
index 17dc679e05..8596f5792e 100644
--- a/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
+++ b/crates/ide-diagnostics/src/handlers/missing_match_arms.rs
@@ -18,7 +18,9 @@ pub(crate) fn missing_match_arms(
#[cfg(test)]
mod tests {
use crate::{
- tests::{check_diagnostics, check_diagnostics_with_config},
+ tests::{
+ check_diagnostics, check_diagnostics_with_config, check_diagnostics_with_disabled,
+ },
DiagnosticsConfig,
};
@@ -282,7 +284,7 @@ fn main() {
cov_mark::check_count!(validate_match_bailed_out, 4);
// Match statements with arms that don't match the
// expression pattern do not fire this diagnostic.
- check_diagnostics(
+ check_diagnostics_with_disabled(
r#"
enum Either { A, B }
enum Either2 { C, D }
@@ -307,6 +309,25 @@ fn main() {
match Unresolved::Bar { Unresolved::Baz => () }
}
"#,
+ &["E0425"],
+ );
+ }
+
+ #[test]
+ fn mismatched_types_issue_15883() {
+ // Check we don't panic.
+ check_diagnostics_no_bails(
+ r#"
+//- minicore: option
+fn main() {
+ match Some((true, false)) {
+ Some(true) | Some(false) => {}
+ // ^^^^ error: expected (bool, bool), found bool
+ // ^^^^^ error: expected (bool, bool), found bool
+ None => {}
+ }
+}
+ "#,
);
}
@@ -379,11 +400,11 @@ fn main() {
match loop {} {
Either::A => (),
}
- match loop { break Foo::A } {
- //^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `B` not covered
+ match loop { break Either::A } {
+ //^^^^^^^^^^^^^^^^^^^^^^^^ error: missing match arm: `B` not covered
Either::A => (),
}
- match loop { break Foo::A } {
+ match loop { break Either::A } {
Either::A => (),
Either::B => (),
}
@@ -959,7 +980,7 @@ fn f(ty: Enum) {
#[test]
fn unexpected_ty_fndef() {
cov_mark::check!(validate_match_bailed_out);
- check_diagnostics(
+ check_diagnostics_with_disabled(
r"
enum Exp {
Tuple(()),
@@ -969,6 +990,7 @@ fn f() {
Exp::Tuple => {}
}
}",
+ &["E0425"],
);
}