]> git.lizzy.rs Git - rust.git/commitdiff
Delegate utils::in_external_macro to rustc::lint::in_external_macro
authorDale Wijnand <dale.wijnand@gmail.com>
Tue, 24 Jul 2018 06:49:39 +0000 (07:49 +0100)
committerDale Wijnand <dale.wijnand@gmail.com>
Tue, 24 Jul 2018 09:34:18 +0000 (10:34 +0100)
clippy_lints/src/utils/mod.rs

index 8e83b8d81f2e4f06dc5c64d1062aac0cf5f22e6f..91bb73a9bf404a5d65078c368e12fb94403f296b 100644 (file)
@@ -19,7 +19,7 @@
 use std::rc::Rc;
 use syntax::ast::{self, LitKind};
 use syntax::attr;
-use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, ExpnInfo, Span, DUMMY_SP};
+use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, Span, DUMMY_SP};
 use syntax::errors::DiagnosticBuilder;
 use syntax::ptr::P;
 use syntax::symbol::keywords;
@@ -78,33 +78,9 @@ pub fn is_range_expression(span: Span) -> bool {
 }
 
 /// Returns true if the macro that expanded the crate was outside of the
-/// current crate or was a
-/// compiler plugin.
+/// current crate or was a compiler plugin.
 pub fn in_external_macro<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
-    /// Invokes `in_macro` with the expansion info of the given span slightly
-    /// heavy, try to use
-    /// this after other checks have already happened.
-    fn in_macro_ext<'a, T: LintContext<'a>>(cx: &T, info: &ExpnInfo) -> bool {
-        // no ExpnInfo = no macro
-        if let ExpnFormat::MacroAttribute(..) = info.format {
-            // these are all plugins
-            return true;
-        }
-        // no span for the callee = external macro
-        info.def_site.map_or(true, |span| {
-            // no snippet = external macro or compiler-builtin expansion
-            cx.sess()
-                .codemap()
-                .span_to_snippet(span)
-                .ok()
-                .map_or(true, |code| !code.starts_with("macro_rules"))
-        })
-    }
-
-    span.ctxt()
-        .outer()
-        .expn_info()
-        .map_or(false, |info| in_macro_ext(cx, &info))
+    ::rustc::lint::in_external_macro(cx.sess(), span)
 }
 
 /// Check if a `DefId`'s path matches the given absolute type path usage.