about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorSimonas Kazlauskas <git@kazlauskas.me>2015-07-20 12:17:55 +0300
committerSimonas Kazlauskas <git@kazlauskas.me>2015-07-20 12:24:16 +0300
commit0ca8e4994ee43ba9dfbded6e129b30ff5fe7a994 (patch)
tree63307a4db73e9d749a6ec69fd9caf969bc319b11 /src
parent22502154e6c1aee835554216d4b5054fd8f570f8 (diff)
downloadrust-0ca8e4994ee43ba9dfbded6e129b30ff5fe7a994.tar.gz
rust-0ca8e4994ee43ba9dfbded6e129b30ff5fe7a994.zip
Convert negate_unsigned feature gate to a warning
Diffstat (limited to 'src')
-rw-r--r--src/librustc_lint/builtin.rs14
-rw-r--r--src/test/run-pass/feature-gate-negate-unsigned.rs (renamed from src/test/compile-fail/feature-gate-negate-unsigned.rs)10
2 files changed, 13 insertions, 11 deletions
diff --git a/src/librustc_lint/builtin.rs b/src/librustc_lint/builtin.rs
index d1583074787..e82e0d790e1 100644
--- a/src/librustc_lint/builtin.rs
+++ b/src/librustc_lint/builtin.rs
@@ -53,7 +53,7 @@ use syntax::{abi, ast};
 use syntax::ast_util::{self, is_shift_binop, local_def};
 use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::{self, Span};
-use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType, emit_feature_err};
+use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
 use syntax::parse::token;
 use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
 use syntax::ptr::P;
@@ -382,11 +382,13 @@ impl LintPass for TypeLimits {
 
         fn check_unsigned_negation_feature(cx: &Context, span: Span) {
             if !cx.sess().features.borrow().negate_unsigned {
-                emit_feature_err(
-                    &cx.sess().parse_sess.span_diagnostic,
-                    "negate_unsigned",
-                    span,
-                    "unary negation of unsigned integers may be removed in the future");
+                // FIXME(#27141): change this to syntax::feature_gate::emit_feature_err…
+                cx.sess().span_warn(span,
+                    "unary negation of unsigned integers will be feature gated in the future");
+                // …and remove following two expressions.
+                if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; }
+                cx.sess().fileline_help(span, "add #![feature(negate_unsigned)] to the \
+                                               crate attributes to enable the gate in advance");
             }
         }
     }
diff --git a/src/test/compile-fail/feature-gate-negate-unsigned.rs b/src/test/run-pass/feature-gate-negate-unsigned.rs
index b1c73fab4ff..95c8e62be53 100644
--- a/src/test/compile-fail/feature-gate-negate-unsigned.rs
+++ b/src/test/run-pass/feature-gate-negate-unsigned.rs
@@ -18,21 +18,21 @@ impl std::ops::Neg for S {
 }
 
 const _MAX: usize = -1;
-//~^ ERROR unary negation of unsigned integers may be removed in the future
+//~^ WARN unary negation of unsigned integers will be feature gated in the future
 
 fn main() {
     let a = -1;
-    //~^ ERROR unary negation of unsigned integers may be removed in the future
+    //~^ WARN unary negation of unsigned integers will be feature gated in the future
     let _b : u8 = a; // for infering variable a to u8.
 
     -a;
-    //~^ ERROR unary negation of unsigned integers may be removed in the future
+    //~^ WARN unary negation of unsigned integers will be feature gated in the future
 
     let _d = -1u8;
-    //~^ ERROR unary negation of unsigned integers may be removed in the future
+    //~^ WARN unary negation of unsigned integers will be feature gated in the future
 
     for _ in -10..10u8 {}
-    //~^ ERROR unary negation of unsigned integers may be removed in the future
+    //~^ WARN unary negation of unsigned integers will be feature gated in the future
 
     -S; // should not trigger the gate; issue 26840
 }