"#[macro_use] is no longer needed"
}
-const BRACKETS: &[char] = &['<', '>'];
-
#[derive(Clone, Debug, PartialEq, Eq)]
struct PathAndSpan {
path: String,
span: Span,
}
-/// `MacroRefData` includes the name of the macro
-/// and the path from `SourceMap::span_to_filename`.
+/// `MacroRefData` includes the name of the macro.
#[derive(Debug, Clone)]
pub struct MacroRefData {
name: String,
- path: String,
}
impl MacroRefData {
- pub fn new(name: String, callee: Span, cx: &LateContext<'_>) -> Self {
- let sm = cx.sess().source_map();
- let mut path = sm.filename_for_diagnostics(&sm.span_to_filename(callee))
- .to_string();
-
- // std lib paths are <::std::module::file type>
- // so remove brackets, space and type.
- if path.contains('<') {
- path = path.replace(BRACKETS, "");
- }
- if path.contains(' ') {
- path = path.split(' ').next().unwrap().to_string();
- }
- Self { name, path }
+ pub fn new(name: String) -> Self {
+ Self { name }
}
}
fn push_unique_macro(&mut self, cx: &LateContext<'_>, span: Span) {
let call_site = span.source_callsite();
let name = snippet(cx, cx.sess().source_map().span_until_char(call_site, '!'), "_");
- if let Some(callee) = span.source_callee() {
+ if let Some(_callee) = span.source_callee() {
if !self.collected.contains(&call_site) {
let name = if name.contains("::") {
name.split("::").last().unwrap().to_string()
name.to_string()
};
- self.mac_refs.push(MacroRefData::new(name, callee.def_site, cx));
+ self.mac_refs.push(MacroRefData::new(name));
self.collected.insert(call_site);
}
}
fn push_unique_macro_pat_ty(&mut self, cx: &LateContext<'_>, span: Span) {
let call_site = span.source_callsite();
let name = snippet(cx, cx.sess().source_map().span_until_char(call_site, '!'), "_");
- if let Some(callee) = span.source_callee() {
+ if let Some(_callee) = span.source_callee() {
if !self.collected.contains(&call_site) {
self.mac_refs
- .push(MacroRefData::new(name.to_string(), callee.def_site, cx));
+ .push(MacroRefData::new(name.to_string()));
self.collected.insert(call_site);
}
}