@@ -50,21 +50,21 @@ declare_clippy_lint! {
50
50
/// #[macro_use]
51
51
/// use lazy_static;
52
52
/// ```
53
- pub MACRO_USE_IMPORT ,
53
+ pub MACRO_USE_IMPORTS ,
54
54
pedantic,
55
55
"#[macro_use] is no longer needed"
56
56
}
57
57
58
58
#[ derive( Default ) ]
59
- pub struct MacroUseImport {
59
+ pub struct MacroUseImports {
60
60
/// the actual import path used and its span.
61
61
imports : Vec < ( String , Span ) > ,
62
62
/// the span of the macro reference and the `MacroRefData`
63
63
/// for the use of the macro.
64
64
collected : FxHashMap < Span , MacroRefData > ,
65
65
}
66
66
67
- impl MacroUseImport {
67
+ impl MacroUseImports {
68
68
fn import_path_mac ( & self , use_path : & str ) -> String {
69
69
println ! ( "END {:?}" , use_path) ;
70
70
@@ -79,12 +79,16 @@ impl MacroUseImport {
79
79
80
80
fn paths_match ( mac : & MacroRefData , use_path : & str ) -> bool {
81
81
let segs = mac. path . split ( "::" )
82
- . filter ( |s| * s = = "" )
82
+ . filter ( |s| * s ! = "" )
83
83
. collect :: < Vec < _ > > ( ) ;
84
+
85
+ println ! ( "{:?}" , segs) ;
86
+
84
87
if segs. starts_with ( & [ "std" ] ) {
85
88
return PRELUDE . iter ( ) . any ( |m| segs. contains ( m) )
86
89
}
87
- false
90
+
91
+ segs. starts_with ( & use_path. split ( "::" ) . collect :: < Vec < _ > > ( ) )
88
92
}
89
93
90
94
fn make_path ( mac : & MacroRefData , use_path : & str ) -> String {
@@ -98,9 +102,9 @@ fn make_path(mac: &MacroRefData, use_path: &str) -> String {
98
102
res
99
103
}
100
104
101
- impl_lint_pass ! ( MacroUseImport => [ MACRO_USE_IMPORT ] ) ;
105
+ impl_lint_pass ! ( MacroUseImports => [ MACRO_USE_IMPORTS ] ) ;
102
106
103
- impl EarlyLintPass for MacroUseImport {
107
+ impl EarlyLintPass for MacroUseImports {
104
108
fn check_item ( & mut self , ecx : & EarlyContext < ' _ > , item : & ast:: Item ) {
105
109
if_chain ! {
106
110
if ecx. sess. opts. edition == Edition :: Edition2018 ;
@@ -175,7 +179,7 @@ impl EarlyLintPass for MacroUseImport {
175
179
let help = format ! ( "use {}" , import_path) ;
176
180
span_lint_and_sugg (
177
181
ecx,
178
- MACRO_USE_IMPORT ,
182
+ MACRO_USE_IMPORTS ,
179
183
* span,
180
184
msg,
181
185
// "remove the attribute and import the macro directly, try",
0 commit comments