Open
Description
Expected Behaviour
Can cast [f32; 5]
as Data { a: f32, b: [f32; 3], c: f32 }
Example & Steps To Reproduce
#[repr(C)]
#[derive(Clone, Copy)]
struct Data {
a: f32,
b: [f32; 3],
c: f32,
}
union DataOrArray {
arr: [f32; 5],
str: Data,
}
impl DataOrArray {
fn arr(self) -> [f32; 5] { unsafe { self.arr } }
fn new(arr: [f32; 5]) -> Self { Self { arr } }
}
in shader:
let dora = DataOrArray::new([0.0, 0.0, 0.0, 0.0, 0.0]);
let arr = dora.arr();
Produces:
error: cannot cast between pointer types
from `*struct types::Data { a: f32, b: [f32; 3], c: f32 }`
to `*[f32; 5]`
System Info
- Rust: rustc 1.84.0-nightly (b19329a37 2024-11-21)
- OS: MacOS 15.3.2
- GPU: M2 Max
- rust-gpu: 698f10a