Skip to content

Commit 03f89e8

Browse files
TrueDoctoreddyb
authored andcommitted
Add support for zero sized types
1 parent b0328ed commit 03f89e8

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

crates/rustc_codegen_spirv/src/builder/builder_methods.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
412412
if field_ty_kind
413413
.sizeof(self)
414414
.map_or(true, |size| offset_in_field < size)
415+
// If the field is a zero sized type, check the type to
416+
// get the correct entry
417+
|| offset_in_field == Size::ZERO && leaf_ty == field_ty
415418
{
416419
Some((i, field_ty, field_ty_kind, offset_in_field))
417420
} else {
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// build-pass
2+
3+
use spirv_std as _;
4+
struct A;
5+
struct B;
6+
7+
struct S {
8+
x: A,
9+
y: B,
10+
}
11+
12+
fn f(x: &B) {}
13+
14+
#[spirv(fragment)]
15+
pub fn main() {
16+
let s = S { x: A, y: B };
17+
f(&s.y);
18+
}

0 commit comments

Comments
 (0)