Skip to content

Commit e22370c

Browse files
committed
compiletests: future-proof issue-46 against MIR optimizations.
1 parent b951fa8 commit e22370c

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/compiletests/ui/lang/issue-46.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
use spirv_std::spirv;
44

5-
#[derive(Default)]
5+
#[derive(Copy, Clone, Default)]
66
struct Foo {
77
bar: bool,
88
baz: [[u32; 2]; 1],
@@ -13,3 +13,20 @@ pub fn main() {
1313
let x = [[1; 2]; 1];
1414
let y = [Foo::default(); 1];
1515
}
16+
17+
// HACK(eddyb) future-proofing against `[expr; 1]` -> `[expr]`
18+
// MIR optimization (https://github.com/rust-lang/rust/pull/135322).
19+
fn force_repeat_one<const ONE: usize>() -> ([[u32; 2]; ONE], [Foo; ONE]) {
20+
([[1; 2]; ONE], [Foo::default(); ONE])
21+
}
22+
23+
#[spirv(fragment)]
24+
pub fn main_future_proof(
25+
#[spirv(storage_buffer, descriptor_set = 0, binding = 0)] out: &mut [[u32; 2]; 2],
26+
) {
27+
let (x, y) = force_repeat_one::<1>();
28+
29+
// NOTE(eddyb) further guard against optimizations by using `x` and `y`.
30+
out[0] = x[0];
31+
out[1] = y[0].baz[0];
32+
}

0 commit comments

Comments
 (0)