Skip to content

Commit d36c785

Browse files
committed
Allow block_in_if_{stmt,expr} in external macro
1 parent 949b347 commit d36c785

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

clippy_lints/src/block_in_if_condition.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::utils::*;
22
use matches::matches;
33
use rustc::hir::intravisit::{walk_expr, NestedVisitorMap, Visitor};
44
use rustc::hir::*;
5-
use rustc::lint::{LateContext, LateLintPass, LintArray, LintPass};
5+
use rustc::lint::{in_external_macro, LateContext, LateLintPass, LintArray, LintContext, LintPass};
66
use rustc::{declare_lint_pass, declare_tool_lint};
77

88
declare_clippy_lint! {
@@ -72,6 +72,9 @@ const COMPLEX_BLOCK_MESSAGE: &str = "in an 'if' condition, avoid complex blocks
7272

7373
impl<'a, 'tcx> LateLintPass<'a, 'tcx> for BlockInIfCondition {
7474
fn check_expr(&mut self, cx: &LateContext<'a, 'tcx>, expr: &'tcx Expr) {
75+
if in_external_macro(cx.sess(), expr.span) {
76+
return;
77+
}
7578
if let Some((check, then, _)) = higher::if_block(&expr) {
7679
if let ExprKind::Block(block, _) = &check.node {
7780
if block.rules == DefaultBlock {

0 commit comments

Comments
 (0)