File tree 2 files changed +33
-0
lines changed
2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ // build-pass
2
+ #![ crate_type = "lib" ]
3
+ #![ feature( unsized_fn_params) ]
4
+
5
+ pub fn f ( mut x : [ i32 ] ) {
6
+ x[ 0 ] = 1 ;
7
+ }
Original file line number Diff line number Diff line change
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 ) ;
You can’t perform that action at this time.
0 commit comments