use hir;
use lint::builtin::BuiltinLintDiagnostics;
use session::{Session, DiagnosticMessageId};
-use std::hash;
+use std::{hash, ptr};
use syntax::ast;
use syntax::codemap::{MultiSpan, ExpnFormat};
use syntax::edition::Edition;
/// Starting at the given edition, default to the given lint level. If this is `None`, then use
/// `default_level`.
pub edition_lint_opts: Option<(Edition, Level)>,
+
+ /// Whether this lint is reported even inside expansions of external macros
+ pub report_in_external_macro: bool,
}
impl Lint {
#[macro_export]
macro_rules! declare_lint {
($vis: vis $NAME: ident, $Level: ident, $desc: expr) => (
+ declare_lint!{$vis $NAME, $Level, $desc, false}
+ );
+ ($vis: vis $NAME: ident, $Level: ident, $desc: expr, report_in_external_macro: $rep: expr) => (
+ declare_lint!{$vis $NAME, $Level, $desc, $rep}
+ );
+ ($vis: vis $NAME: ident, $Level: ident, $desc: expr, $external: expr) => (
$vis static $NAME: &$crate::lint::Lint = &$crate::lint::Lint {
name: stringify!($NAME),
default_level: $crate::lint::$Level,
desc: $desc,
edition_lint_opts: None,
+ report_in_external_macro: $external,
};
);
($vis: vis $NAME: ident, $Level: ident, $desc: expr,
default_level: $crate::lint::$Level,
desc: $desc,
edition_lint_opts: Some(($lint_edition, $crate::lint::Level::$edition_level)),
+ report_in_external_macro: false,
};
);
}
impl PartialEq for LintId {
fn eq(&self, other: &LintId) -> bool {
- (self.lint as *const Lint) == (other.lint as *const Lint)
+ ptr::eq(self.lint, other.lint)
}
}
// items to take care of (delete the macro invocation). As a result we have
// a few lints we whitelist here for allowing a lint even though it's in a
// foreign macro invocation.
- } else if lint_id != LintId::of(builtin::UNREACHABLE_CODE) &&
- lint_id != LintId::of(builtin::DEPRECATED) {
+ } else if !lint.report_in_external_macro {
if err.span.primary_spans().iter().any(|s| in_external_macro(sess, *s)) {
err.cancel();
}