Skip to content

Commit ed2c27e

Browse files
committed
consts: remove dead runtime-array const bitcast fallback
The generic unsized constant reader already handles `RuntimeArray` constants, including the trailing-bytes error case covered by the new compile-fail test. Keep `const_bitcast` on the direct `try_read_from_const_alloc` path instead of carrying a second fallback that no longer changes behavior.
1 parent e0d2e20 commit ed2c27e

File tree

1 file changed

+1
-34
lines changed

1 file changed

+1
-34
lines changed

crates/rustc_codegen_spirv/src/codegen_cx/constant.rs

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -347,47 +347,14 @@ impl<'tcx> CodegenCx<'tcx> {
347347
self.builder.lookup_const_by_id(pointee)
348348
&& let SpirvType::Pointer { pointee } = self.lookup_type(ty)
349349
{
350-
let mut runtime_array_bitcast_error = None;
351-
let init = self.try_read_from_const_alloc(alloc, pointee).or_else(|| {
352-
match self.lookup_type(pointee) {
353-
// Reify unsized constants through a sized backing array,
354-
// then keep the requested pointer type in `SpirvConst::PtrTo`.
355-
SpirvType::RuntimeArray { element } => {
356-
let elem_size = self.lookup_type(element).sizeof(self)?;
357-
if elem_size.bytes() == 0 {
358-
return None;
359-
}
360-
361-
let alloc_size = alloc.inner().size();
362-
if alloc_size.bytes() % elem_size.bytes() != 0 {
363-
runtime_array_bitcast_error = Some(
364-
"const runtime array backing allocation size is not a multiple of the element size",
365-
);
366-
return None;
367-
}
368-
369-
let count = alloc_size.bytes() / elem_size.bytes();
370-
let sized_ty = self.type_array(element, count);
371-
self.try_read_from_const_alloc(alloc, sized_ty)
372-
}
373-
_ => None,
374-
}
375-
});
376-
377-
if let Some(init) = init {
350+
if let Some(init) = self.try_read_from_const_alloc(alloc, pointee) {
378351
return self.def_constant(
379352
ty,
380353
SpirvConst::PtrTo {
381354
pointee: init.def_cx(self),
382355
},
383356
);
384357
}
385-
386-
if let Some(reason) = runtime_array_bitcast_error {
387-
let result = val.def_cx(self).with_type(ty);
388-
self.zombie_no_span(result.def_cx(self), reason);
389-
return result;
390-
}
391358
}
392359

393360
if val.ty == ty {

0 commit comments

Comments
 (0)