about summary refs log tree commit diff
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-06-02 10:53:47 +0100
committervarkor <github@varkor.com>2018-08-16 20:09:05 +0100
commit25ba9118ff3d3f6b8d05efb7995c4d53a55841b8 (patch)
tree240b088df43e3ffbae5ea24085d0452c0c78a45b
parent07064de9a788d02b28f8e3f32d81334cd8ef2dce (diff)
downloadrust-25ba9118ff3d3f6b8d05efb7995c4d53a55841b8.tar.gz
rust-25ba9118ff3d3f6b8d05efb7995c4d53a55841b8.zip
Add guarded arms to tests
-rw-r--r--src/test/ui/exhaustive_integer_patterns.rs12
-rw-r--r--src/test/ui/exhaustive_integer_patterns.stderr8
2 files changed, 19 insertions, 1 deletions
diff --git a/src/test/ui/exhaustive_integer_patterns.rs b/src/test/ui/exhaustive_integer_patterns.rs
index e8f2affbec3..294481389f7 100644
--- a/src/test/ui/exhaustive_integer_patterns.rs
+++ b/src/test/ui/exhaustive_integer_patterns.rs
@@ -120,4 +120,16 @@ fn main() {
     match 0i128 {
         i128::MIN ..= i128::MAX => {} // ok
     }
+
+    // Make sure that guards don't factor into the exhaustiveness checks.
+    match 0u8 { //~ ERROR non-exhaustive patterns
+        0 .. 128 => {}
+        128 ..= 255 if true => {}
+    }
+
+    match 0u8 {
+        0 .. 128 => {}
+        128 ..= 255 if false => {}
+        128 ..= 255 => {} // ok, because previous arm was guarded
+    }
 }
diff --git a/src/test/ui/exhaustive_integer_patterns.stderr b/src/test/ui/exhaustive_integer_patterns.stderr
index 0f7ab8688c6..a2ed9416b50 100644
--- a/src/test/ui/exhaustive_integer_patterns.stderr
+++ b/src/test/ui/exhaustive_integer_patterns.stderr
@@ -46,6 +46,12 @@ error[E0004]: non-exhaustive patterns: `0i16` not covered
 LL |     match 0i16 { //~ ERROR non-exhaustive patterns
    |           ^^^^ pattern `0i16` not covered
 
-error: aborting due to 7 previous errors
+error[E0004]: non-exhaustive patterns: `128u8..=255u8` not covered
+  --> $DIR/exhaustive_integer_patterns.rs:125:11
+   |
+LL |     match 0u8 { //~ ERROR non-exhaustive patterns
+   |           ^^^ pattern `128u8..=255u8` not covered
+
+error: aborting due to 8 previous errors
 
 For more information about this error, try `rustc --explain E0004`.