diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-17 12:02:58 +0000 |
commit | 698f8c2f01ea549d77d7dc3338a12e04c11057b9 (patch) | |
tree | 173a775858bd501c378080a10dca74132f05bc50 /src/tools/clippy/tests/ui/manual_bits.rs | |
parent | Initial commit. (diff) | |
download | rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.tar.xz rustc-698f8c2f01ea549d77d7dc3338a12e04c11057b9.zip |
Adding upstream version 1.64.0+dfsg1.upstream/1.64.0+dfsg1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r-- | src/tools/clippy/tests/ui/manual_bits.rs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui/manual_bits.rs b/src/tools/clippy/tests/ui/manual_bits.rs new file mode 100644 index 000000000..62638f047 --- /dev/null +++ b/src/tools/clippy/tests/ui/manual_bits.rs @@ -0,0 +1,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); +} |