Skip to content

Commit b93addb

Browse files
committed
move in_derive_expansion as Span method
1 parent 3a2af32 commit b93addb

File tree

3 files changed

+7
-11
lines changed

3 files changed

+7
-11
lines changed

src/librustc/lint/mod.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -494,11 +494,3 @@ pub fn in_external_macro(sess: &Session, span: Span) -> bool {
494494
ExpnKind::Macro(..) => true, // definitely a plugin
495495
}
496496
}
497-
498-
/// Returns `true` if `span` originates in a derive-macro's expansion.
499-
pub fn in_derive_expansion(span: Span) -> bool {
500-
if let ExpnKind::Macro(MacroKind::Derive, _) = span.ctxt().outer_expn_data().kind {
501-
return true;
502-
}
503-
false
504-
}

src/librustc/middle/stability.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
44
pub use self::StabilityLevel::*;
55

6-
use crate::lint::in_derive_expansion;
76
use crate::session::{DiagnosticMessageId, Session};
87
use crate::ty::{self, TyCtxt};
98
use rustc_data_structures::fx::{FxHashMap, FxHashSet};
@@ -201,7 +200,7 @@ pub fn early_report_deprecation(
201200
lint: &'static Lint,
202201
span: Span,
203202
) {
204-
if in_derive_expansion(span) {
203+
if span.in_derive_expansion() {
205204
return;
206205
}
207206

@@ -218,7 +217,7 @@ fn late_report_deprecation(
218217
def_id: DefId,
219218
hir_id: HirId,
220219
) {
221-
if in_derive_expansion(span) {
220+
if span.in_derive_expansion() {
222221
return;
223222
}
224223

src/librustc_span/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,6 +309,11 @@ impl Span {
309309
self.ctxt() != SyntaxContext::root()
310310
}
311311

312+
/// Returns `true` if `span` originates in a derive-macro's expansion.
313+
pub fn in_derive_expansion(self) -> bool {
314+
matches!(self.ctxt().outer_expn_data().kind, ExpnKind::Macro(MacroKind::Derive, _))
315+
}
316+
312317
#[inline]
313318
pub fn with_root_ctxt(lo: BytePos, hi: BytePos) -> Span {
314319
Span::new(lo, hi, SyntaxContext::root())

0 commit comments

Comments
 (0)