about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2025-07-23 13:57:12 +0000
committerbors <bors@rust-lang.org>2025-07-23 13:57:12 +0000
commit4ff3fa01cbdd468851b1b859541ee1c648cde7de (patch)
tree05c4213420d2f0a73a8e009c48bc480158bdde8b /src
parent5a30e4307f0506bed87eeecd171f8366fdbda1dc (diff)
parent3303534dc8825258f8a5d3a1b1e4572d55cccd9a (diff)
downloadrust-4ff3fa01cbdd468851b1b859541ee1c648cde7de.tar.gz
rust-4ff3fa01cbdd468851b1b859541ee1c648cde7de.zip
Auto merge of #143843 - JonathanBrouwer:macro-use-parser, r=oli-obk
Ports `#[macro_use]` and `#[macro_escape]` to the new attribute parsing infrastructure

Ports `#[macro_use]` and `#[macro_escape]` to the new attribute parsing infrastructure for https://github.com/rust-lang/rust/issues/131229#issuecomment-2971351163

r? `@jdonszelmann` `@oli-obk`
Diffstat (limited to 'src')
-rw-r--r--src/tools/clippy/clippy_lints/src/macro_use.rs8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/tools/clippy/clippy_lints/src/macro_use.rs b/src/tools/clippy/clippy_lints/src/macro_use.rs
index c1a26c5a9c7..d1a54df988f 100644
--- a/src/tools/clippy/clippy_lints/src/macro_use.rs
+++ b/src/tools/clippy/clippy_lints/src/macro_use.rs
@@ -7,8 +7,9 @@ use rustc_hir::{self as hir, AmbigArg};
 use rustc_lint::{LateContext, LateLintPass, LintContext};
 use rustc_session::impl_lint_pass;
 use rustc_span::edition::Edition;
-use rustc_span::{Span, sym};
+use rustc_span::{Span};
 use std::collections::BTreeMap;
+use rustc_attr_data_structures::{AttributeKind, find_attr};
 
 declare_clippy_lint! {
     /// ### What it does
@@ -99,15 +100,14 @@ impl LateLintPass<'_> for MacroUseImports {
             && let hir::ItemKind::Use(path, _kind) = &item.kind
             && let hir_id = item.hir_id()
             && let attrs = cx.tcx.hir_attrs(hir_id)
-            && let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use))
+            && let Some(mac_attr_span) = find_attr!(attrs, AttributeKind::MacroUse {span, ..} => *span)
             && let Some(Res::Def(DefKind::Mod, id)) = path.res.type_ns
             && !id.is_local()
         {
             for kid in cx.tcx.module_children(id) {
                 if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
-                    let span = mac_attr.span();
                     let def_path = cx.tcx.def_path_str(mac_id);
-                    self.imports.push((def_path, span, hir_id));
+                    self.imports.push((def_path, mac_attr_span, hir_id));
                 }
             }
         } else if item.span.from_expansion() {