Skip to content

Commit 7140eac

Browse files
committed
Cleanup
1 parent f39c627 commit 7140eac

File tree

2 files changed

+2
-6
lines changed

2 files changed

+2
-6
lines changed

clippy_lints/src/block_in_if_condition.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,7 @@ struct ExVisitor<'v> {
5656
impl<'v> Visitor<'v> for ExVisitor<'v> {
5757
fn visit_expr(&mut self, expr: &'v Expr) {
5858
if let ExprClosure(_, _, ref expr, _) = expr.node {
59-
let complex = {
60-
matches!(expr.node, ExprBlock(_))
61-
};
62-
if complex {
59+
if matches!(expr.node, ExprBlock(_)) {
6360
self.found_block = Some(expr);
6461
return;
6562
}
@@ -111,7 +108,7 @@ impl LateLintPass for BlockInIfCondition {
111108
let mut visitor = ExVisitor { found_block: None };
112109
walk_expr(&mut visitor, check);
113110
if let Some(block) = visitor.found_block {
114-
span_help_and_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE, "");
111+
span_lint(cx, BLOCK_IN_IF_CONDITION_STMT, block.span, COMPLEX_BLOCK_MESSAGE);
115112
}
116113
}
117114
}

tests/compile-fail/block_in_if_condition.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ fn macro_if() {
2727
}
2828

2929
fn condition_has_block() -> i32 {
30-
3130
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'
3231
let x = 3;
3332
x == 3

0 commit comments

Comments
 (0)