mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-30 06:53:27 +00:00
390 lines
13 KiB
Text
390 lines
13 KiB
Text
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:76:5
|
|
|
|
|
LL | / if x9 < min {
|
|
LL | | x9 = min;
|
|
LL | | }
|
|
LL | | if x9 > max {
|
|
LL | | x9 = max;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x9 = x9.clamp(min, max);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
= note: `-D clippy::manual-clamp` implied by `-D warnings`
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:91:5
|
|
|
|
|
LL | / if x11 > max {
|
|
LL | | x11 = max;
|
|
LL | | }
|
|
LL | | if x11 < min {
|
|
LL | | x11 = min;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x11 = x11.clamp(min, max);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:99:5
|
|
|
|
|
LL | / if min > x12 {
|
|
LL | | x12 = min;
|
|
LL | | }
|
|
LL | | if max < x12 {
|
|
LL | | x12 = max;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x12 = x12.clamp(min, max);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:107:5
|
|
|
|
|
LL | / if max < x13 {
|
|
LL | | x13 = max;
|
|
LL | | }
|
|
LL | | if min > x13 {
|
|
LL | | x13 = min;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x13 = x13.clamp(min, max);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:161:5
|
|
|
|
|
LL | / if max < x33 {
|
|
LL | | x33 = max;
|
|
LL | | }
|
|
LL | | if min > x33 {
|
|
LL | | x33 = min;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x33 = x33.clamp(min, max);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:21:14
|
|
|
|
|
LL | let x0 = if max < input {
|
|
| ______________^
|
|
LL | | max
|
|
LL | | } else if min > input {
|
|
LL | | min
|
|
LL | | } else {
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:29:14
|
|
|
|
|
LL | let x1 = if input > max {
|
|
| ______________^
|
|
LL | | max
|
|
LL | | } else if input < min {
|
|
LL | | min
|
|
LL | | } else {
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:37:14
|
|
|
|
|
LL | let x2 = if input < min {
|
|
| ______________^
|
|
LL | | min
|
|
LL | | } else if input > max {
|
|
LL | | max
|
|
LL | | } else {
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:45:14
|
|
|
|
|
LL | let x3 = if min > input {
|
|
| ______________^
|
|
LL | | min
|
|
LL | | } else if max < input {
|
|
LL | | max
|
|
LL | | } else {
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:53:14
|
|
|
|
|
LL | let x4 = input.max(min).min(max);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:55:14
|
|
|
|
|
LL | let x5 = input.min(max).max(min);
|
|
| ^^^^^^^^^^^^^^^^^^^^^^^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:57:14
|
|
|
|
|
LL | let x6 = match input {
|
|
| ______________^
|
|
LL | | x if x > max => max,
|
|
LL | | x if x < min => min,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:63:14
|
|
|
|
|
LL | let x7 = match input {
|
|
| ______________^
|
|
LL | | x if x < min => min,
|
|
LL | | x if x > max => max,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:69:14
|
|
|
|
|
LL | let x8 = match input {
|
|
| ______________^
|
|
LL | | x if max < x => max,
|
|
LL | | x if min > x => min,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:83:15
|
|
|
|
|
LL | let x10 = match input {
|
|
| _______________^
|
|
LL | | x if min > x => min,
|
|
LL | | x if max < x => max,
|
|
LL | | x => x,
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:114:15
|
|
|
|
|
LL | let x14 = if input > CONST_MAX {
|
|
| _______________^
|
|
LL | | CONST_MAX
|
|
LL | | } else if input < CONST_MIN {
|
|
LL | | CONST_MIN
|
|
LL | | } else {
|
|
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
|
|
--> $DIR/manual_clamp.rs:123:19
|
|
|
|
|
LL | let x15 = if input > max {
|
|
| ___________________^
|
|
LL | | max
|
|
LL | | } else if input < min {
|
|
LL | | min
|
|
LL | | } else {
|
|
LL | | input
|
|
LL | | };
|
|
| |_________^ help: replace with clamp: `input.clamp(min, 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
|
|
--> $DIR/manual_clamp.rs:134: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
|
|
--> $DIR/manual_clamp.rs:135: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
|
|
--> $DIR/manual_clamp.rs:136: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
|
|
--> $DIR/manual_clamp.rs:137: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
|
|
--> $DIR/manual_clamp.rs:138: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
|
|
--> $DIR/manual_clamp.rs:139: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
|
|
--> $DIR/manual_clamp.rs:140: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
|
|
--> $DIR/manual_clamp.rs:141: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
|
|
--> $DIR/manual_clamp.rs:143: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
|
|
--> $DIR/manual_clamp.rs:144: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
|
|
--> $DIR/manual_clamp.rs:145: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
|
|
--> $DIR/manual_clamp.rs:146: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
|
|
--> $DIR/manual_clamp.rs:147: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
|
|
--> $DIR/manual_clamp.rs:148: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
|
|
--> $DIR/manual_clamp.rs:149: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
|
|
--> $DIR/manual_clamp.rs:150: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
|
|
--> $DIR/manual_clamp.rs:153:5
|
|
|
|
|
LL | / if x32 < min {
|
|
LL | | x32 = min;
|
|
LL | | } else if x32 > max {
|
|
LL | | x32 = max;
|
|
LL | | }
|
|
| |_____^ help: replace with clamp: `x32 = x32.clamp(min, max);`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: clamp-like pattern without using clamp function
|
|
--> $DIR/manual_clamp.rs:321:13
|
|
|
|
|
LL | let _ = if input < min {
|
|
| _____________^
|
|
LL | | min
|
|
LL | | } else if input > max {
|
|
LL | | max
|
|
LL | | } else {
|
|
LL | | input
|
|
LL | | };
|
|
| |_____^ help: replace with clamp: `input.clamp(min, max)`
|
|
|
|
|
= note: clamp will panic if max < min
|
|
|
|
error: aborting due to 35 previous errors
|
|
|