stage2: lower each struct field type, align, init separately
Previously, struct types, alignment values, and initialization expressions were all lowered into the same ZIR body, which caused false positive "depends on itself" errors when the initialization expression depended on the size of the struct. This also uses ResultLoc.coerced_ty for struct field alignment and initialization values. The resulting ZIR encoding ends up being roughly the same, neither smaller nor larger than previously. Closes #12029
This commit is contained in:
@@ -916,13 +916,14 @@ pub const Struct = struct {
|
||||
/// one possible value.
|
||||
known_non_opv: bool,
|
||||
requires_comptime: PropertyBoolean = .unknown,
|
||||
have_field_inits: bool = false,
|
||||
|
||||
pub const Fields = std.StringArrayHashMapUnmanaged(Field);
|
||||
|
||||
/// The `Type` and `Value` memory is owned by the arena of the Struct's owner_decl.
|
||||
pub const Field = struct {
|
||||
/// Uses `noreturn` to indicate `anytype`.
|
||||
/// undefined until `status` is `have_field_types` or `have_layout`.
|
||||
/// undefined until `status` is >= `have_field_types`.
|
||||
ty: Type,
|
||||
/// Uses `unreachable_value` to indicate no default.
|
||||
default_val: Value,
|
||||
|
||||
Reference in New Issue
Block a user