diff options
| author | Jason Newcomb <jsnewcomb@pm.me> | 2024-06-16 01:34:25 -0400 |
|---|---|---|
| committer | Jason Newcomb <jsnewcomb@pm.me> | 2024-07-07 10:22:29 -0400 |
| commit | aa371c37c2989e2c505865630179250ec528c19b (patch) | |
| tree | 5d508ccd17dd54245a52943aeeeef556c193baf8 /tests | |
| parent | f2c74e220bef89dc62dfbd1d2a4eb49c6ae8b47a (diff) | |
| download | rust-aa371c37c2989e2c505865630179250ec528c19b.tar.gz rust-aa371c37c2989e2c505865630179250ec528c19b.zip | |
Rewrite `overflow_check_conditional`
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ui/overflow_check_conditional.rs | 21 | ||||
| -rw-r--r-- | tests/ui/overflow_check_conditional.stderr | 28 |
2 files changed, 14 insertions, 35 deletions
diff --git a/tests/ui/overflow_check_conditional.rs b/tests/ui/overflow_check_conditional.rs index a70bb3bc47b..acabe9a37e0 100644 --- a/tests/ui/overflow_check_conditional.rs +++ b/tests/ui/overflow_check_conditional.rs @@ -2,23 +2,14 @@ #![allow(clippy::needless_if)] fn test(a: u32, b: u32, c: u32) { - if a + b < a {} - //~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust - //~| NOTE: `-D clippy::overflow-check-conditional` implied by `-D warnings` - if a > a + b {} - //~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust - if a + b < b {} - //~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust - if b > a + b {} - //~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust + if a + b < a {} //~ overflow_check_conditional + if a > a + b {} //~ overflow_check_conditional + if a + b < b {} //~ overflow_check_conditional + if b > a + b {} //~ overflow_check_conditional if a - b > b {} - //~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus if b < a - b {} - //~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus - if a - b > a {} - //~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus - if a < a - b {} - //~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus + if a - b > a {} //~ overflow_check_conditional + if a < a - b {} //~ overflow_check_conditional if a + b < c {} if c > a + b {} if a - b < c {} diff --git a/tests/ui/overflow_check_conditional.stderr b/tests/ui/overflow_check_conditional.stderr index c14532bad5a..e71768d3745 100644 --- a/tests/ui/overflow_check_conditional.stderr +++ b/tests/ui/overflow_check_conditional.stderr @@ -8,46 +8,34 @@ LL | if a + b < a {} = help: to override `-D warnings` add `#[allow(clippy::overflow_check_conditional)]` error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:8:8 + --> tests/ui/overflow_check_conditional.rs:6:8 | LL | if a > a + b {} | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:10:8 + --> tests/ui/overflow_check_conditional.rs:7:8 | LL | if a + b < b {} | ^^^^^^^^^ error: you are trying to use classic C overflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:12:8 + --> tests/ui/overflow_check_conditional.rs:8:8 | LL | if b > a + b {} | ^^^^^^^^^ -error: you are trying to use classic C underflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:14:8 - | -LL | if a - b > b {} - | ^^^^^^^^^ - -error: you are trying to use classic C underflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:16:8 - | -LL | if b < a - b {} - | ^^^^^^^^^ - -error: you are trying to use classic C underflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:18:8 +error: you are trying to use classic C overflow conditions that will fail in Rust + --> tests/ui/overflow_check_conditional.rs:11:8 | LL | if a - b > a {} | ^^^^^^^^^ -error: you are trying to use classic C underflow conditions that will fail in Rust - --> tests/ui/overflow_check_conditional.rs:20:8 +error: you are trying to use classic C overflow conditions that will fail in Rust + --> tests/ui/overflow_check_conditional.rs:12:8 | LL | if a < a - b {} | ^^^^^^^^^ -error: aborting due to 8 previous errors +error: aborting due to 6 previous errors |
