@@ -7,8 +7,9 @@ use rustc_hir::{self as hir, AmbigArg};
7
7
use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
8
8
use rustc_session:: impl_lint_pass;
9
9
use rustc_span:: edition:: Edition ;
10
- use rustc_span:: { Span , sym } ;
10
+ use rustc_span:: { Span } ;
11
11
use std:: collections:: BTreeMap ;
12
+ use rustc_attr_data_structures:: { AttributeKind , find_attr} ;
12
13
13
14
declare_clippy_lint ! {
14
15
/// ### What it does
@@ -99,15 +100,14 @@ impl LateLintPass<'_> for MacroUseImports {
99
100
&& let hir:: ItemKind :: Use ( path, _kind) = & item. kind
100
101
&& let hir_id = item. hir_id ( )
101
102
&& 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 )
103
104
&& let Some ( Res :: Def ( DefKind :: Mod , id) ) = path. res . type_ns
104
105
&& !id. is_local ( )
105
106
{
106
107
for kid in cx. tcx . module_children ( id) {
107
108
if let Res :: Def ( DefKind :: Macro ( _mac_type) , mac_id) = kid. res {
108
- let span = mac_attr. span ( ) ;
109
109
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) ) ;
111
111
}
112
112
}
113
113
} else if item. span . from_expansion ( ) {
0 commit comments