]> git.proxmox.com Git - rustc.git/blob - src/test/run-pass/feature-gate-negate-unsigned.rs
Imported Upstream version 1.3.0+dfsg1
[rustc.git] / src / test / run-pass / feature-gate-negate-unsigned.rs
1 // Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // Test that negating unsigned integers is gated by `negate_unsigned` feature
12 // gate
13
14 struct S;
15 impl std::ops::Neg for S {
16 type Output = u32;
17 fn neg(self) -> u32 { 0 }
18 }
19
20 const _MAX: usize = -1;
21 //~^ WARN unary negation of unsigned integers will be feature gated in the future
22
23 fn main() {
24 let a = -1;
25 //~^ WARN unary negation of unsigned integers will be feature gated in the future
26 let _b : u8 = a; // for infering variable a to u8.
27
28 -a;
29 //~^ WARN unary negation of unsigned integers will be feature gated in the future
30
31 let _d = -1u8;
32 //~^ WARN unary negation of unsigned integers will be feature gated in the future
33
34 for _ in -10..10u8 {}
35 //~^ WARN unary negation of unsigned integers will be feature gated in the future
36
37 -S; // should not trigger the gate; issue 26840
38 }