Skip to content

Commit 5104a93

Browse files
committed
Revert "Convert negate_unsigned feature gate to a warning"
This reverts commit 0ca8e49 and fixes the code to work with current rustc. Fixes rust-lang#27141
1 parent 24fdaed commit 5104a93

File tree

4 files changed

+15
-14
lines changed

4 files changed

+15
-14
lines changed

src/librustc_lint/builtin.rs

+7-8
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ use std::{i8, i16, i32, i64, u8, u16, u32, u64, f32, f64};
4949
use syntax::{abi, ast};
5050
use syntax::attr::{self, AttrMetaMethods};
5151
use syntax::codemap::{self, Span};
52-
use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType};
52+
use syntax::feature_gate::{KNOWN_ATTRIBUTES, AttributeType, emit_feature_err, GateIssue};
5353
use syntax::ast::{TyIs, TyUs, TyI8, TyU8, TyI16, TyU16, TyI32, TyU32, TyI64, TyU64};
5454
use syntax::ptr::P;
5555

@@ -381,13 +381,12 @@ impl LateLintPass for TypeLimits {
381381

382382
fn check_unsigned_negation_feature(cx: &LateContext, span: Span) {
383383
if !cx.sess().features.borrow().negate_unsigned {
384-
// FIXME(#27141): change this to syntax::feature_gate::emit_feature_err…
385-
cx.sess().span_warn(span,
386-
"unary negation of unsigned integers will be feature gated in the future");
387-
// …and remove following two expressions.
388-
if option_env!("CFG_DISABLE_UNSTABLE_FEATURES").is_some() { return; }
389-
cx.sess().fileline_help(span, "add #![feature(negate_unsigned)] to the \
390-
crate attributes to enable the gate in advance");
384+
emit_feature_err(
385+
&cx.sess().parse_sess.span_diagnostic,
386+
"negate_unsigned",
387+
span,
388+
GateIssue::Language,
389+
"unary negation of unsigned integers may be removed in the future");
391390
}
392391
}
393392
}

src/test/bench/shootout-mandelbrot.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ fn write_line(init_i: f64, vec_init_r: &[f64], res: &mut Vec<u8>) {
192192
i += 2;
193193
}
194194

195-
res.push(cur_byte^-1);
195+
res.push(cur_byte^!0);
196196
}
197197
}
198198

src/test/run-pass/feature-gate-negate-unsigned.rs src/test/compile-fail/feature-gate-negate-unsigned.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -18,21 +18,21 @@ impl std::ops::Neg for S {
1818
}
1919

2020
const _MAX: usize = -1;
21-
//~^ WARN unary negation of unsigned integers will be feature gated in the future
21+
//~^ ERROR unary negation of unsigned integers may be removed in the future
2222

2323
fn main() {
2424
let a = -1;
25-
//~^ WARN unary negation of unsigned integers will be feature gated in the future
25+
//~^ ERROR unary negation of unsigned integers may be removed in the future
2626
let _b : u8 = a; // for infering variable a to u8.
2727

2828
-a;
29-
//~^ WARN unary negation of unsigned integers will be feature gated in the future
29+
//~^ ERROR unary negation of unsigned integers may be removed in the future
3030

3131
let _d = -1u8;
32-
//~^ WARN unary negation of unsigned integers will be feature gated in the future
32+
//~^ ERROR unary negation of unsigned integers may be removed in the future
3333

3434
for _ in -10..10u8 {}
35-
//~^ WARN unary negation of unsigned integers will be feature gated in the future
35+
//~^ ERROR unary negation of unsigned integers may be removed in the future
3636

3737
-S; // should not trigger the gate; issue 26840
3838
}

src/test/run-pass/unary-minus-suffix-inference.rs

+2
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#![feature(negate_unsigned)]
12+
1113
pub fn main() {
1214
let a = 1;
1315
let a_neg: i8 = -a;

0 commit comments

Comments
 (0)