]> git.lizzy.rs Git - rust.git/blobdiff - src/test/ui/exhaustive_integer_patterns.rs
Auto merge of #54720 - davidtwco:issue-51191, r=nikomatsakis
[rust.git] / src / test / ui / exhaustive_integer_patterns.rs
index c267c4ef28c08f9ab527ca3b438295e315ba64fb..7825aaa291286c08ea26b202ac43af8e83308a63 100644 (file)
@@ -138,4 +138,36 @@ fn main() {
         (1, _) => {}
         (_, None) => {}
     }
+
+    match (0u8, true) { //~ ERROR non-exhaustive patterns
+        (0 ..= 125, false) => {}
+        (128 ..= 255, false) => {}
+        (0 ..= 255, true) => {}
+    }
+
+    match (0u8, true) { // ok
+        (0 ..= 125, false) => {}
+        (128 ..= 255, false) => {}
+        (0 ..= 255, true) => {}
+        (125 .. 128, false) => {}
+    }
+
+    match 0u8 { // ok
+        0 .. 2 => {}
+        1 ..= 2 => {}
+        _ => {}
+    }
+
+    const LIM: u128 = u128::MAX - 1;
+    match 0u128 { //~ ERROR non-exhaustive patterns
+        0 ..= LIM => {}
+    }
+
+    match 0u128 { //~ ERROR non-exhaustive patterns
+        0 ..= 4 => {}
+    }
+
+    match 0u128 { //~ ERROR non-exhaustive patterns
+        4 ..= u128::MAX => {}
+    }
 }