Skip to content

Commit 819d018

Browse files
nikomatsakispnkfelix
authored andcommitted
improve visibility of future-incompatibilities (mildly, at least)
1 parent 2e48b59 commit 819d018

File tree

3 files changed

+23
-3
lines changed

3 files changed

+23
-3
lines changed

src/librustc/lint/builtin.rs

+3
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@
1616
1717
use lint::{LintPass, LateLintPass, LintArray};
1818

19+
// name of the future-incompatible group
20+
pub const FUTURE_INCOMPATIBLE: &'static str = "future_incompatible";
21+
1922
declare_lint! {
2023
pub CONST_ERR,
2124
Warn,

src/librustc/lint/context.rs

+19-3
Original file line numberDiff line numberDiff line change
@@ -363,8 +363,12 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
363363
/// in trans that run after the main lint pass is finished. Most
364364
/// lints elsewhere in the compiler should call
365365
/// `Session::add_lint()` instead.
366-
pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
367-
lvlsrc: LevelSource, span: Option<Span>, msg: &str) {
366+
pub fn raw_emit_lint(sess: &Session,
367+
lints: &LintStore,
368+
lint: &'static Lint,
369+
lvlsrc: LevelSource,
370+
span: Option<Span>,
371+
msg: &str) {
368372
let (mut level, source) = lvlsrc;
369373
if level == Allow { return }
370374

@@ -399,6 +403,18 @@ pub fn raw_emit_lint(sess: &Session, lint: &'static Lint,
399403
_ => sess.bug("impossible level in raw_emit_lint"),
400404
}
401405

406+
// Check for future incompatibility lints and issue a stronger warning.
407+
let future_incompat_lints = &lints.lint_groups[builtin::FUTURE_INCOMPATIBLE];
408+
let this_id = LintId::of(lint);
409+
if future_incompat_lints.0.iter().any(|&id| id == this_id) {
410+
let msg = "this lint will become a HARD ERROR in a future release!";
411+
if let Some(sp) = span {
412+
sess.span_note(sp, msg);
413+
} else {
414+
sess.note(msg);
415+
}
416+
}
417+
402418
if let Some(span) = def {
403419
sess.span_note(span, "lint level defined here");
404420
}
@@ -428,7 +444,7 @@ pub trait LintContext: Sized {
428444
Some(&pair) => pair,
429445
};
430446

431-
raw_emit_lint(&self.sess(), lint, (level, src), span, msg);
447+
raw_emit_lint(&self.sess(), self.lints(), lint, (level, src), span, msg);
432448
}
433449

434450
/// Emit a lint at the appropriate level, for a particular span.

src/librustc_trans/trans/base.rs

+1
Original file line numberDiff line numberDiff line change
@@ -2204,6 +2204,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &hir::EnumDef, sp: Span,
22042204
// Use lint::raw_emit_lint rather than sess.add_lint because the lint-printing
22052205
// pass for the latter already ran.
22062206
lint::raw_emit_lint(&ccx.tcx().sess,
2207+
&ccx.tcx().sess.lint_store.borrow(),
22072208
lint::builtin::VARIANT_SIZE_DIFFERENCES,
22082209
*lvlsrc.unwrap(),
22092210
Some(sp),

0 commit comments

Comments
 (0)