summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/manual_bits.rs
blob: 62638f047eb015b299d9b8e45afd4489b9b9a364 (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
47
48
49
50
51
52
53
54
55
56
57
58
59
// run-rustfix

#![warn(clippy::manual_bits)]
#![allow(
    clippy::no_effect,
    clippy::useless_conversion,
    path_statements,
    unused_must_use,
    clippy::unnecessary_operation
)]

use std::mem::{size_of, size_of_val};

fn main() {
    size_of::<i8>() * 8;
    size_of::<i16>() * 8;
    size_of::<i32>() * 8;
    size_of::<i64>() * 8;
    size_of::<i128>() * 8;
    size_of::<isize>() * 8;

    size_of::<u8>() * 8;
    size_of::<u16>() * 8;
    size_of::<u32>() * 8;
    size_of::<u64>() * 8;
    size_of::<u128>() * 8;
    size_of::<usize>() * 8;

    8 * size_of::<i8>();
    8 * size_of::<i16>();
    8 * size_of::<i32>();
    8 * size_of::<i64>();
    8 * size_of::<i128>();
    8 * size_of::<isize>();

    8 * size_of::<u8>();
    8 * size_of::<u16>();
    8 * size_of::<u32>();
    8 * size_of::<u64>();
    8 * size_of::<u128>();
    8 * size_of::<usize>();

    size_of::<usize>() * 4;
    4 * size_of::<usize>();
    size_of::<bool>() * 8;
    8 * size_of::<bool>();

    size_of_val(&0u32) * 8;

    type Word = u32;
    size_of::<Word>() * 8;
    type Bool = bool;
    size_of::<Bool>() * 8;

    let _: u32 = (size_of::<u128>() * 8) as u32;
    let _: u32 = (size_of::<u128>() * 8).try_into().unwrap();
    let _ = (size_of::<u128>() * 8).pow(5);
    let _ = &(size_of::<u128>() * 8);
}