Skip to content
Permalink
Browse files

move in_derive_expansion as Span method

  • Loading branch information
Centril committed Jan 9, 2020
1 parent 3a2af32 commit b93addba7add1f49249120b724023333db894055
Showing with 7 additions and 11 deletions.
  1. +0 −8 src/librustc/lint/mod.rs
  2. +2 −3 src/librustc/middle/stability.rs
  3. +5 −0 src/librustc_span/lib.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
}
@@ -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;
}

@@ -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())

0 comments on commit b93addb

Please sign in to comment.
You can’t perform that action at this time.