summaryrefslogtreecommitdiffstats
path: root/tests/ui/pattern/usefulness/empty-match-check-notes.rs
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/pattern/usefulness/empty-match-check-notes.rs')
-rw-r--r--tests/ui/pattern/usefulness/empty-match-check-notes.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/tests/ui/pattern/usefulness/empty-match-check-notes.rs b/tests/ui/pattern/usefulness/empty-match-check-notes.rs
new file mode 100644
index 000000000..ee9ff3dcf
--- /dev/null
+++ b/tests/ui/pattern/usefulness/empty-match-check-notes.rs
@@ -0,0 +1,52 @@
+// aux-build:empty.rs
+// revisions: normal exhaustive_patterns
+//
+// This tests a match with no arms on various types, and checks NOTEs.
+#![feature(never_type)]
+#![cfg_attr(exhaustive_patterns, feature(exhaustive_patterns))]
+#![deny(unreachable_patterns)]
+//~^ NOTE the lint level is defined here
+
+extern crate empty;
+
+enum EmptyEnum {}
+
+fn empty_enum(x: EmptyEnum) {
+ match x {} // ok
+ match x {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match x {
+ _ if false => {} //~ ERROR unreachable pattern
+ }
+}
+
+fn empty_foreign_enum(x: empty::EmptyForeignEnum) {
+ match x {} // ok
+ match x {
+ _ => {} //~ ERROR unreachable pattern
+ }
+ match x {
+ _ if false => {} //~ ERROR unreachable pattern
+ }
+}
+
+fn empty_foreign_enum_private(x: Option<empty::SecretlyUninhabitedForeignStruct>) {
+ let None = x;
+ //~^ ERROR refutable pattern in local binding
+ //~| NOTE `let` bindings require an "irrefutable pattern"
+ //~| NOTE for more information, visit
+ //~| NOTE the matched value is of type
+ //~| NOTE pattern `Some(_)` not covered
+ //[exhaustive_patterns]~| NOTE currently uninhabited, but this variant contains private fields
+}
+
+fn main() {
+ match 0u8 {
+ //~^ ERROR `_` not covered
+ //~| NOTE the matched value is of type
+ //~| NOTE match arms with guards don't count towards exhaustivity
+ //~| NOTE pattern `_` not covered
+ _ if false => {}
+ }
+}