File tree Expand file tree Collapse file tree 1 file changed +18
-1
lines changed
tests/compiletests/ui/lang Expand file tree Collapse file tree 1 file changed +18
-1
lines changed Original file line number Diff line number Diff line change 2
2
3
3
use spirv_std:: spirv;
4
4
5
- #[ derive( Default ) ]
5
+ #[ derive( Copy , Clone , Default ) ]
6
6
struct Foo {
7
7
bar : bool ,
8
8
baz : [ [ u32 ; 2 ] ; 1 ] ,
@@ -13,3 +13,20 @@ pub fn main() {
13
13
let x = [ [ 1 ; 2 ] ; 1 ] ;
14
14
let y = [ Foo :: default ( ) ; 1 ] ;
15
15
}
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
+ }
You can’t perform that action at this time.
0 commit comments