diff options
| author | Devin Ragotzy <devin.ragotzy@gmail.com> | 2021-08-03 08:19:13 -0400 |
|---|---|---|
| committer | Devin Ragotzy <devin.ragotzy@gmail.com> | 2021-08-03 08:19:13 -0400 |
| commit | bc7fac9526a157cff245c0bbd55e156b37292a0b (patch) | |
| tree | 1bc59410c5b90cdd0e316c4b8de3046521be9858 | |
| parent | 44d37a44bc9d6382424c903a624080bd8d9fa966 (diff) | |
| download | rust-bc7fac9526a157cff245c0bbd55e156b37292a0b.tar.gz rust-bc7fac9526a157cff245c0bbd55e156b37292a0b.zip | |
fixup! Lint inside macro when owned by current crate
| -rw-r--r-- | clippy_lints/src/nonstandard_macro_braces.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/clippy_lints/src/nonstandard_macro_braces.rs b/clippy_lints/src/nonstandard_macro_braces.rs index 2a318946656..99423b8a840 100644 --- a/clippy_lints/src/nonstandard_macro_braces.rs +++ b/clippy_lints/src/nonstandard_macro_braces.rs @@ -7,6 +7,7 @@ use clippy_utils::{diagnostics::span_lint_and_help, in_macro, is_direct_expn_of, use if_chain::if_chain; use rustc_ast::ast; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; +use rustc_hir::def_id::DefId; use rustc_lint::{EarlyContext, EarlyLintPass}; use rustc_session::{declare_tool_lint, impl_lint_pass}; use rustc_span::Span; @@ -95,9 +96,11 @@ impl EarlyLintPass for MacroBraces { fn is_offending_macro<'a>(cx: &EarlyContext<'_>, span: Span, mac_braces: &'a MacroBraces) -> Option<MacroInfo<'a>> { let unnested_or_local = || { let nested = in_macro(span.ctxt().outer_expn_data().call_site); - let in_local_macro = nested - && matches!(span.macro_backtrace().last().and_then(|e| e.macro_def_id), Some(defid) if defid.is_local()); - !nested || in_local_macro + !nested + || span + .macro_backtrace() + .last() + .map_or(false, |e| e.macro_def_id.map_or(false, DefId::is_local)) }; if_chain! { // Make sure we are only one level deep otherwise there are to many FP's |
