summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/suspicious_xor_used_as_pow.rs
blob: eb9fc63fb1d4692f2da82445f19857d79a4200c2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![allow(unused)]
#![warn(clippy::suspicious_xor_used_as_pow)]
#![allow(clippy::eq_op)]

macro_rules! macro_test {
    () => {
        13
    };
}

macro_rules! macro_test_inside {
    () => {
        1 ^ 2 // should warn even if inside macro
    };
}

fn main() {
    // Should warn:
    let _ = 2 ^ 5;
    let _ = 2i32 ^ 9i32;
    let _ = 2i32 ^ 2i32;
    let _ = 50i32 ^ 3i32;
    let _ = 5i32 ^ 8i32;
    let _ = 2i32 ^ 32i32;
    macro_test_inside!();

    // Should not warn:
    let x = 0x02;
    let _ = x ^ 2;
    let _ = 2 ^ x;
    let _ = x ^ 5;
    let _ = 10 ^ 0b0101;
    let _ = 2i32 ^ macro_test!();
}