]> git.lizzy.rs Git - rust.git/blobdiff - src/tools/clippy/clippy_lints/src/macro_use.rs
Auto merge of #88865 - guswynn:must_not_suspend, r=oli-obk
[rust.git] / src / tools / clippy / clippy_lints / src / macro_use.rs
index 39f7ade3f81f6cbbf8c824e9c58f9820b1d40d64..41e6ad12d058923a9af3d1a1b616bd7d650ced23 100644 (file)
     "#[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 }
     }
 }
 
@@ -79,7 +63,7 @@ impl MacroUseImports {
     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()
@@ -87,7 +71,7 @@ fn push_unique_macro(&mut self, cx: &LateContext<'_>, span: Span) {
                     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);
             }
         }
@@ -96,10 +80,10 @@ fn push_unique_macro(&mut self, cx: &LateContext<'_>, span: Span) {
     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);
             }
         }