@@ -29,36 +29,21 @@ declare_clippy_lint! {
2929 "#[macro_use] is no longer needed"
3030}
3131
32- const BRACKETS : & [ char ] = & [ '<' , '>' ] ;
33-
3432#[ derive( Clone , Debug , PartialEq , Eq ) ]
3533struct PathAndSpan {
3634 path : String ,
3735 span : Span ,
3836}
3937
40- /// `MacroRefData` includes the name of the macro
41- /// and the path from `SourceMap::span_to_filename`.
38+ /// `MacroRefData` includes the name of the macro.
4239#[ derive( Debug , Clone ) ]
4340pub struct MacroRefData {
4441 name : String ,
45- path : String ,
4642}
4743
4844impl MacroRefData {
49- pub fn new ( name : String , callee : Span , cx : & LateContext < ' _ > ) -> Self {
50- let sm = cx. sess ( ) . source_map ( ) ;
51- let mut path = sm. filename_for_diagnostics ( & sm. span_to_filename ( callee) ) . to_string ( ) ;
52-
53- // std lib paths are <::std::module::file type>
54- // so remove brackets, space and type.
55- if path. contains ( '<' ) {
56- path = path. replace ( BRACKETS , "" ) ;
57- }
58- if path. contains ( ' ' ) {
59- path = path. split ( ' ' ) . next ( ) . unwrap ( ) . to_string ( ) ;
60- }
61- Self { name, path }
45+ pub fn new ( name : String ) -> Self {
46+ Self { name }
6247 }
6348}
6449
@@ -78,15 +63,15 @@ impl MacroUseImports {
7863 fn push_unique_macro ( & mut self , cx : & LateContext < ' _ > , span : Span ) {
7964 let call_site = span. source_callsite ( ) ;
8065 let name = snippet ( cx, cx. sess ( ) . source_map ( ) . span_until_char ( call_site, '!' ) , "_" ) ;
81- if let Some ( callee ) = span. source_callee ( ) {
66+ if let Some ( _callee ) = span. source_callee ( ) {
8267 if !self . collected . contains ( & call_site) {
8368 let name = if name. contains ( "::" ) {
8469 name. split ( "::" ) . last ( ) . unwrap ( ) . to_string ( )
8570 } else {
8671 name. to_string ( )
8772 } ;
8873
89- self . mac_refs . push ( MacroRefData :: new ( name, callee . def_site , cx ) ) ;
74+ self . mac_refs . push ( MacroRefData :: new ( name) ) ;
9075 self . collected . insert ( call_site) ;
9176 }
9277 }
@@ -95,10 +80,10 @@ impl MacroUseImports {
9580 fn push_unique_macro_pat_ty ( & mut self , cx : & LateContext < ' _ > , span : Span ) {
9681 let call_site = span. source_callsite ( ) ;
9782 let name = snippet ( cx, cx. sess ( ) . source_map ( ) . span_until_char ( call_site, '!' ) , "_" ) ;
98- if let Some ( callee ) = span. source_callee ( ) {
83+ if let Some ( _callee ) = span. source_callee ( ) {
9984 if !self . collected . contains ( & call_site) {
10085 self . mac_refs
101- . push ( MacroRefData :: new ( name. to_string ( ) , callee . def_site , cx ) ) ;
86+ . push ( MacroRefData :: new ( name. to_string ( ) ) ) ;
10287 self . collected . insert ( call_site) ;
10388 }
10489 }
0 commit comments