mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-18 19:43:43 +00:00
20 lines
512 B
Rust
20 lines
512 B
Rust
|
#![feature(plugin)]
|
||
|
#![plugin(clippy)]
|
||
|
|
||
|
#![deny(bad_bit_mask)]
|
||
|
fn main() {
|
||
|
let x = 5;
|
||
|
x & 1 == 1; //ok, distinguishes bit 0
|
||
|
x & 2 == 1; //~ERROR
|
||
|
x | 1 == 3; //ok, equals x == 2 || x == 3
|
||
|
x | 3 == 3; //ok, equals x <= 3
|
||
|
x | 3 == 2; //~ERROR
|
||
|
|
||
|
x & 1 > 1; //~ERROR
|
||
|
x & 2 > 1; // ok, distinguishes x & 2 == 2 from x & 2 == 0
|
||
|
x & 2 < 1; // ok, distinguishes x & 2 == 2 from x & 2 == 0
|
||
|
x | 1 > 1; // ok (if a bit silly), equals x > 1
|
||
|
x | 2 > 1; //~ERROR
|
||
|
x | 2 <= 2; // ok (if a bit silly), equals x <= 2
|
||
|
}
|