mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-18 09:03:18 +00:00
62 lines
1.8 KiB
Text
62 lines
1.8 KiB
Text
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
|
|
--> $DIR/block_in_if_condition.rs:35:8
|
|
|
|
|
35 | if {
|
|
| ________^
|
|
36 | | let x = 3;
|
|
37 | | x == 3
|
|
38 | | } {
|
|
| |_____^
|
|
|
|
|
= note: `-D clippy::block-in-if-condition-stmt` implied by `-D warnings`
|
|
= help: try
|
|
let res = {
|
|
let x = 3;
|
|
x == 3
|
|
};
|
|
if res {
|
|
6
|
|
} ...
|
|
|
|
error: omit braces around single expression condition
|
|
--> $DIR/block_in_if_condition.rs:46:8
|
|
|
|
|
46 | if { true } {
|
|
| ^^^^^^^^
|
|
|
|
|
= note: `-D clippy::block-in-if-condition-expr` implied by `-D warnings`
|
|
= help: try
|
|
if true {
|
|
6
|
|
} ...
|
|
|
|
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
|
|
--> $DIR/block_in_if_condition.rs:66:17
|
|
|
|
|
66 | |x| {
|
|
| _________________^
|
|
67 | | let target = 3;
|
|
68 | | x == target
|
|
69 | | },
|
|
| |_____________^
|
|
|
|
error: in an 'if' condition, avoid complex blocks or closures with blocks; instead, move the block or closure higher and bind it with a 'let'
|
|
--> $DIR/block_in_if_condition.rs:75:13
|
|
|
|
|
75 | |x| {
|
|
| _____________^
|
|
76 | | let target = 3;
|
|
77 | | x == target
|
|
78 | | },
|
|
| |_________^
|
|
|
|
error: this boolean expression can be simplified
|
|
--> $DIR/block_in_if_condition.rs:85:8
|
|
|
|
|
85 | if true && x == 3 {
|
|
| ^^^^^^^^^^^^^^ help: try: `x == 3`
|
|
|
|
|
= note: `-D clippy::nonminimal-bool` implied by `-D warnings`
|
|
|
|
error: aborting due to 5 previous errors
|
|
|