2018-07-28 10:34:52 -05:00
|
|
|
#![warn(clippy::overflow_check_conditional)]
|
2023-07-02 07:35:19 -05:00
|
|
|
#![allow(clippy::needless_if)]
|
2016-03-06 09:01:17 -06:00
|
|
|
|
2023-03-07 11:51:48 -06:00
|
|
|
fn test(a: u32, b: u32, c: u32) {
|
2018-12-09 16:26:16 -06:00
|
|
|
if a + b < a {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ 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`
|
2018-12-09 16:26:16 -06:00
|
|
|
if a > a + b {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust
|
2018-12-09 16:26:16 -06:00
|
|
|
if a + b < b {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust
|
2018-12-09 16:26:16 -06:00
|
|
|
if b > a + b {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C overflow conditions that will fail in Rust
|
2018-12-09 16:26:16 -06:00
|
|
|
if a - b > b {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus
|
2018-12-09 16:26:16 -06:00
|
|
|
if b < a - b {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus
|
2018-12-09 16:26:16 -06:00
|
|
|
if a - b > a {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus
|
2018-12-09 16:26:16 -06:00
|
|
|
if a < a - b {}
|
2023-08-24 14:32:12 -05:00
|
|
|
//~^ ERROR: you are trying to use classic C underflow conditions that will fail in Rus
|
2018-12-09 16:26:16 -06:00
|
|
|
if a + b < c {}
|
|
|
|
if c > a + b {}
|
|
|
|
if a - b < c {}
|
|
|
|
if c > a - b {}
|
|
|
|
let i = 1.1;
|
|
|
|
let j = 2.2;
|
|
|
|
if i + j < i {}
|
|
|
|
if i - j < i {}
|
|
|
|
if i > i + j {}
|
|
|
|
if i - j < i {}
|
2016-03-06 09:01:17 -06:00
|
|
|
}
|
2023-03-07 11:51:48 -06:00
|
|
|
|
|
|
|
fn main() {
|
|
|
|
test(1, 2, 3)
|
|
|
|
}
|