mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 00:53:31 +00:00
406 lines
13 KiB
Text
406 lines
13 KiB
Text
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:217:5
|
|
|
|
|
LL | / if x9 < CONST_MIN {
|
|
LL | |
|
|
LL | |
|
|
LL | | x9 = CONST_MIN;
|
|
... |
|
|
LL | | x9 = CONST_MAX;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x9 = x9.clamp(CONST_MIN, CONST_MAX);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
= note: `-D clippy::manual-clamp` implied by `-D warnings`
|
|
= help: to override `-D warnings` add `#[allow(clippy::manual_clamp)]`
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:236:5
|
|
|
|
|
LL | / if x11 > CONST_MAX {
|
|
LL | |
|
|
LL | |
|
|
LL | | x11 = CONST_MAX;
|
|
... |
|
|
LL | | x11 = CONST_MIN;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x11 = x11.clamp(CONST_MIN, CONST_MAX);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:246:5
|
|
|
|
|
LL | / if CONST_MIN > x12 {
|
|
LL | |
|
|
LL | |
|
|
LL | | x12 = CONST_MIN;
|
|
... |
|
|
LL | | x12 = CONST_MAX;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x12 = x12.clamp(CONST_MIN, CONST_MAX);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:256:5
|
|
|
|
|
LL | / if CONST_MAX < x13 {
|
|
LL | |
|
|
LL | |
|
|
LL | | x13 = CONST_MAX;
|
|
... |
|
|
LL | | x13 = CONST_MIN;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x13 = x13.clamp(CONST_MIN, CONST_MAX);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:370:5
|
|
|
|
|
LL | / if CONST_MAX < x35 {
|
|
LL | |
|
|
LL | |
|
|
LL | | x35 = CONST_MAX;
|
|
... |
|
|
LL | | x35 = CONST_MIN;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x35 = x35.clamp(CONST_MIN, CONST_MAX);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:144:14
|
|
|
|
|
LL | let x0 = if CONST_MAX < input {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_MAX
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:154:14
|
|
|
|
|
LL | let x1 = if input > CONST_MAX {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_MAX
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:164:14
|
|
|
|
|
LL | let x2 = if input < CONST_MIN {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_MIN
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:174:14
|
|
|
|
|
LL | let x3 = if CONST_MIN > input {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_MIN
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:184:14
|
|
|
|
|
LL | let x4 = input.max(CONST_MIN).min(CONST_MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:188:14
|
|
|
|
|
LL | let x5 = input.min(CONST_MAX).max(CONST_MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:192:14
|
|
|
|
|
LL | let x6 = match input {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | x if x > CONST_MAX => CONST_MAX,
|
|
LL | | x if x < CONST_MIN => CONST_MIN,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:200:14
|
|
|
|
|
LL | let x7 = match input {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | x if x < CONST_MIN => CONST_MIN,
|
|
LL | | x if x > CONST_MAX => CONST_MAX,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:208:14
|
|
|
|
|
LL | let x8 = match input {
|
|
| ______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | x if CONST_MAX < x => CONST_MAX,
|
|
LL | | x if CONST_MIN > x => CONST_MIN,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:226:15
|
|
|
|
|
LL | let x10 = match input {
|
|
| _______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | x if CONST_MIN > x => CONST_MIN,
|
|
LL | | x if CONST_MAX < x => CONST_MAX,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:265:15
|
|
|
|
|
LL | let x14 = if input > CONST_MAX {
|
|
| _______________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_MAX
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:276:19
|
|
|
|
|
LL | let x15 = if input > CONST_F64_MAX {
|
|
| ___________________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_F64_MAX
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_________^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:289:19
|
|
|
|
|
LL | let x16 = cmp_max(cmp_min(input, CONST_MAX), CONST_MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:292:19
|
|
|
|
|
LL | let x17 = cmp_min(cmp_max(input, CONST_MIN), CONST_MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:295:19
|
|
|
|
|
LL | let x18 = cmp_max(CONST_MIN, cmp_min(input, CONST_MAX));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:298:19
|
|
|
|
|
LL | let x19 = cmp_min(CONST_MAX, cmp_max(input, CONST_MIN));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:301:19
|
|
|
|
|
LL | let x20 = cmp_max(cmp_min(CONST_MAX, input), CONST_MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:304:19
|
|
|
|
|
LL | let x21 = cmp_min(cmp_max(CONST_MIN, input), CONST_MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:307:19
|
|
|
|
|
LL | let x22 = cmp_max(CONST_MIN, cmp_min(CONST_MAX, input));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:310:19
|
|
|
|
|
LL | let x23 = cmp_min(CONST_MAX, cmp_max(CONST_MIN, input));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:314:19
|
|
|
|
|
LL | let x24 = f64::max(f64::min(input, CONST_F64_MAX), CONST_F64_MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:317:19
|
|
|
|
|
LL | let x25 = f64::min(f64::max(input, CONST_F64_MIN), CONST_F64_MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:320:19
|
|
|
|
|
LL | let x26 = f64::max(CONST_F64_MIN, f64::min(input, CONST_F64_MAX));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:323:19
|
|
|
|
|
LL | let x27 = f64::min(CONST_F64_MAX, f64::max(input, CONST_F64_MIN));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:326:19
|
|
|
|
|
LL | let x28 = f64::max(f64::min(CONST_F64_MAX, input), CONST_F64_MIN);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:329:19
|
|
|
|
|
LL | let x29 = f64::min(f64::max(CONST_F64_MIN, input), CONST_F64_MAX);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:332:19
|
|
|
|
|
LL | let x30 = f64::max(CONST_F64_MIN, f64::min(CONST_F64_MAX, input));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:335:19
|
|
|
|
|
LL | let x31 = f64::min(CONST_F64_MAX, f64::max(CONST_F64_MIN, input));
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(CONST_F64_MIN, CONST_F64_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min, min.is_nan(), or max.is_nan()
|
|
= note: clamp returns NaN if the input is NaN
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:340:5
|
|
|
|
|
LL | / if x32 < CONST_MIN {
|
|
LL | |
|
|
LL | |
|
|
LL | | x32 = CONST_MIN;
|
|
LL | | } else if x32 > CONST_MAX {
|
|
LL | | x32 = CONST_MAX;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x32 = x32.clamp(CONST_MIN, CONST_MAX);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> tests/ui/manual_clamp.rs:532:13
|
|
|
|
|
LL | let _ = if input > CONST_MAX {
|
|
| _____________^
|
|
LL | |
|
|
LL | |
|
|
LL | | CONST_MAX
|
|
... |
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(CONST_MIN, CONST_MAX)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: aborting due to 35 previous errors
|
|
|