Auto merge of #8100 - c410-f3r:blah-blah-blah, r=giraffate
Fix `blocks_in_if_conditions` false positive Fix #8099 changelog: Fix [`blocks_in_if_conditions`] false positive with an empty closure
This commit is contained in:
commit
aa3648af50
@ -73,9 +73,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…
x
Reference in New Issue
Block a user