Skip to content

Commit bc7fac9

Browse files
committed
fixup! Lint inside macro when owned by current crate
1 parent 44d37a4 commit bc7fac9

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

clippy_lints/src/nonstandard_macro_braces.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use clippy_utils::{diagnostics::span_lint_and_help, in_macro, is_direct_expn_of,
77
use if_chain::if_chain;
88
use rustc_ast::ast;
99
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
10+
use rustc_hir::def_id::DefId;
1011
use rustc_lint::{EarlyContext, EarlyLintPass};
1112
use rustc_session::{declare_tool_lint, impl_lint_pass};
1213
use rustc_span::Span;
@@ -95,9 +96,11 @@ impl EarlyLintPass for MacroBraces {
9596
fn is_offending_macro<'a>(cx: &EarlyContext<'_>, span: Span, mac_braces: &'a MacroBraces) -> Option<MacroInfo<'a>> {
9697
let unnested_or_local = || {
9798
let nested = in_macro(span.ctxt().outer_expn_data().call_site);
98-
let in_local_macro = nested
99-
&& matches!(span.macro_backtrace().last().and_then(|e| e.macro_def_id), Some(defid) if defid.is_local());
100-
!nested || in_local_macro
99+
!nested
100+
|| span
101+
.macro_backtrace()
102+
.last()
103+
.map_or(false, |e| e.macro_def_id.map_or(false, DefId::is_local))
101104
};
102105
if_chain! {
103106
// Make sure we are only one level deep otherwise there are to many FP's

0 commit comments

Comments
 (0)