]> git.lizzy.rs Git - rust.git/blob - tests/ui/precedence.rs
Merge pull request #3265 from mikerite/fix-export
[rust.git] / tests / ui / precedence.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 #![feature(tool_lints)]
12
13
14 #[warn(clippy::precedence)]
15 #[allow(clippy::identity_op)]
16 #[allow(clippy::eq_op)]
17
18 macro_rules! trip {
19    ($a:expr) => {
20     match $a & 0b1111_1111i8 {
21         0 => println!("a is zero ({})", $a),
22         _ => println!("a is {}", $a),
23     }
24    };
25 }
26
27 fn main() {
28     1 << 2 + 3;
29     1 + 2 << 3;
30     4 >> 1 + 1;
31     1 + 3 >> 2;
32     1 ^ 1 - 1;
33     3 | 2 - 1;
34     3 & 5 - 2;
35     -1i32.abs();
36     -1f32.abs();
37
38     // These should not trigger an error
39     let _ = (-1i32).abs();
40     let _ = (-1f32).abs();
41     let _ = -(1i32).abs();
42     let _ = -(1f32).abs();
43     let _ = -(1i32.abs());
44     let _ = -(1f32.abs());
45
46     let b = 3;
47     trip!(b * 8);
48 }