Fix blocks_in_if_conditions false positive
This commit is contained in:
parent
07f4f7c2dd
commit
392b2eff4b
2 changed files with 13 additions and 3 deletions
|
|
@ -72,9 +72,11 @@ impl<'a, 'tcx> Visitor<'tcx> for ExVisitor<'a, 'tcx> {
|
|||
|
||||
let body = self.cx.tcx.hir().body(eid);
|
||||
let ex = &body.value;
|
||||
if matches!(ex.kind, ExprKind::Block(_, _)) && !body.value.span.from_expansion() {
|
||||
self.found_block = Some(ex);
|
||||
return;
|
||||
if let ExprKind::Block(block, _) = ex.kind {
|
||||
if !body.value.span.from_expansion() && !block.stmts.is_empty() {
|
||||
self.found_block = Some(ex);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
walk_expr(self, expr);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,14 @@ fn macro_in_closure() {
|
|||
}
|
||||
}
|
||||
|
||||
fn closure(_: impl FnMut()) -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
fn function_with_empty_closure() {
|
||||
if closure(|| {}) {}
|
||||
}
|
||||
|
||||
#[rustfmt::skip]
|
||||
fn main() {
|
||||
let mut range = 0..10;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue