Move code comments to prevent having weird clippy fmt issues
This commit is contained in:
parent
a05d3a4137
commit
f4670121d5
@ -40,7 +40,8 @@ fn main() {
|
||||
let status_code = 500; // Value doesn't matter for the lint
|
||||
let status = Status { code: status_code };
|
||||
|
||||
status_code >= 400 && status_code < 500; // Correct
|
||||
// Correct
|
||||
status_code >= 400 && status_code < 500;
|
||||
status_code <= 400 && status_code > 500;
|
||||
//~^ ERROR: boolean expression will never evaluate to 'true'
|
||||
//~| NOTE: since `400` < `500`, the expression evaluates to false for any value of `st
|
||||
@ -80,22 +81,30 @@ fn main() {
|
||||
//~| NOTE: `status` cannot simultaneously be greater than and less than `STATUS_SERVER
|
||||
|
||||
// Yoda conditions
|
||||
500 <= status_code && 600 > status_code; // Correct
|
||||
500 <= status_code && status_code <= 600; // Correct
|
||||
500 >= status_code && 600 < status_code; // Incorrect
|
||||
// Correct
|
||||
500 <= status_code && 600 > status_code;
|
||||
// Correct
|
||||
500 <= status_code && status_code <= 600;
|
||||
// Incorrect
|
||||
500 >= status_code && 600 < status_code;
|
||||
//~^ ERROR: boolean expression will never evaluate to 'true'
|
||||
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
|
||||
500 >= status_code && status_code > 600; // Incorrect
|
||||
// Incorrect
|
||||
500 >= status_code && status_code > 600;
|
||||
//~^ ERROR: boolean expression will never evaluate to 'true'
|
||||
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
|
||||
|
||||
// Yoda conditions, comparing two different types
|
||||
500 <= status && 600 > status; // Correct
|
||||
500 <= status && status <= 600; // Correct
|
||||
500 >= status && 600 < status; // Incorrect
|
||||
// Correct
|
||||
500 <= status && 600 > status;
|
||||
// Correct
|
||||
500 <= status && status <= 600;
|
||||
// Incorrect
|
||||
500 >= status && 600 < status;
|
||||
//~^ ERROR: boolean expression will never evaluate to 'true'
|
||||
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
|
||||
500 >= status && status > 600; // Incorrect
|
||||
// Incorrect
|
||||
500 >= status && status > 600;
|
||||
//~^ ERROR: boolean expression will never evaluate to 'true'
|
||||
//~| NOTE: since `500` < `600`, the expression evaluates to false for any value of `st
|
||||
|
||||
@ -105,13 +114,17 @@ fn main() {
|
||||
status_code > 200 && status_code >= 299;
|
||||
//~^ ERROR: left-hand side of `&&` operator has no effect
|
||||
|
||||
status_code >= 500 && status_code > 500; // Useless left
|
||||
// Useless left
|
||||
status_code >= 500 && status_code > 500;
|
||||
//~^ ERROR: left-hand side of `&&` operator has no effect
|
||||
status_code > 500 && status_code >= 500; // Useless right
|
||||
// Useless right
|
||||
status_code > 500 && status_code >= 500;
|
||||
//~^ ERROR: right-hand side of `&&` operator has no effect
|
||||
status_code <= 500 && status_code < 500; // Useless left
|
||||
// Useless left
|
||||
status_code <= 500 && status_code < 500;
|
||||
//~^ ERROR: left-hand side of `&&` operator has no effect
|
||||
status_code < 500 && status_code <= 500; // Useless right
|
||||
// Useless right
|
||||
status_code < 500 && status_code <= 500;
|
||||
//~^ ERROR: right-hand side of `&&` operator has no effect
|
||||
|
||||
// Other types
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:44:5
|
||||
--> $DIR/const_comparisons.rs:45:5
|
||||
|
|
||||
LL | status_code <= 400 && status_code > 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -8,7 +8,7 @@ LL | status_code <= 400 && status_code > 500;
|
||||
= note: `-D clippy::impossible-comparisons` implied by `-D warnings`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:47:5
|
||||
--> $DIR/const_comparisons.rs:48:5
|
||||
|
|
||||
LL | status_code > 500 && status_code < 400;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -16,7 +16,7 @@ LL | status_code > 500 && status_code < 400;
|
||||
= note: since `500` > `400`, the expression evaluates to false for any value of `status_code`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:50:5
|
||||
--> $DIR/const_comparisons.rs:51:5
|
||||
|
|
||||
LL | status_code < 500 && status_code > 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -24,7 +24,7 @@ LL | status_code < 500 && status_code > 500;
|
||||
= note: `status_code` cannot simultaneously be greater than and less than `500`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:55:5
|
||||
--> $DIR/const_comparisons.rs:56:5
|
||||
|
|
||||
LL | status_code < { 400 } && status_code > { 500 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -32,7 +32,7 @@ LL | status_code < { 400 } && status_code > { 500 };
|
||||
= note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status_code`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:58:5
|
||||
--> $DIR/const_comparisons.rs:59:5
|
||||
|
|
||||
LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -40,7 +40,7 @@ LL | status_code < STATUS_BAD_REQUEST && status_code > STATUS_SERVER_ERROR;
|
||||
= note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:61:5
|
||||
--> $DIR/const_comparisons.rs:62:5
|
||||
|
|
||||
LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -48,7 +48,7 @@ LL | status_code <= u16::MIN + 1 && status_code > STATUS_SERVER_ERROR;
|
||||
= note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status_code`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:64:5
|
||||
--> $DIR/const_comparisons.rs:65:5
|
||||
|
|
||||
LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -56,7 +56,7 @@ LL | status_code < STATUS_SERVER_ERROR && status_code > STATUS_SERVER_ERROR;
|
||||
= note: `status_code` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:69:5
|
||||
--> $DIR/const_comparisons.rs:70:5
|
||||
|
|
||||
LL | status < { 400 } && status > { 500 };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -64,7 +64,7 @@ LL | status < { 400 } && status > { 500 };
|
||||
= note: since `{ 400 }` < `{ 500 }`, the expression evaluates to false for any value of `status`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:72:5
|
||||
--> $DIR/const_comparisons.rs:73:5
|
||||
|
|
||||
LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -72,7 +72,7 @@ LL | status < STATUS_BAD_REQUEST && status > STATUS_SERVER_ERROR;
|
||||
= note: since `STATUS_BAD_REQUEST` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:75:5
|
||||
--> $DIR/const_comparisons.rs:76:5
|
||||
|
|
||||
LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -80,7 +80,7 @@ LL | status <= u16::MIN + 1 && status > STATUS_SERVER_ERROR;
|
||||
= note: since `u16::MIN + 1` < `STATUS_SERVER_ERROR`, the expression evaluates to false for any value of `status`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:78:5
|
||||
--> $DIR/const_comparisons.rs:79:5
|
||||
|
|
||||
LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -88,112 +88,112 @@ LL | status < STATUS_SERVER_ERROR && status > STATUS_SERVER_ERROR;
|
||||
= note: `status` cannot simultaneously be greater than and less than `STATUS_SERVER_ERROR`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:85:5
|
||||
--> $DIR/const_comparisons.rs:89:5
|
||||
|
|
||||
LL | 500 >= status_code && 600 < status_code; // Incorrect
|
||||
LL | 500 >= status_code && 600 < status_code;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: since `500` < `600`, the expression evaluates to false for any value of `status_code`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:88:5
|
||||
--> $DIR/const_comparisons.rs:93:5
|
||||
|
|
||||
LL | 500 >= status_code && status_code > 600; // Incorrect
|
||||
LL | 500 >= status_code && status_code > 600;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: since `500` < `600`, the expression evaluates to false for any value of `status_code`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:95:5
|
||||
--> $DIR/const_comparisons.rs:103:5
|
||||
|
|
||||
LL | 500 >= status && 600 < status; // Incorrect
|
||||
LL | 500 >= status && 600 < status;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: since `500` < `600`, the expression evaluates to false for any value of `status`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:98:5
|
||||
--> $DIR/const_comparisons.rs:107:5
|
||||
|
|
||||
LL | 500 >= status && status > 600; // Incorrect
|
||||
LL | 500 >= status && status > 600;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
= note: since `500` < `600`, the expression evaluates to false for any value of `status`
|
||||
|
||||
error: right-hand side of `&&` operator has no effect
|
||||
--> $DIR/const_comparisons.rs:103:5
|
||||
--> $DIR/const_comparisons.rs:112:5
|
||||
|
|
||||
LL | status_code < 200 && status_code <= 299;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `if `status_code < 200` evaluates to true, status_code <= 299` will always evaluate to true as well
|
||||
--> $DIR/const_comparisons.rs:103:23
|
||||
--> $DIR/const_comparisons.rs:112:23
|
||||
|
|
||||
LL | status_code < 200 && status_code <= 299;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
= note: `-D clippy::redundant-comparisons` implied by `-D warnings`
|
||||
|
||||
error: left-hand side of `&&` operator has no effect
|
||||
--> $DIR/const_comparisons.rs:105:5
|
||||
--> $DIR/const_comparisons.rs:114:5
|
||||
|
|
||||
LL | status_code > 200 && status_code >= 299;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `if `status_code >= 299` evaluates to true, status_code > 200` will always evaluate to true as well
|
||||
--> $DIR/const_comparisons.rs:105:5
|
||||
--> $DIR/const_comparisons.rs:114:5
|
||||
|
|
||||
LL | status_code > 200 && status_code >= 299;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: left-hand side of `&&` operator has no effect
|
||||
--> $DIR/const_comparisons.rs:108:5
|
||||
--> $DIR/const_comparisons.rs:118:5
|
||||
|
|
||||
LL | status_code >= 500 && status_code > 500; // Useless left
|
||||
LL | status_code >= 500 && status_code > 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well
|
||||
--> $DIR/const_comparisons.rs:108:5
|
||||
--> $DIR/const_comparisons.rs:118:5
|
||||
|
|
||||
LL | status_code >= 500 && status_code > 500; // Useless left
|
||||
LL | status_code >= 500 && status_code > 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: right-hand side of `&&` operator has no effect
|
||||
--> $DIR/const_comparisons.rs:110:5
|
||||
--> $DIR/const_comparisons.rs:121:5
|
||||
|
|
||||
LL | status_code > 500 && status_code >= 500; // Useless right
|
||||
LL | status_code > 500 && status_code >= 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `if `status_code > 500` evaluates to true, status_code >= 500` will always evaluate to true as well
|
||||
--> $DIR/const_comparisons.rs:110:23
|
||||
--> $DIR/const_comparisons.rs:121:23
|
||||
|
|
||||
LL | status_code > 500 && status_code >= 500; // Useless right
|
||||
LL | status_code > 500 && status_code >= 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: left-hand side of `&&` operator has no effect
|
||||
--> $DIR/const_comparisons.rs:112:5
|
||||
--> $DIR/const_comparisons.rs:124:5
|
||||
|
|
||||
LL | status_code <= 500 && status_code < 500; // Useless left
|
||||
LL | status_code <= 500 && status_code < 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well
|
||||
--> $DIR/const_comparisons.rs:112:5
|
||||
--> $DIR/const_comparisons.rs:124:5
|
||||
|
|
||||
LL | status_code <= 500 && status_code < 500; // Useless left
|
||||
LL | status_code <= 500 && status_code < 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: right-hand side of `&&` operator has no effect
|
||||
--> $DIR/const_comparisons.rs:114:5
|
||||
--> $DIR/const_comparisons.rs:127:5
|
||||
|
|
||||
LL | status_code < 500 && status_code <= 500; // Useless right
|
||||
LL | status_code < 500 && status_code <= 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
note: `if `status_code < 500` evaluates to true, status_code <= 500` will always evaluate to true as well
|
||||
--> $DIR/const_comparisons.rs:114:23
|
||||
--> $DIR/const_comparisons.rs:127:23
|
||||
|
|
||||
LL | status_code < 500 && status_code <= 500; // Useless right
|
||||
LL | status_code < 500 && status_code <= 500;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:119:5
|
||||
--> $DIR/const_comparisons.rs:132:5
|
||||
|
|
||||
LL | name < "Jennifer" && name > "Shannon";
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -201,7 +201,7 @@ LL | name < "Jennifer" && name > "Shannon";
|
||||
= note: since `"Jennifer"` < `"Shannon"`, the expression evaluates to false for any value of `name`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:124:5
|
||||
--> $DIR/const_comparisons.rs:137:5
|
||||
|
|
||||
LL | numbers < [3, 4] && numbers > [5, 6];
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -209,7 +209,7 @@ LL | numbers < [3, 4] && numbers > [5, 6];
|
||||
= note: since `[3, 4]` < `[5, 6]`, the expression evaluates to false for any value of `numbers`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:129:5
|
||||
--> $DIR/const_comparisons.rs:142:5
|
||||
|
|
||||
LL | letter < 'b' && letter > 'c';
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
@ -217,7 +217,7 @@ LL | letter < 'b' && letter > 'c';
|
||||
= note: since `'b'` < `'c'`, the expression evaluates to false for any value of `letter`
|
||||
|
||||
error: boolean expression will never evaluate to 'true'
|
||||
--> $DIR/const_comparisons.rs:134:5
|
||||
--> $DIR/const_comparisons.rs:147:5
|
||||
|
|
||||
LL | area < std::f32::consts::E && area > std::f32::consts::PI;
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user