mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-23 05:03:21 +00:00
Cleanup
This commit is contained in:
parent
f39c6278e1
commit
7140eac484
2 changed files with 2 additions and 6 deletions
|
@ -56,10 +56,7 @@ struct ExVisitor<'v> {
|
|||
impl<'v> Visitor<'v> for ExVisitor<'v> {
|
||||
fn visit_expr(&mut self, expr: &'v Expr) {
|
||||
if let ExprClosure(_, _, ref expr, _) = expr.node {
|
||||
let complex = {
|
||||
matches!(expr.node, ExprBlock(_))
|
||||
};
|
||||
if complex {
|
||||
if matches!(expr.node, ExprBlock(_)) {
|
||||
self.found_block = Some(expr);
|
||||
return;
|
||||
}
|
||||
|
@ -111,7 +108,7 @@ impl LateLintPass for BlockInIfCondition {
|
|||
let mut visitor = ExVisitor { found_block: None };
|
||||
walk_expr(&mut visitor, check);
|
||||
if let Some(block) = visitor.found_block {
|
||||
span_help_and_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE, "");
|
||||
span_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,7 +27,6 @@ fn macro_if() {
|
|||
}
|
||||
|
||||
fn condition_has_block() -> i32 {
|
||||
|
||||
if { //~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'
|
||||
let x = 3;
|
||||
x == 3
|
||||
|
|
Loading…
Reference in a new issue