Skip to content

Commit 27d6b9d

Browse files
committed
improve visibility of future-incompatibilities (mildly, at least)
1 parent 15d32ff commit 27d6b9d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-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

+17-3
Original file line numberDiff line numberDiff line change
@@ -364,14 +364,16 @@ pub fn gather_attrs(attrs: &[ast::Attribute])
364364
/// lints elsewhere in the compiler should call
365365
/// `Session::add_lint()` instead.
366366
pub fn raw_emit_lint(sess: &Session,
367+
lints: &LintStore,
367368
lint: &'static Lint,
368369
lvlsrc: LevelSource,
369370
span: Option<Span>,
370371
msg: &str) {
371-
raw_struct_lint(sess, lint, lvlsrc, span, msg).emit();
372+
raw_struct_lint(sess, lints, lint, lvlsrc, span, msg).emit();
372373
}
373374

374375
pub fn raw_struct_lint<'a>(sess: &'a Session,
376+
lints: &LintStore,
375377
lint: &'static Lint,
376378
lvlsrc: LevelSource,
377379
span: Option<Span>,
@@ -413,6 +415,18 @@ pub fn raw_struct_lint<'a>(sess: &'a Session,
413415
_ => sess.bug("impossible level in raw_emit_lint"),
414416
};
415417

418+
// Check for future incompatibility lints and issue a stronger warning.
419+
let future_incompat_lints = &lints.lint_groups[builtin::FUTURE_INCOMPATIBLE];
420+
let this_id = LintId::of(lint);
421+
if future_incompat_lints.0.iter().any(|&id| id == this_id) {
422+
let msg = "this lint will become a HARD ERROR in a future release!";
423+
if let Some(sp) = span {
424+
err.span_note(sp, msg);
425+
} else {
426+
err.note(msg);
427+
}
428+
}
429+
416430
if let Some(span) = def {
417431
err.span_note(span, "lint level defined here");
418432
}
@@ -450,7 +464,7 @@ pub trait LintContext: Sized {
450464
Some(pair) => pair,
451465
};
452466

453-
raw_emit_lint(&self.sess(), lint, (level, src), span, msg);
467+
raw_emit_lint(&self.sess(), self.lints(), lint, (level, src), span, msg);
454468
}
455469

456470
fn lookup(&self,
@@ -463,7 +477,7 @@ pub trait LintContext: Sized {
463477
Some(pair) => pair,
464478
};
465479

466-
raw_struct_lint(&self.sess(), lint, (level, src), span, msg)
480+
raw_struct_lint(&self.sess(), self.lints(), lint, (level, src), span, msg)
467481
}
468482

469483
/// 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
@@ -2208,6 +2208,7 @@ fn enum_variant_size_lint(ccx: &CrateContext, enum_def: &hir::EnumDef, sp: Span,
22082208
// Use lint::raw_emit_lint rather than sess.add_lint because the lint-printing
22092209
// pass for the latter already ran.
22102210
lint::raw_struct_lint(&ccx.tcx().sess,
2211+
&ccx.tcx().sess.lint_store.borrow(),
22112212
lint::builtin::VARIANT_SIZE_DIFFERENCES,
22122213
*lvlsrc.unwrap(),
22132214
Some(sp),

0 commit comments

Comments
 (0)