Remove BackendRepr::Uninhabited
, replaced with an uninhabited: bool
field in LayoutData
.
Also update comments that refered to BackendRepr::Uninhabited.
This commit is contained in:
parent
28b83ee596
commit
7ba3d7b54e
26 changed files with 93 additions and 113 deletions
|
@ -385,7 +385,7 @@ impl<'tcx, Prov: Provenance> ImmTy<'tcx, Prov> {
|
|||
(Immediate::Uninit, _) => Immediate::Uninit,
|
||||
// If the field is uninhabited, we can forget the data (can happen in ConstProp).
|
||||
// `enum S { A(!), B, C }` is an example of an enum with Scalar layout that
|
||||
// has an `Uninhabited` variant, which means this case is possible.
|
||||
// has an uninhabited variant, which means this case is possible.
|
||||
_ if layout.is_uninhabited() => Immediate::Uninit,
|
||||
// the field contains no information, can be left uninit
|
||||
// (Scalar/ScalarPair can contain even aligned ZST, not just 1-ZST)
|
||||
|
|
|
@ -1274,11 +1274,11 @@ impl<'rt, 'tcx, M: Machine<'tcx>> ValueVisitor<'tcx, M> for ValidityVisitor<'rt,
|
|||
// FIXME: We could avoid some redundant checks here. For newtypes wrapping
|
||||
// scalars, we do the same check on every "level" (e.g., first we check
|
||||
// MyNewtype and then the scalar in there).
|
||||
if val.layout.is_uninhabited() {
|
||||
let ty = val.layout.ty;
|
||||
throw_validation_failure!(self.path, UninhabitedVal { ty });
|
||||
}
|
||||
match val.layout.backend_repr {
|
||||
BackendRepr::Uninhabited => {
|
||||
let ty = val.layout.ty;
|
||||
throw_validation_failure!(self.path, UninhabitedVal { ty });
|
||||
}
|
||||
BackendRepr::Scalar(scalar_layout) => {
|
||||
if !scalar_layout.is_uninit_valid() {
|
||||
// There is something to check here.
|
||||
|
|
|
@ -111,13 +111,15 @@ fn check_validity_requirement_lax<'tcx>(
|
|||
};
|
||||
|
||||
// Check the ABI.
|
||||
let valid = match this.backend_repr {
|
||||
BackendRepr::Uninhabited => false, // definitely UB
|
||||
BackendRepr::Scalar(s) => scalar_allows_raw_init(s),
|
||||
BackendRepr::ScalarPair(s1, s2) => scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2),
|
||||
BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s),
|
||||
BackendRepr::Memory { .. } => true, // Fields are checked below.
|
||||
};
|
||||
let valid = !this.is_uninhabited() // definitely UB if uninhabited
|
||||
&& match this.backend_repr {
|
||||
BackendRepr::Scalar(s) => scalar_allows_raw_init(s),
|
||||
BackendRepr::ScalarPair(s1, s2) => {
|
||||
scalar_allows_raw_init(s1) && scalar_allows_raw_init(s2)
|
||||
}
|
||||
BackendRepr::Vector { element: s, count } => count == 0 || scalar_allows_raw_init(s),
|
||||
BackendRepr::Memory { .. } => true, // Fields are checked below.
|
||||
};
|
||||
if !valid {
|
||||
// This is definitely not okay.
|
||||
return Ok(false);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue