We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a339ed1 commit 09c71a5Copy full SHA for 09c71a5
tests/ui/const_prop/ice-issue-96944.rs
@@ -0,0 +1,26 @@
1
+// build-pass
2
+#![crate_type = "lib"]
3
+#![allow(arithmetic_overflow)]
4
+
5
+pub trait BitSplit {
6
+ type Half;
7
+ fn merge(halves: [Self::Half; 2]) -> Self;
8
+}
9
10
+macro_rules! impl_ints {
11
+ ($int:ty => $half:ty; $mask:expr) => {
12
+ impl BitSplit for $int {
13
+ type Half = $half;
14
+ #[inline]
15
+ fn merge(halves: [Self::Half; 2]) -> Self {
16
+ const HALF_SIZE: usize = std::mem::size_of::<$half>() * 8;
17
+ (halves[0] << HALF_SIZE) as $int | halves[1] as $int
18
+ }
19
20
+ };
21
22
23
+impl_ints!(u128 => u64; 0x0000_0000_0000_0000_FFFF_FFFF_FFFF_FFFF);
24
+impl_ints!( u64 => u32; 0x0000_0000_FFFF_FFFF);
25
+impl_ints!( u32 => u16; 0x0000_FFFF);
26
+impl_ints!( u16 => u8; 0x00FF);
0 commit comments