2016-03-25 09:42:27 +00:00
|
|
|
#![feature(plugin)]
|
|
|
|
#![plugin(clippy)]
|
|
|
|
|
|
|
|
#![deny(invalid_upcast_comparisons)]
|
|
|
|
#![allow(unused, eq_op, no_effect)]
|
|
|
|
fn main() {
|
|
|
|
let zero: u32 = 0;
|
|
|
|
let u8_max: u8 = 255;
|
|
|
|
|
2016-03-26 05:57:03 +00:00
|
|
|
(u8_max as u32) > 300; //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false
|
2016-03-25 09:42:27 +00:00
|
|
|
(u8_max as u32) > 20;
|
|
|
|
|
2016-03-26 05:57:03 +00:00
|
|
|
(zero as i32) < -5; //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false
|
2016-03-25 09:42:27 +00:00
|
|
|
(zero as i32) < 10;
|
2016-03-25 22:47:27 +00:00
|
|
|
|
2016-03-26 05:57:03 +00:00
|
|
|
-5 < (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always true
|
|
|
|
0 <= (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always true
|
2016-03-25 22:47:27 +00:00
|
|
|
0 < (zero as i32);
|
2016-03-29 04:44:18 +00:00
|
|
|
|
|
|
|
-5 > (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false
|
|
|
|
-5 >= (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false
|
2016-04-02 13:51:28 +00:00
|
|
|
1337 == (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always false
|
2016-03-29 05:08:58 +00:00
|
|
|
|
|
|
|
-5 == (zero as i32); //~ERROR because of the numeric bounds on `zero` prior to casting, this expression is always false
|
|
|
|
-5 != (u8_max as i32); //~ERROR because of the numeric bounds on `u8_max` prior to casting, this expression is always true
|
2016-04-02 13:51:28 +00:00
|
|
|
|
|
|
|
// Those are Ok:
|
|
|
|
42 == (u8_max as i32);
|
|
|
|
42 != (u8_max as i32);
|
|
|
|
42 > (u8_max as i32);
|
|
|
|
(u8_max as i32) == 42;
|
|
|
|
(u8_max as i32) != 42;
|
|
|
|
(u8_max as i32) > 42;
|
|
|
|
(u8_max as i32) < 42;
|
2016-03-25 09:42:27 +00:00
|
|
|
}
|