Sema: resoveTypeLayout resolves optionals and error unions too

Previously it only worked on struct, union, and array.
This commit is contained in:
Andrew Kelley 2021-10-21 23:22:55 -07:00
parent 6cd14f051d
commit 912e7dc54b

View File

@ -13662,6 +13662,15 @@ pub fn resolveTypeLayout(
const elem_ty = ty.childType();
return sema.resolveTypeLayout(block, src, elem_ty);
},
.Optional => {
var buf: Type.Payload.ElemType = undefined;
const payload_ty = ty.optionalChild(&buf);
return sema.resolveTypeLayout(block, src, payload_ty);
},
.ErrorUnion => {
const payload_ty = ty.errorUnionPayload();
return sema.resolveTypeLayout(block, src, payload_ty);
},
else => {},
}
}