Skip to content

Commit d7914ec

Browse files
committed
buffer descriptor array: validate PassMode::Pair are slices
1 parent d700bc1 commit d7914ec

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

crates/rustc_codegen_spirv/src/builder/runtime_array.rs

+10-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,16 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
9191
}
9292
PassMode::Pair(_, _) => {
9393
// element is a slice
94-
// TODO can other elements also be pairs?
94+
match self.lookup_type(result_type) {
95+
SpirvType::Adt { field_types, .. } if field_types.len() == 2
96+
&& matches!(self.lookup_type(field_types[0]), SpirvType::Pointer {..})
97+
&& field_types[1] == self.type_isize() => {
98+
}
99+
_ => self.fatal(format!(
100+
"Expected element of RuntimeArray to be a plain slice, like `&RuntimeArray<[u32]>`, but got {:?}!",
101+
self.lookup_type(result_type).debug(result_type, self)
102+
))
103+
};
95104
let len = self
96105
.emit()
97106
.array_length(self.type_isize(), None, element.def(self), 0)

0 commit comments

Comments
 (0)