Auto merge of #12173 - samueltardieu:issue-12162, r=Manishearth
blocks_in_conditions: do not warn if condition comes from macro changelog: [`blocks_in_conditions`]: do not warn if condition comes from macro Fix #12162
This commit is contained in:
commit
6fd0258e45
@ -67,6 +67,11 @@ fn check_expr(&mut self, cx: &LateContext<'tcx>, expr: &'tcx Expr<'_>) {
|
||||
);
|
||||
|
||||
if let ExprKind::Block(block, _) = &cond.kind {
|
||||
if !block.span.eq_ctxt(expr.span) {
|
||||
// If the block comes from a macro, or as an argument to a macro,
|
||||
// do not lint.
|
||||
return;
|
||||
}
|
||||
if block.rules == BlockCheckMode::DefaultBlock {
|
||||
if block.stmts.is_empty() {
|
||||
if let Some(ex) = &block.expr {
|
||||
|
@ -85,4 +85,18 @@ fn block_in_match_expr(num: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
// issue #12162
|
||||
macro_rules! timed {
|
||||
($name:expr, $body:expr $(,)?) => {{
|
||||
let __scope = ();
|
||||
$body
|
||||
}};
|
||||
}
|
||||
|
||||
fn issue_12162() {
|
||||
if timed!("check this!", false) {
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
@ -85,4 +85,18 @@ fn block_in_match_expr(num: i32) -> i32 {
|
||||
}
|
||||
}
|
||||
|
||||
// issue #12162
|
||||
macro_rules! timed {
|
||||
($name:expr, $body:expr $(,)?) => {{
|
||||
let __scope = ();
|
||||
$body
|
||||
}};
|
||||
}
|
||||
|
||||
fn issue_12162() {
|
||||
if timed!("check this!", false) {
|
||||
println!();
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user