]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/range_contains.fixed
Auto merge of #9684 - kraktus:ref_option_ref, r=xFrednet
[rust.git] / tests / ui / range_contains.fixed
index 048874a7f8294a5d0af9c3365f29572dd38d07f6..85d021b2f25e2094435df55fc9e40bcaa39caa34 100644 (file)
@@ -6,7 +6,7 @@
 #[allow(clippy::short_circuit_statement)]
 #[allow(clippy::unnecessary_operation)]
 fn main() {
-    let x = 9_u32;
+    let x = 9_i32;
 
     // order shouldn't matter
     (8..12).contains(&x);
@@ -43,4 +43,22 @@ fn main() {
     let y = 3.;
     (0. ..1.).contains(&y);
     !(0. ..=1.).contains(&y);
+
+    // handle negatives #8721
+    (-10..=10).contains(&x);
+    x >= 10 && x <= -10;
+    (-3. ..=3.).contains(&y);
+    y >= 3. && y <= -3.;
+
+    // Fix #8745
+    let z = 42;
+    (0..=10).contains(&x) && (0..=10).contains(&z);
+    !(0..10).contains(&x) || !(0..10).contains(&z);
+    // Make sure operators in parens don't give a breaking suggestion
+    ((x % 2 == 0) || (x < 0)) || (x >= 10);
+}
+
+// Fix #6373
+pub const fn in_range(a: i32) -> bool {
+    3 <= a && a <= 20
 }