about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui/manual_range_patterns.rs
diff options
context:
space:
mode:
authorPhilipp Krones <hello@philkrones.com>2023-07-02 14:35:19 +0200
committerPhilipp Krones <hello@philkrones.com>2023-07-02 14:59:02 +0200
commitbeb0e731de1c13ee0ee341965718b6350a48b34d (patch)
tree55b99c273013575811111601fc4ff948e4d27157 /src/tools/clippy/tests/ui/manual_range_patterns.rs
parent72b21014344fe5a595270c951d5a15887f9c7992 (diff)
parent37f4c1725d3fd7e9c3ffd8783246bc5589debc53 (diff)
downloadrust-beb0e731de1c13ee0ee341965718b6350a48b34d.tar.gz
rust-beb0e731de1c13ee0ee341965718b6350a48b34d.zip
Merge commit '37f4c1725d3fd7e9c3ffd8783246bc5589debc53' into clippyup
Diffstat (limited to 'src/tools/clippy/tests/ui/manual_range_patterns.rs')
-rw-r--r--src/tools/clippy/tests/ui/manual_range_patterns.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/manual_range_patterns.rs b/src/tools/clippy/tests/ui/manual_range_patterns.rs
new file mode 100644
index 00000000000..10743a7d04c
--- /dev/null
+++ b/src/tools/clippy/tests/ui/manual_range_patterns.rs
@@ -0,0 +1,35 @@
+//@run-rustfix
+
+#![allow(unused)]
+#![warn(clippy::manual_range_patterns)]
+#![feature(exclusive_range_pattern)]
+
+fn main() {
+    let f = 6;
+
+    let _ = matches!(f, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10);
+    let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 7 | 8 | 10);
+    let _ = matches!(f, 4 | 2 | 3 | 1 | 5 | 6 | 9 | 8 | 10); // 7 is missing
+    let _ = matches!(f, | 4);
+    let _ = matches!(f, 4 | 5);
+    let _ = matches!(f, 1 | 2147483647);
+    let _ = matches!(f, 0 | 2147483647);
+    let _ = matches!(f, -2147483647 | 2147483647);
+    let _ = matches!(f, 1 | (2..=4));
+    let _ = matches!(f, 1 | (2..4));
+    let _ = matches!(f, (1..=10) | (2..=13) | (14..=48324728) | 48324729);
+    let _ = matches!(f, 0 | (1..=10) | 48324730 | (2..=13) | (14..=48324728) | 48324729);
+    let _ = matches!(f, 0..=1 | 0..=2 | 0..=3);
+    #[allow(clippy::match_like_matches_macro)]
+    let _ = match f {
+        1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 => true,
+        _ => false,
+    };
+
+    macro_rules! mac {
+        ($e:expr) => {
+            matches!($e, 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10)
+        };
+    }
+    mac!(f);
+}