Skip to content

Commit b1fa7b9

Browse files
committed
Delegate utils::in_external_macro to rustc::lint::in_external_macro
1 parent b02e53d commit b1fa7b9

File tree

1 file changed

+3
-27
lines changed

1 file changed

+3
-27
lines changed

clippy_lints/src/utils/mod.rs

+3-27
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::str::FromStr;
1919
use std::rc::Rc;
2020
use syntax::ast::{self, LitKind};
2121
use syntax::attr;
22-
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, ExpnInfo, Span, DUMMY_SP};
22+
use syntax::codemap::{CompilerDesugaringKind, ExpnFormat, Span, DUMMY_SP};
2323
use syntax::errors::DiagnosticBuilder;
2424
use syntax::ptr::P;
2525
use syntax::symbol::keywords;
@@ -78,33 +78,9 @@ pub fn is_range_expression(span: Span) -> bool {
7878
}
7979

8080
/// Returns true if the macro that expanded the crate was outside of the
81-
/// current crate or was a
82-
/// compiler plugin.
81+
/// current crate or was a compiler plugin.
8382
pub fn in_external_macro<'a, T: LintContext<'a>>(cx: &T, span: Span) -> bool {
84-
/// Invokes `in_macro` with the expansion info of the given span slightly
85-
/// heavy, try to use
86-
/// this after other checks have already happened.
87-
fn in_macro_ext<'a, T: LintContext<'a>>(cx: &T, info: &ExpnInfo) -> bool {
88-
// no ExpnInfo = no macro
89-
if let ExpnFormat::MacroAttribute(..) = info.format {
90-
// these are all plugins
91-
return true;
92-
}
93-
// no span for the callee = external macro
94-
info.def_site.map_or(true, |span| {
95-
// no snippet = external macro or compiler-builtin expansion
96-
cx.sess()
97-
.codemap()
98-
.span_to_snippet(span)
99-
.ok()
100-
.map_or(true, |code| !code.starts_with("macro_rules"))
101-
})
102-
}
103-
104-
span.ctxt()
105-
.outer()
106-
.expn_info()
107-
.map_or(false, |info| in_macro_ext(cx, &info))
83+
::rustc::lint::in_external_macro(cx.sess(), span)
10884
}
10985

11086
/// Check if a `DefId`'s path matches the given absolute type path usage.

0 commit comments

Comments
 (0)