mirror of
https://github.com/rust-lang/rust-clippy
synced 2025-02-17 06:28:42 +00:00
blocks_in_conditions: do not warn if condition comes from macro
This commit is contained in:
parent
4b3a9c09f3
commit
c6079a6880
3 changed files with 33 additions and 0 deletions
|
@ -67,6 +67,11 @@ impl<'tcx> LateLintPass<'tcx> for BlocksInConditions {
|
|||
);
|
||||
|
||||
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…
Add table
Reference in a new issue