improve visibility of future-incompatibilities (mildly, at least)
This commit is contained in:
parent
15d32ffbb2
commit
27d6b9d215
3 changed files with 21 additions and 3 deletions
|
|
@ -16,6 +16,9 @@
|
|||
|
||||
use lint::{LintPass, LateLintPass, LintArray};
|
||||
|
||||
// name of the future-incompatible group
|
||||
pub const FUTURE_INCOMPATIBLE: &'static str = "future_incompatible";
|
||||
|
||||
declare_lint! {
|
||||
pub CONST_ERR,
|
||||
Warn,
|
||||
|
|
|
|||
|
|
@ -364,14 +364,16 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
|
|||
/// lints elsewhere in the compiler should call
|
||||
/// `Session::add_lint()` instead.
|
||||
pub fn raw_emit_lint(sess: &Session,
|
||||
lints: &LintStore,
|
||||
lint: &'static Lint,
|
||||
lvlsrc: LevelSource,
|
||||
span: Option<Span>,
|
||||
msg: &str) {
|
||||
raw_struct_lint(sess, lint, lvlsrc, span, msg).emit();
|
||||
raw_struct_lint(sess, lints, lint, lvlsrc, span, msg).emit();
|
||||
}
|
||||
|
||||
pub fn raw_struct_lint<'a>(sess: &'a Session,
|
||||
lints: &LintStore,
|
||||
lint: &'static Lint,
|
||||
lvlsrc: LevelSource,
|
||||
span: Option<Span>,
|
||||
|
|
@ -413,6 +415,18 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
|
|||
_ => sess.bug("impossible level in raw_emit_lint"),
|
||||
};
|
||||
|
||||
// Check for future incompatibility lints and issue a stronger warning.
|
||||
let future_incompat_lints = &lints.lint_groups[builtin::FUTURE_INCOMPATIBLE];
|
||||
let this_id = LintId::of(lint);
|
||||
if future_incompat_lints.0.iter().any(|&id| id == this_id) {
|
||||
let msg = "this lint will become a HARD ERROR in a future release!";
|
||||
if let Some(sp) = span {
|
||||
err.span_note(sp, msg);
|
||||
} else {
|
||||
err.note(msg);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(span) = def {
|
||||
err.span_note(span, "lint level defined here");
|
||||
}
|
||||
|
|
@ -450,7 +464,7 @@ pub trait LintContext: Sized {
|
|||
Some(pair) => pair,
|
||||
};
|
||||
|
||||
raw_emit_lint(&self.sess(), lint, (level, src), span, msg);
|
||||
raw_emit_lint(&self.sess(), self.lints(), lint, (level, src), span, msg);
|
||||
}
|
||||
|
||||
fn lookup(&self,
|
||||
|
|
@ -463,7 +477,7 @@ pub trait LintContext: Sized {
|
|||
Some(pair) => pair,
|
||||
};
|
||||
|
||||
raw_struct_lint(&self.sess(), lint, (level, src), span, msg)
|
||||
raw_struct_lint(&self.sess(), self.lints(), lint, (level, src), span, msg)
|
||||
}
|
||||
|
||||
/// Emit a lint at the appropriate level, for a particular span.
|
||||
|
|
|
|||
|
|
@ -2208,6 +2208,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &hir::EnumDef, sp: Span,
|
|||
// Use lint::raw_emit_lint rather than sess.add_lint because the lint-printing
|
||||
// pass for the latter already ran.
|
||||
lint::raw_struct_lint(&ccx.tcx().sess,
|
||||
&ccx.tcx().sess.lint_store.borrow(),
|
||||
lint::builtin::VARIANT_SIZE_DIFFERENCES,
|
||||
*lvlsrc.unwrap(),
|
||||
Some(sp),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue