const_eval and codegen: audit uses of is_zst

This commit is contained in:
Ralf Jung 2023-08-27 18:12:34 +02:00
parent bf91321e0f
commit b2ebf1c23f
12 changed files with 42 additions and 29 deletions

View file

@ -239,6 +239,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
// if the entire value is uninit, then so is the field (can happen in ConstProp)
(Immediate::Uninit, _) => Immediate::Uninit,
// the field contains no information, can be left uninit
// (Scalar/ScalarPair can contain even aligned ZST, not just 1-ZST)
_ if layout.is_zst() => Immediate::Uninit,
// some fieldless enum variants can have non-zero size but still `Aggregate` ABI... try
// to detect those here and also give them no data