@@ -29,36 +29,21 @@ declare_clippy_lint! {
29
29
"#[macro_use] is no longer needed"
30
30
}
31
31
32
- const BRACKETS : & [ char ] = & [ '<' , '>' ] ;
33
-
34
32
#[ derive( Clone , Debug , PartialEq , Eq ) ]
35
33
struct PathAndSpan {
36
34
path : String ,
37
35
span : Span ,
38
36
}
39
37
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.
42
39
#[ derive( Debug , Clone ) ]
43
40
pub struct MacroRefData {
44
41
name : String ,
45
- path : String ,
46
42
}
47
43
48
44
impl 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 }
62
47
}
63
48
}
64
49
@@ -78,15 +63,15 @@ impl MacroUseImports {
78
63
fn push_unique_macro ( & mut self , cx : & LateContext < ' _ > , span : Span ) {
79
64
let call_site = span. source_callsite ( ) ;
80
65
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 ( ) {
82
67
if !self . collected . contains ( & call_site) {
83
68
let name = if name. contains ( "::" ) {
84
69
name. split ( "::" ) . last ( ) . unwrap ( ) . to_string ( )
85
70
} else {
86
71
name. to_string ( )
87
72
} ;
88
73
89
- self . mac_refs . push ( MacroRefData :: new ( name, callee . def_site , cx ) ) ;
74
+ self . mac_refs . push ( MacroRefData :: new ( name) ) ;
90
75
self . collected . insert ( call_site) ;
91
76
}
92
77
}
@@ -95,10 +80,10 @@ impl MacroUseImports {
95
80
fn push_unique_macro_pat_ty ( & mut self , cx : & LateContext < ' _ > , span : Span ) {
96
81
let call_site = span. source_callsite ( ) ;
97
82
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 ( ) {
99
84
if !self . collected . contains ( & call_site) {
100
85
self . mac_refs
101
- . push ( MacroRefData :: new ( name. to_string ( ) , callee . def_site , cx ) ) ;
86
+ . push ( MacroRefData :: new ( name. to_string ( ) ) ) ;
102
87
self . collected . insert ( call_site) ;
103
88
}
104
89
}
0 commit comments