@@ -50,21 +50,21 @@ declare_clippy_lint! {
5050 /// #[macro_use]
5151 /// use lazy_static;
5252 /// ```
53- pub MACRO_USE_IMPORT ,
53+ pub MACRO_USE_IMPORTS ,
5454 pedantic,
5555 "#[macro_use] is no longer needed"
5656}
5757
5858#[ derive( Default ) ]
59- pub struct MacroUseImport {
59+ pub struct MacroUseImports {
6060 /// the actual import path used and its span.
6161 imports : Vec < ( String , Span ) > ,
6262 /// the span of the macro reference and the `MacroRefData`
6363 /// for the use of the macro.
6464 collected : FxHashMap < Span , MacroRefData > ,
6565}
6666
67- impl MacroUseImport {
67+ impl MacroUseImports {
6868 fn import_path_mac ( & self , use_path : & str ) -> String {
6969 println ! ( "END {:?}" , use_path) ;
7070
@@ -79,12 +79,16 @@ impl MacroUseImport {
7979
8080fn paths_match ( mac : & MacroRefData , use_path : & str ) -> bool {
8181 let segs = mac. path . split ( "::" )
82- . filter ( |s| * s = = "" )
82+ . filter ( |s| * s ! = "" )
8383 . collect :: < Vec < _ > > ( ) ;
84+
85+ println ! ( "{:?}" , segs) ;
86+
8487 if segs. starts_with ( & [ "std" ] ) {
8588 return PRELUDE . iter ( ) . any ( |m| segs. contains ( m) )
8689 }
87- false
90+
91+ segs. starts_with ( & use_path. split ( "::" ) . collect :: < Vec < _ > > ( ) )
8892}
8993
9094fn make_path ( mac : & MacroRefData , use_path : & str ) -> String {
@@ -98,9 +102,9 @@ fn make_path(mac: &MacroRefData, use_path: &str) -> String {
98102 res
99103}
100104
101- impl_lint_pass ! ( MacroUseImport => [ MACRO_USE_IMPORT ] ) ;
105+ impl_lint_pass ! ( MacroUseImports => [ MACRO_USE_IMPORTS ] ) ;
102106
103- impl EarlyLintPass for MacroUseImport {
107+ impl EarlyLintPass for MacroUseImports {
104108 fn check_item ( & mut self , ecx : & EarlyContext < ' _ > , item : & ast:: Item ) {
105109 if_chain ! {
106110 if ecx. sess. opts. edition == Edition :: Edition2018 ;
@@ -175,7 +179,7 @@ impl EarlyLintPass for MacroUseImport {
175179 let help = format ! ( "use {}" , import_path) ;
176180 span_lint_and_sugg (
177181 ecx,
178- MACRO_USE_IMPORT ,
182+ MACRO_USE_IMPORTS ,
179183 * span,
180184 msg,
181185 // "remove the attribute and import the macro directly, try",
0 commit comments