]>
Commit | Line | Data |
---|---|---|
c1a9b12d SL |
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 | ||
9cc50fc6 | 11 | // Test that negating unsigned integers doesn't compile |
c1a9b12d SL |
12 | |
13 | struct S; | |
14 | impl std::ops::Neg for S { | |
15 | type Output = u32; | |
16 | fn neg(self) -> u32 { 0 } | |
17 | } | |
18 | ||
c1a9b12d | 19 | fn main() { |
32a655c1 SL |
20 | let _max: usize = -1; |
21 | //~^ ERROR cannot apply unary operator `-` to type `usize` | |
22 | ||
54a0048b | 23 | let x = 5u8; |
32a655c1 SL |
24 | let _y = -x; |
25 | //~^ ERROR cannot apply unary operator `-` to type `u8` | |
26 | ||
c1a9b12d SL |
27 | -S; // should not trigger the gate; issue 26840 |
28 | } |