@@ -7,8 +7,9 @@ use rustc_hir::{self as hir, AmbigArg};
77use rustc_lint:: { LateContext , LateLintPass , LintContext } ;
88use rustc_session:: impl_lint_pass;
99use rustc_span:: edition:: Edition ;
10- use rustc_span:: { Span , sym } ;
10+ use rustc_span:: { Span } ;
1111use std:: collections:: BTreeMap ;
12+ use rustc_attr_data_structures:: { AttributeKind , find_attr} ;
1213
1314declare_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