2017-07-27 04:51:09 +00:00
|
|
|
use std::cmp;
|
|
|
|
|
2019-02-05 17:20:45 +00:00
|
|
|
use crate::ich::StableHashingContext;
|
2019-12-24 04:02:53 +00:00
|
|
|
use rustc_data_structures::fx::FxHashMap;
|
2019-11-12 17:09:20 +00:00
|
|
|
use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
|
2020-03-21 02:13:14 +00:00
|
|
|
use rustc_errors::{DiagnosticBuilder, DiagnosticId};
|
2020-01-05 01:37:57 +00:00
|
|
|
use rustc_hir::HirId;
|
2020-03-11 11:49:08 +00:00
|
|
|
use rustc_session::lint::{builtin, Level, Lint, LintId};
|
2020-01-09 04:57:07 +00:00
|
|
|
use rustc_session::{DiagnosticMessageId, Session};
|
|
|
|
use rustc_span::hygiene::MacroKind;
|
|
|
|
use rustc_span::source_map::{DesugaringKind, ExpnKind, MultiSpan};
|
2020-06-15 18:17:35 +00:00
|
|
|
use rustc_span::{symbol, Span, Symbol, DUMMY_SP};
|
2020-01-09 05:42:42 +00:00
|
|
|
|
2020-01-09 04:20:28 +00:00
|
|
|
/// How a lint level was set.
|
|
|
|
#[derive(Clone, Copy, PartialEq, Eq, HashStable)]
|
2020-12-21 22:17:53 +00:00
|
|
|
pub enum LintLevelSource {
|
2020-01-09 04:20:28 +00:00
|
|
|
/// Lint is at the default level as declared
|
|
|
|
/// in rustc or a plugin.
|
|
|
|
Default,
|
|
|
|
|
|
|
|
/// Lint level was set by an attribute.
|
|
|
|
Node(Symbol, Span, Option<Symbol> /* RFC 2383 reason */),
|
|
|
|
|
|
|
|
/// Lint level was set by a command-line flag.
|
2020-11-02 06:37:26 +00:00
|
|
|
/// The provided `Level` is the level specified on the command line -
|
|
|
|
/// the actual level may be lower due to `--cap-lints`
|
|
|
|
CommandLine(Symbol, Level),
|
2020-01-09 04:20:28 +00:00
|
|
|
}
|
|
|
|
|
2020-12-21 22:17:53 +00:00
|
|
|
impl LintLevelSource {
|
2020-06-15 18:17:35 +00:00
|
|
|
pub fn name(&self) -> Symbol {
|
|
|
|
match *self {
|
2020-12-21 22:17:53 +00:00
|
|
|
LintLevelSource::Default => symbol::kw::Default,
|
|
|
|
LintLevelSource::Node(name, _, _) => name,
|
|
|
|
LintLevelSource::CommandLine(name, _) => name,
|
2020-06-15 18:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn span(&self) -> Span {
|
|
|
|
match *self {
|
2020-12-21 22:17:53 +00:00
|
|
|
LintLevelSource::Default => DUMMY_SP,
|
|
|
|
LintLevelSource::Node(_, span, _) => span,
|
|
|
|
LintLevelSource::CommandLine(_, _) => DUMMY_SP,
|
2020-06-15 18:17:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-12-21 22:17:53 +00:00
|
|
|
pub type LevelSource = (Level, LintLevelSource);
|
2020-01-09 04:20:28 +00:00
|
|
|
|
2017-07-27 04:51:09 +00:00
|
|
|
pub struct LintLevelSets {
|
2020-01-09 06:52:01 +00:00
|
|
|
pub list: Vec<LintSet>,
|
|
|
|
pub lint_cap: Level,
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
|
2020-01-09 06:52:01 +00:00
|
|
|
pub enum LintSet {
|
2017-07-27 04:51:09 +00:00
|
|
|
CommandLine {
|
|
|
|
// -A,-W,-D flags, a `Symbol` for the flag itself and `Level` for which
|
|
|
|
// flag.
|
2020-01-09 04:20:28 +00:00
|
|
|
specs: FxHashMap<LintId, LevelSource>,
|
2017-07-27 04:51:09 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
Node {
|
2020-01-09 04:20:28 +00:00
|
|
|
specs: FxHashMap<LintId, LevelSource>,
|
2017-07-27 04:51:09 +00:00
|
|
|
parent: u32,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
impl LintLevelSets {
|
2020-01-09 04:20:28 +00:00
|
|
|
pub fn new() -> Self {
|
2020-01-09 03:06:33 +00:00
|
|
|
LintLevelSets { list: Vec::new(), lint_cap: Level::Forbid }
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
|
2020-01-09 04:20:28 +00:00
|
|
|
pub fn get_lint_level(
|
2019-12-22 22:42:04 +00:00
|
|
|
&self,
|
|
|
|
lint: &'static Lint,
|
|
|
|
idx: u32,
|
2020-01-09 04:20:28 +00:00
|
|
|
aux: Option<&FxHashMap<LintId, LevelSource>>,
|
2019-12-22 22:42:04 +00:00
|
|
|
sess: &Session,
|
2020-01-09 04:20:28 +00:00
|
|
|
) -> LevelSource {
|
2017-08-13 12:37:24 +00:00
|
|
|
let (level, mut src) = self.get_lint_id_level(LintId::of(lint), idx, aux);
|
2017-07-27 04:51:09 +00:00
|
|
|
|
|
|
|
// If `level` is none then we actually assume the default level for this
|
|
|
|
// lint.
|
2019-11-12 16:52:26 +00:00
|
|
|
let mut level = level.unwrap_or_else(|| lint.default_level(sess.edition()));
|
2017-07-27 04:51:09 +00:00
|
|
|
|
|
|
|
// If we're about to issue a warning, check at the last minute for any
|
|
|
|
// directives against the warnings "lint". If, for example, there's an
|
|
|
|
// `allow(warnings)` in scope then we want to respect that instead.
|
|
|
|
if level == Level::Warn {
|
|
|
|
let (warnings_level, warnings_src) =
|
2020-01-09 04:20:28 +00:00
|
|
|
self.get_lint_id_level(LintId::of(builtin::WARNINGS), idx, aux);
|
2017-07-27 04:51:09 +00:00
|
|
|
if let Some(configured_warning_level) = warnings_level {
|
|
|
|
if configured_warning_level != Level::Warn {
|
|
|
|
level = configured_warning_level;
|
|
|
|
src = warnings_src;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that we never exceed the `--cap-lints` argument.
|
|
|
|
level = cmp::min(level, self.lint_cap);
|
|
|
|
|
2018-06-30 22:27:44 +00:00
|
|
|
if let Some(driver_level) = sess.driver_lint_caps.get(&LintId::of(lint)) {
|
|
|
|
// Ensure that we never exceed driver level.
|
|
|
|
level = cmp::min(*driver_level, level);
|
|
|
|
}
|
|
|
|
|
2020-03-20 14:03:11 +00:00
|
|
|
(level, src)
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
|
2020-01-09 04:20:28 +00:00
|
|
|
pub fn get_lint_id_level(
|
2019-12-22 22:42:04 +00:00
|
|
|
&self,
|
|
|
|
id: LintId,
|
|
|
|
mut idx: u32,
|
2020-01-09 04:20:28 +00:00
|
|
|
aux: Option<&FxHashMap<LintId, LevelSource>>,
|
2020-12-21 22:17:53 +00:00
|
|
|
) -> (Option<Level>, LintLevelSource) {
|
2017-08-13 12:37:24 +00:00
|
|
|
if let Some(specs) = aux {
|
|
|
|
if let Some(&(level, src)) = specs.get(&id) {
|
2019-12-22 22:42:04 +00:00
|
|
|
return (Some(level), src);
|
2017-08-13 12:37:24 +00:00
|
|
|
}
|
|
|
|
}
|
2017-07-27 04:51:09 +00:00
|
|
|
loop {
|
|
|
|
match self.list[idx as usize] {
|
|
|
|
LintSet::CommandLine { ref specs } => {
|
|
|
|
if let Some(&(level, src)) = specs.get(&id) {
|
2019-12-22 22:42:04 +00:00
|
|
|
return (Some(level), src);
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
2020-12-21 22:17:53 +00:00
|
|
|
return (None, LintLevelSource::Default);
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
LintSet::Node { ref specs, parent } => {
|
|
|
|
if let Some(&(level, src)) = specs.get(&id) {
|
2019-12-22 22:42:04 +00:00
|
|
|
return (Some(level), src);
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
idx = parent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub struct LintLevelMap {
|
2020-01-09 06:52:01 +00:00
|
|
|
pub sets: LintLevelSets,
|
|
|
|
pub id_to_set: FxHashMap<HirId, u32>,
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl LintLevelMap {
|
|
|
|
/// If the `id` was previously registered with `register_id` when building
|
|
|
|
/// this `LintLevelMap` this returns the corresponding lint level and source
|
|
|
|
/// of the lint level for the lint provided.
|
|
|
|
///
|
|
|
|
/// If the `id` was not previously registered, returns `None`. If `None` is
|
|
|
|
/// returned then the parent of `id` should be acquired and this function
|
|
|
|
/// should be called again.
|
2019-12-22 22:42:04 +00:00
|
|
|
pub fn level_and_source(
|
|
|
|
&self,
|
|
|
|
lint: &'static Lint,
|
|
|
|
id: HirId,
|
|
|
|
session: &Session,
|
2020-01-09 04:20:28 +00:00
|
|
|
) -> Option<LevelSource> {
|
2019-12-22 22:42:04 +00:00
|
|
|
self.id_to_set.get(&id).map(|idx| self.sets.get_lint_level(lint, *idx, None, session))
|
2017-07-27 04:51:09 +00:00
|
|
|
}
|
|
|
|
}
|
2017-08-14 16:19:42 +00:00
|
|
|
|
2018-01-16 09:16:38 +00:00
|
|
|
impl<'a> HashStable<StableHashingContext<'a>> for LintLevelMap {
|
2017-08-14 16:19:42 +00:00
|
|
|
#[inline]
|
2019-09-26 22:54:39 +00:00
|
|
|
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
|
2019-12-22 22:42:04 +00:00
|
|
|
let LintLevelMap { ref sets, ref id_to_set } = *self;
|
2017-08-14 16:19:42 +00:00
|
|
|
|
2017-09-13 16:20:27 +00:00
|
|
|
id_to_set.hash_stable(hcx, hasher);
|
2017-08-14 16:19:42 +00:00
|
|
|
|
2019-12-22 22:42:04 +00:00
|
|
|
let LintLevelSets { ref list, lint_cap } = *sets;
|
2017-08-14 16:19:42 +00:00
|
|
|
|
|
|
|
lint_cap.hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
hcx.while_hashing_spans(true, |hcx| {
|
|
|
|
list.len().hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
// We are working under the assumption here that the list of
|
|
|
|
// lint-sets is built in a deterministic order.
|
|
|
|
for lint_set in list {
|
|
|
|
::std::mem::discriminant(lint_set).hash_stable(hcx, hasher);
|
|
|
|
|
|
|
|
match *lint_set {
|
|
|
|
LintSet::CommandLine { ref specs } => {
|
2017-09-13 16:20:27 +00:00
|
|
|
specs.hash_stable(hcx, hasher);
|
2017-08-14 16:19:42 +00:00
|
|
|
}
|
|
|
|
LintSet::Node { ref specs, parent } => {
|
2017-09-13 16:20:27 +00:00
|
|
|
specs.hash_stable(hcx, hasher);
|
2017-08-14 16:19:42 +00:00
|
|
|
parent.hash_stable(hcx, hasher);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
2020-01-09 04:57:07 +00:00
|
|
|
|
2020-01-31 12:24:57 +00:00
|
|
|
pub struct LintDiagnosticBuilder<'a>(DiagnosticBuilder<'a>);
|
|
|
|
|
|
|
|
impl<'a> LintDiagnosticBuilder<'a> {
|
|
|
|
/// Return the inner DiagnosticBuilder, first setting the primary message to `msg`.
|
|
|
|
pub fn build(mut self, msg: &str) -> DiagnosticBuilder<'a> {
|
|
|
|
self.0.set_primary_message(msg);
|
|
|
|
self.0
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Create a LintDiagnosticBuilder from some existing DiagnosticBuilder.
|
2020-02-01 23:47:58 +00:00
|
|
|
pub fn new(err: DiagnosticBuilder<'a>) -> LintDiagnosticBuilder<'a> {
|
2020-01-31 12:24:57 +00:00
|
|
|
LintDiagnosticBuilder(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-01-31 20:57:50 +00:00
|
|
|
pub fn struct_lint_level<'s, 'd>(
|
2020-01-31 12:24:57 +00:00
|
|
|
sess: &'s Session,
|
2020-01-09 04:57:07 +00:00
|
|
|
lint: &'static Lint,
|
|
|
|
level: Level,
|
2020-12-21 22:17:53 +00:00
|
|
|
src: LintLevelSource,
|
2020-01-09 04:57:07 +00:00
|
|
|
span: Option<MultiSpan>,
|
2020-01-31 20:57:50 +00:00
|
|
|
decorate: impl for<'a> FnOnce(LintDiagnosticBuilder<'a>) + 'd,
|
|
|
|
) {
|
|
|
|
// Avoid codegen bloat from monomorphization by immediately doing dyn dispatch of `decorate` to
|
|
|
|
// the "real" work.
|
|
|
|
fn struct_lint_level_impl(
|
|
|
|
sess: &'s Session,
|
|
|
|
lint: &'static Lint,
|
|
|
|
level: Level,
|
2020-12-21 22:17:53 +00:00
|
|
|
src: LintLevelSource,
|
2020-01-31 20:57:50 +00:00
|
|
|
span: Option<MultiSpan>,
|
2020-02-01 23:47:58 +00:00
|
|
|
decorate: Box<dyn for<'b> FnOnce(LintDiagnosticBuilder<'b>) + 'd>,
|
|
|
|
) {
|
2020-08-13 19:41:52 +00:00
|
|
|
// Check for future incompatibility lints and issue a stronger warning.
|
|
|
|
let lint_id = LintId::of(lint);
|
|
|
|
let future_incompatible = lint.future_incompatible;
|
|
|
|
|
|
|
|
let has_future_breakage =
|
|
|
|
future_incompatible.map_or(false, |incompat| incompat.future_breakage.is_some());
|
|
|
|
|
2020-01-31 20:57:50 +00:00
|
|
|
let mut err = match (level, span) {
|
2020-08-13 19:41:52 +00:00
|
|
|
(Level::Allow, span) => {
|
|
|
|
if has_future_breakage {
|
|
|
|
if let Some(span) = span {
|
|
|
|
sess.struct_span_allow(span, "")
|
|
|
|
} else {
|
|
|
|
sess.struct_allow("")
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
return;
|
|
|
|
}
|
2020-01-31 20:57:50 +00:00
|
|
|
}
|
|
|
|
(Level::Warn, Some(span)) => sess.struct_span_warn(span, ""),
|
|
|
|
(Level::Warn, None) => sess.struct_warn(""),
|
2020-04-17 00:38:52 +00:00
|
|
|
(Level::Deny | Level::Forbid, Some(span)) => sess.struct_span_err(span, ""),
|
|
|
|
(Level::Deny | Level::Forbid, None) => sess.struct_err(""),
|
2020-01-31 20:57:50 +00:00
|
|
|
};
|
2020-01-09 04:57:07 +00:00
|
|
|
|
2020-01-31 20:57:50 +00:00
|
|
|
// If this code originates in a foreign macro, aka something that this crate
|
|
|
|
// did not itself author, then it's likely that there's nothing this crate
|
|
|
|
// can do about it. We probably want to skip the lint entirely.
|
|
|
|
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
|
|
|
|
// Any suggestions made here are likely to be incorrect, so anything we
|
|
|
|
// emit shouldn't be automatically fixed by rustfix.
|
|
|
|
err.allow_suggestions(false);
|
|
|
|
|
|
|
|
// If this is a future incompatible lint it'll become a hard error, so
|
2020-07-07 15:12:44 +00:00
|
|
|
// we have to emit *something*. Also, if this lint occurs in the
|
|
|
|
// expansion of a macro from an external crate, allow individual lints
|
|
|
|
// to opt-out from being reported.
|
2020-01-31 20:57:50 +00:00
|
|
|
if future_incompatible.is_none() && !lint.report_in_external_macro {
|
|
|
|
err.cancel();
|
|
|
|
// Don't continue further, since we don't want to have
|
|
|
|
// `diag_span_note_once` called for a diagnostic that isn't emitted.
|
|
|
|
return;
|
|
|
|
}
|
2020-01-09 04:57:07 +00:00
|
|
|
}
|
2020-01-31 20:57:50 +00:00
|
|
|
|
|
|
|
let name = lint.name_lower();
|
|
|
|
match src {
|
2020-12-21 22:17:53 +00:00
|
|
|
LintLevelSource::Default => {
|
2020-01-09 04:57:07 +00:00
|
|
|
sess.diag_note_once(
|
|
|
|
&mut err,
|
|
|
|
DiagnosticMessageId::from(lint),
|
2020-01-31 20:57:50 +00:00
|
|
|
&format!("`#[{}({})]` on by default", level.as_str(), name),
|
2020-01-09 04:57:07 +00:00
|
|
|
);
|
|
|
|
}
|
2020-12-21 22:17:53 +00:00
|
|
|
LintLevelSource::CommandLine(lint_flag_val, orig_level) => {
|
2020-11-02 06:37:26 +00:00
|
|
|
let flag = match orig_level {
|
2020-01-31 20:57:50 +00:00
|
|
|
Level::Warn => "-W",
|
|
|
|
Level::Deny => "-D",
|
|
|
|
Level::Forbid => "-F",
|
2020-11-02 06:37:26 +00:00
|
|
|
Level::Allow => "-A",
|
2020-01-31 20:57:50 +00:00
|
|
|
};
|
|
|
|
let hyphen_case_lint_name = name.replace("_", "-");
|
|
|
|
if lint_flag_val.as_str() == name {
|
|
|
|
sess.diag_note_once(
|
|
|
|
&mut err,
|
|
|
|
DiagnosticMessageId::from(lint),
|
|
|
|
&format!(
|
|
|
|
"requested on the command line with `{} {}`",
|
|
|
|
flag, hyphen_case_lint_name
|
|
|
|
),
|
|
|
|
);
|
|
|
|
} else {
|
|
|
|
let hyphen_case_flag_val = lint_flag_val.as_str().replace("_", "-");
|
|
|
|
sess.diag_note_once(
|
|
|
|
&mut err,
|
|
|
|
DiagnosticMessageId::from(lint),
|
|
|
|
&format!(
|
|
|
|
"`{} {}` implied by `{} {}`",
|
|
|
|
flag, hyphen_case_lint_name, flag, hyphen_case_flag_val
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2020-01-09 04:57:07 +00:00
|
|
|
}
|
2020-12-21 22:17:53 +00:00
|
|
|
LintLevelSource::Node(lint_attr_name, src, reason) => {
|
2020-01-31 20:57:50 +00:00
|
|
|
if let Some(rationale) = reason {
|
|
|
|
err.note(&rationale.as_str());
|
|
|
|
}
|
|
|
|
sess.diag_span_note_once(
|
2020-01-09 04:57:07 +00:00
|
|
|
&mut err,
|
|
|
|
DiagnosticMessageId::from(lint),
|
2020-01-31 20:57:50 +00:00
|
|
|
src,
|
|
|
|
"the lint level is defined here",
|
2020-01-09 04:57:07 +00:00
|
|
|
);
|
2020-01-31 20:57:50 +00:00
|
|
|
if lint_attr_name.as_str() != name {
|
|
|
|
let level_str = level.as_str();
|
|
|
|
sess.diag_note_once(
|
|
|
|
&mut err,
|
|
|
|
DiagnosticMessageId::from(lint),
|
|
|
|
&format!(
|
|
|
|
"`#[{}({})]` implied by `#[{}({})]`",
|
|
|
|
level_str, name, level_str, lint_attr_name
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
2020-01-09 04:57:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-13 19:41:52 +00:00
|
|
|
err.code(DiagnosticId::Lint { name, has_future_breakage });
|
2020-01-31 20:57:50 +00:00
|
|
|
|
|
|
|
if let Some(future_incompatible) = future_incompatible {
|
|
|
|
const STANDARD_MESSAGE: &str = "this was previously accepted by the compiler but is being phased out; \
|
|
|
|
it will become a hard error";
|
|
|
|
|
|
|
|
let explanation = if lint_id == LintId::of(builtin::UNSTABLE_NAME_COLLISIONS) {
|
|
|
|
"once this method is added to the standard library, \
|
|
|
|
the ambiguity may cause an error or change in behavior!"
|
|
|
|
.to_owned()
|
|
|
|
} else if lint_id == LintId::of(builtin::MUTABLE_BORROW_RESERVATION_CONFLICT) {
|
|
|
|
"this borrowing pattern was not meant to be accepted, \
|
|
|
|
and may become a hard error in the future"
|
|
|
|
.to_owned()
|
|
|
|
} else if let Some(edition) = future_incompatible.edition {
|
|
|
|
format!("{} in the {} edition!", STANDARD_MESSAGE, edition)
|
|
|
|
} else {
|
|
|
|
format!("{} in a future release!", STANDARD_MESSAGE)
|
|
|
|
};
|
|
|
|
let citation = format!("for more information, see {}", future_incompatible.reference);
|
|
|
|
err.warn(&explanation);
|
|
|
|
err.note(&citation);
|
|
|
|
}
|
2020-01-09 04:57:07 +00:00
|
|
|
|
2020-01-31 20:57:50 +00:00
|
|
|
// Finally, run `decorate`. This function is also responsible for emitting the diagnostic.
|
|
|
|
decorate(LintDiagnosticBuilder::new(err));
|
|
|
|
}
|
|
|
|
struct_lint_level_impl(sess, lint, level, src, span, Box::new(decorate))
|
2020-01-09 04:57:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/// Returns whether `span` originates in a foreign crate's external macro.
|
|
|
|
///
|
|
|
|
/// This is used to test whether a lint should not even begin to figure out whether it should
|
|
|
|
/// be reported on the current node.
|
|
|
|
pub fn in_external_macro(sess: &Session, span: Span) -> bool {
|
|
|
|
let expn_data = span.ctxt().outer_expn_data();
|
|
|
|
match expn_data.kind {
|
2020-09-19 16:56:32 +00:00
|
|
|
ExpnKind::Inlined | ExpnKind::Root | ExpnKind::Desugaring(DesugaringKind::ForLoop(_)) => {
|
|
|
|
false
|
|
|
|
}
|
2020-01-09 04:57:07 +00:00
|
|
|
ExpnKind::AstPass(_) | ExpnKind::Desugaring(_) => true, // well, it's "external"
|
|
|
|
ExpnKind::Macro(MacroKind::Bang, _) => {
|
2019-11-13 12:01:43 +00:00
|
|
|
// Dummy span for the `def_site` means it's an external macro.
|
|
|
|
expn_data.def_site.is_dummy() || sess.source_map().is_imported(expn_data.def_site)
|
2020-01-09 04:57:07 +00:00
|
|
|
}
|
2020-03-17 15:45:02 +00:00
|
|
|
ExpnKind::Macro { .. } => true, // definitely a plugin
|
2020-01-09 04:57:07 +00:00
|
|
|
}
|
|
|
|
}
|