]> git.lizzy.rs Git - rust.git/commitdiff
improve visibility of future-incompatibilities (mildly, at least)
authorNiko Matsakis <niko@alum.mit.edu>
Tue, 5 Jan 2016 18:43:57 +0000 (13:43 -0500)
committerNiko Matsakis <niko@alum.mit.edu>
Tue, 5 Jan 2016 21:21:53 +0000 (16:21 -0500)
src/librustc/lint/builtin.rs
src/librustc/lint/context.rs
src/librustc_trans/trans/base.rs

index 2c5c664566a38e8fcb34ec23ccf5dccc18984fc5..26c38a863e22d140d4d490c6d8e02216b07f1baa 100644 (file)
@@ -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,
index 464f29a33937f053c0ba9ae191b5b7ddd5667219..a4af12bcc7c9d1136fac1a5ba894a5614a27d423 100644 (file)
@@ -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 @@ fn lookup_and_emit(&self, lint: &'static Lint, span: Option<Span>, msg: &str) {
             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 @@ fn lookup(&self,
             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.
index 4197f80cb5ea31282c959e17d89b09727b68b5be..67f26595a369f06b9747ec47399f5263dfb81abe 100644 (file)
@@ -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),