2022-01-02 16:34:10 -06:00
|
|
|
#![warn(clippy::manual_bits)]
|
2022-04-10 12:03:16 -05:00
|
|
|
#![allow(
|
|
|
|
clippy::no_effect,
|
|
|
|
clippy::useless_conversion,
|
|
|
|
path_statements,
|
|
|
|
unused_must_use,
|
2022-10-02 04:53:58 -05:00
|
|
|
clippy::unnecessary_operation,
|
|
|
|
clippy::unnecessary_cast
|
2022-04-10 12:03:16 -05:00
|
|
|
)]
|
2022-01-02 16:34:10 -06:00
|
|
|
|
|
|
|
use std::mem::{size_of, size_of_val};
|
|
|
|
|
|
|
|
fn main() {
|
2022-04-10 12:03:16 -05:00
|
|
|
i8::BITS as usize;
|
|
|
|
i16::BITS as usize;
|
|
|
|
i32::BITS as usize;
|
|
|
|
i64::BITS as usize;
|
|
|
|
i128::BITS as usize;
|
|
|
|
isize::BITS as usize;
|
|
|
|
|
|
|
|
u8::BITS as usize;
|
|
|
|
u16::BITS as usize;
|
|
|
|
u32::BITS as usize;
|
|
|
|
u64::BITS as usize;
|
|
|
|
u128::BITS as usize;
|
|
|
|
usize::BITS as usize;
|
|
|
|
|
|
|
|
i8::BITS as usize;
|
|
|
|
i16::BITS as usize;
|
|
|
|
i32::BITS as usize;
|
|
|
|
i64::BITS as usize;
|
|
|
|
i128::BITS as usize;
|
|
|
|
isize::BITS as usize;
|
|
|
|
|
|
|
|
u8::BITS as usize;
|
|
|
|
u16::BITS as usize;
|
|
|
|
u32::BITS as usize;
|
|
|
|
u64::BITS as usize;
|
|
|
|
u128::BITS as usize;
|
|
|
|
usize::BITS as usize;
|
2022-01-02 16:34:10 -06:00
|
|
|
|
|
|
|
size_of::<usize>() * 4;
|
|
|
|
4 * size_of::<usize>();
|
|
|
|
size_of::<bool>() * 8;
|
|
|
|
8 * size_of::<bool>();
|
|
|
|
|
|
|
|
size_of_val(&0u32) * 8;
|
|
|
|
|
|
|
|
type Word = u32;
|
2022-04-10 12:03:16 -05:00
|
|
|
Word::BITS as usize;
|
2022-01-02 16:34:10 -06:00
|
|
|
type Bool = bool;
|
|
|
|
size_of::<Bool>() * 8;
|
2022-04-10 12:03:16 -05:00
|
|
|
|
|
|
|
let _: u32 = u128::BITS as u32;
|
|
|
|
let _: u32 = u128::BITS.try_into().unwrap();
|
|
|
|
let _ = (u128::BITS as usize).pow(5);
|
|
|
|
let _ = &(u128::BITS as usize);
|
2022-01-02 16:34:10 -06:00
|
|
|
}
|
2024-10-18 15:41:05 -05:00
|
|
|
|
|
|
|
fn should_not_lint() {
|
|
|
|
macro_rules! bits_via_macro {
|
|
|
|
($T: ty) => {
|
|
|
|
size_of::<$T>() * 8;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
bits_via_macro!(u8);
|
|
|
|
bits_via_macro!(String);
|
|
|
|
}
|