Fix recover_access_chain_from_offset on unsized fields (#510)

This commit is contained in:
Ashley Hauck 2021-03-19 16:23:55 +01:00 committed by GitHub
parent 4bd0dcaf3f
commit 3bc8a8076b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -405,7 +405,10 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
let field_ty_kind = self.lookup_type(field_ty);
let offset_in_field = offset - field_offset;
if offset_in_field < field_ty_kind.sizeof(self)? {
if field_ty_kind
.sizeof(self)
.map_or(true, |size| offset_in_field < size)
{
Some((i, field_ty, field_ty_kind, offset_in_field))
} else {
None