Skip to content

Commit e07a4ee

Browse files
Ports #[macro_use] and #[macro_escape] to the new attribute parsing infrastructure
1 parent 3ed170f commit e07a4ee

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

clippy_lints/src/macro_use.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ use rustc_hir::{self as hir, AmbigArg};
77
use rustc_lint::{LateContext, LateLintPass, LintContext};
88
use rustc_session::impl_lint_pass;
99
use rustc_span::edition::Edition;
10-
use rustc_span::{Span, sym};
10+
use rustc_span::{Span};
1111
use std::collections::BTreeMap;
12+
use rustc_attr_data_structures::{AttributeKind, find_attr};
1213

1314
declare_clippy_lint! {
1415
/// ### What it does
@@ -99,15 +100,14 @@ impl LateLintPass<'_> for MacroUseImports {
99100
&& let hir::ItemKind::Use(path, _kind) = &item.kind
100101
&& let hir_id = item.hir_id()
101102
&& let attrs = cx.tcx.hir_attrs(hir_id)
102-
&& let Some(mac_attr) = attrs.iter().find(|attr| attr.has_name(sym::macro_use))
103+
&& let Some(mac_attr_span) = find_attr!(attrs, AttributeKind::MacroUse {span, ..} => *span)
103104
&& let Some(Res::Def(DefKind::Mod, id)) = path.res.type_ns
104105
&& !id.is_local()
105106
{
106107
for kid in cx.tcx.module_children(id) {
107108
if let Res::Def(DefKind::Macro(_mac_type), mac_id) = kid.res {
108-
let span = mac_attr.span();
109109
let def_path = cx.tcx.def_path_str(mac_id);
110-
self.imports.push((def_path, span, hir_id));
110+
self.imports.push((def_path, mac_attr_span, hir_id));
111111
}
112112
}
113113
} else if item.span.from_expansion() {

0 commit comments

Comments
 (0)