2016-01-11 05:31:46 -06:00
|
|
|
// Test that negating unsigned integers doesn't compile
|
2015-04-16 07:48:31 -05:00
|
|
|
|
2015-07-13 17:03:24 -05:00
|
|
|
struct S;
|
|
|
|
impl std::ops::Neg for S {
|
|
|
|
type Output = u32;
|
|
|
|
fn neg(self) -> u32 { 0 }
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
2017-01-03 13:48:17 -06:00
|
|
|
let _max: usize = -1;
|
|
|
|
//~^ ERROR cannot apply unary operator `-` to type `usize`
|
|
|
|
|
2015-12-16 11:44:15 -06:00
|
|
|
let x = 5u8;
|
2017-01-03 13:48:17 -06:00
|
|
|
let _y = -x;
|
|
|
|
//~^ ERROR cannot apply unary operator `-` to type `u8`
|
|
|
|
|
2015-07-13 17:03:24 -05:00
|
|
|
-S; // should not trigger the gate; issue 26840
|
|
|
|
}
|