]> git.lizzy.rs Git - rust.git/commitdiff
Revert "Convert negate_unsigned feature gate to a warning"
authorSimonas Kazlauskas <git@kazlauskas.me>
Thu, 17 Sep 2015 20:09:28 +0000 (23:09 +0300)
committerSimonas Kazlauskas <git@kazlauskas.me>
Fri, 18 Sep 2015 17:22:16 +0000 (20:22 +0300)
This reverts commit 0ca8e4994ee43ba9dfbded6e129b30ff5fe7a994 and fixes the code to work with
current rustc.

Fixes #27141

src/librustc_lint/builtin.rs
src/test/bench/shootout-mandelbrot.rs
src/test/compile-fail/feature-gate-negate-unsigned.rs [new file with mode: 0644]
src/test/run-pass/feature-gate-negate-unsigned.rs [deleted file]
src/test/run-pass/unary-minus-suffix-inference.rs

index 394bd2abc08c7f491d33fc31c656523bf20d1487..5b875e6acbc04b022c38dd1a8bce20f24b9e6663 100644 (file)
@@ -49,7 +49,7 @@
 use syntax::{abi, ast};
 use syntax::attr::{self, AttrMetaMethods};
 use syntax::codemap::{self, Span};
-use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
+use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType, emit_feature_err, GateIssue};
 use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
 use syntax::ptr::P;
 
@@ -381,13 +381,12 @@ fn is_comparison(binop: hir::BinOp) -> bool {
 
         fn check_unsigned_negation_feature(cx: &LateContext, span: Span) {
             if !cx.sess().features.borrow().negate_unsigned {
-                // 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");
+                emit_feature_err(
+                    &cx.sess().parse_sess.span_diagnostic,
+                    "negate_unsigned",
+                    span,
+                    GateIssue::Language,
+                    "unary negation of unsigned integers may be removed in the future");
             }
         }
     }
index 232d6b414f580cb4b973388793e13a5551ee94da..21ac23253c86a7d16ac5a0e2ee21408638bfd2c9 100644 (file)
@@ -192,7 +192,7 @@ fn write_line(init_i: f64, vec_init_r: &[f64], res: &mut Vec<u8>) {
             i += 2;
         }
 
-        res.push(cur_byte^-1);
+        res.push(cur_byte^!0);
     }
 }
 
diff --git a/src/test/compile-fail/feature-gate-negate-unsigned.rs b/src/test/compile-fail/feature-gate-negate-unsigned.rs
new file mode 100644 (file)
index 0000000..b1c73fa
--- /dev/null
@@ -0,0 +1,38 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+// Test that negating unsigned integers is gated by `negate_unsigned` feature
+// gate
+
+struct S;
+impl std::ops::Neg for S {
+    type Output = u32;
+    fn neg(self) -> u32 { 0 }
+}
+
+const _MAX: usize = -1;
+//~^ ERROR unary negation of unsigned integers may be removed in the future
+
+fn main() {
+    let a = -1;
+    //~^ ERROR unary negation of unsigned integers may be removed 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
+
+    let _d = -1u8;
+    //~^ ERROR unary negation of unsigned integers may be removed in the future
+
+    for _ in -10..10u8 {}
+    //~^ ERROR unary negation of unsigned integers may be removed in the future
+
+    -S; // should not trigger the gate; issue 26840
+}
diff --git a/src/test/run-pass/feature-gate-negate-unsigned.rs b/src/test/run-pass/feature-gate-negate-unsigned.rs
deleted file mode 100644 (file)
index 95c8e62..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
-// file at the top-level directory of this distribution and at
-// http://rust-lang.org/COPYRIGHT.
-//
-// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
-// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
-// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
-// option. This file may not be copied, modified, or distributed
-// except according to those terms.
-
-// Test that negating unsigned integers is gated by `negate_unsigned` feature
-// gate
-
-struct S;
-impl std::ops::Neg for S {
-    type Output = u32;
-    fn neg(self) -> u32 { 0 }
-}
-
-const _MAX: usize = -1;
-//~^ WARN unary negation of unsigned integers will be feature gated in the future
-
-fn main() {
-    let a = -1;
-    //~^ WARN unary negation of unsigned integers will be feature gated in the future
-    let _b : u8 = a; // for infering variable a to u8.
-
-    -a;
-    //~^ WARN unary negation of unsigned integers will be feature gated in the future
-
-    let _d = -1u8;
-    //~^ WARN unary negation of unsigned integers will be feature gated in the future
-
-    for _ in -10..10u8 {}
-    //~^ WARN unary negation of unsigned integers will be feature gated in the future
-
-    -S; // should not trigger the gate; issue 26840
-}
index 9d685e0263f22c007988fb52cda9d2f8e9e6a0e9..fdb70fe248eff1bc456ebbf60557582488d985b0 100644 (file)
@@ -8,6 +8,8 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![feature(negate_unsigned)]
+
 pub fn main() {
     let a = 1;
     let a_neg: i8 = -a;