Skip to content

Commit d720f93

Browse files
authored
Rollup merge of rust-lang#114543 - RalfJung:test-96944, r=compiler-errors
add tests for some fixed ConstProp ICEs Fixes rust-lang#96944 Fixes rust-lang#111353
2 parents 74dce18 + 0c59544 commit d720f93

File tree

2 files changed

+33
-0
lines changed

2 files changed

+33
-0
lines changed

Diff for: tests/ui/const_prop/ice-issue-111353.rs

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
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+
}

Diff for: tests/ui/const_prop/ice-issue-96944.rs

+26
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)