summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/unreadable_literal.rs
blob: 82f04e7ced5279f95e8959ca7e4a8848ad6e6721 (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
35
36
37
38
39
40
41
42
43
44
45
46
// run-rustfix

#![warn(clippy::unreadable_literal)]
#![allow(unused_tuple_struct_fields)]

struct Foo(u64);

macro_rules! foo {
    () => {
        Foo(123123123123)
    };
}

struct Bar(f32);

macro_rules! bar {
    () => {
        Bar(100200300400.100200300400500)
    };
}

fn main() {
    let _good = (
        0b1011_i64,
        0o1_234_u32,
        0x1_234_567,
        65536,
        1_2345_6789,
        1234_f32,
        1_234.12_f32,
        1_234.123_f32,
        1.123_4_f32,
    );
    let _bad = (0b110110_i64, 0x12345678_usize, 123456_f32, 1.234567_f32);
    let _good_sci = 1.1234e1;
    let _bad_sci = 1.123456e1;

    let _fail1 = 0xabcdef;
    let _fail2: u32 = 0xBAFEBAFE;
    let _fail3 = 0xabcdeff;
    let _fail4: i128 = 0xabcabcabcabcabcabc;
    let _fail5 = 1.100300400;

    let _ = foo!();
    let _ = bar!();
}