Unnamed repository; edit this file 'description' to name the repository.
Diffstat (limited to 'crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs')
-rw-r--r--crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs61
1 files changed, 61 insertions, 0 deletions
diff --git a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
index 1a4d2877ef..ff1eeb0516 100644
--- a/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
+++ b/crates/ide-diagnostics/src/handlers/non_exhaustive_let.rs
@@ -44,4 +44,65 @@ fn main() {
"#,
);
}
+
+ #[test]
+ fn option_nonexhaustive_inside_blocks() {
+ check_diagnostics(
+ r#"
+//- minicore: option
+fn main() {
+ '_a: {
+ let None = Some(5);
+ //^^^^ error: non-exhaustive pattern: `Some(_)` not covered
+ }
+}
+"#,
+ );
+
+ check_diagnostics(
+ r#"
+//- minicore: future, option
+fn main() {
+ let _ = async {
+ let None = Some(5);
+ //^^^^ error: non-exhaustive pattern: `Some(_)` not covered
+ };
+}
+"#,
+ );
+
+ check_diagnostics(
+ r#"
+//- minicore: option
+fn main() {
+ unsafe {
+ let None = Some(5);
+ //^^^^ error: non-exhaustive pattern: `Some(_)` not covered
+ }
+}
+"#,
+ );
+ }
+
+ #[test]
+ fn min_exhaustive() {
+ check_diagnostics(
+ r#"
+//- minicore: result
+fn test(x: Result<i32, !>) {
+ let Ok(_y) = x;
+}
+"#,
+ );
+
+ check_diagnostics(
+ r#"
+//- minicore: result
+fn test(x: Result<i32, &'static !>) {
+ let Ok(_y) = x;
+ //^^^^^^ error: non-exhaustive pattern: `Err(_)` not covered
+}
+"#,
+ );
+ }
}