diff options
| -rw-r--r-- | src/librustc/lint/mod.rs | 8 | ||||
| -rw-r--r-- | src/librustc/middle/stability.rs | 5 | ||||
| -rw-r--r-- | src/librustc_span/lib.rs | 5 |
3 files changed, 7 insertions, 11 deletions
diff --git a/src/librustc/lint/mod.rs b/src/librustc/lint/mod.rs index 4afeb144948..944868e7909 100644 --- a/src/librustc/lint/mod.rs +++ b/src/librustc/lint/mod.rs @@ -494,11 +494,3 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool { ExpnKind::Macro(..) => true, // definitely a plugin } } - -/// Returns `true` if `span` originates in a derive-macro's expansion. -pub fn in_derive_expansion(span: Span) -> bool { - if let ExpnKind::Macro(MacroKind::Derive, _) = span.ctxt().outer_expn_data().kind { - return true; - } - false -} diff --git a/src/librustc/middle/stability.rs b/src/librustc/middle/stability.rs index 93fc09b4a2a..1176ffc79d2 100644 --- a/src/librustc/middle/stability.rs +++ b/src/librustc/middle/stability.rs @@ -3,7 +3,6 @@ pub use self::StabilityLevel::*; -use crate::lint::in_derive_expansion; use crate::session::{DiagnosticMessageId, Session}; use crate::ty::{self, TyCtxt}; use rustc_data_structures::fx::{FxHashMap, FxHashSet}; @@ -201,7 +200,7 @@ pub fn early_report_deprecation( lint: &'static Lint, span: Span, ) { - if in_derive_expansion(span) { + if span.in_derive_expansion() { return; } @@ -218,7 +217,7 @@ fn late_report_deprecation( def_id: DefId, hir_id: HirId, ) { - if in_derive_expansion(span) { + if span.in_derive_expansion() { return; } diff --git a/src/librustc_span/lib.rs b/src/librustc_span/lib.rs index 8cca59df338..f20cd6ae955 100644 --- a/src/librustc_span/lib.rs +++ b/src/librustc_span/lib.rs @@ -309,6 +309,11 @@ impl Span { self.ctxt() != SyntaxContext::root() } + /// Returns `true` if `span` originates in a derive-macro's expansion. + pub fn in_derive_expansion(self) -> bool { + matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _)) + } + #[inline] pub fn with_root_ctxt(lo: BytePos, hi: BytePos) -> Span { Span::new(lo, hi, SyntaxContext::root()) |
