authorgravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-12-13 22:30:06+01:00
committergravatar for r00ster91@proton.meWooster <r00ster91@proton.me> 2022-12-17 14:11:33+01:00
logaac2d6b56f32134ea32fb3d984e3fcdfddd8aaf6
tree941528727d4d0a5b92f58c0b862f0d5f372b89e0
parent7350ea3e2da4d4e6ef5092cd9f0832beef0291d5

std.builtin: rename Type.UnionField and Type.StructField's field_type to type


60 files changed, 177 insertions(+), 178 deletions(-)

doc/langref.html.in+1-1
...@@ -4253,7 +4253,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool {...@@ -4253,7 +4253,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool {
4253 return switch (field_index) {4253 return switch (field_index) {
4254 // This prong is analyzed `fields.len - 1` times with `idx` being an4254 // This prong is analyzed `fields.len - 1` times with `idx` being an
4255 // unique comptime-known value each time.4255 // unique comptime-known value each time.
4256 inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].field_type) == .Optional,4256 inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional,
4257 else => return error.IndexOutOfBounds,4257 else => return error.IndexOutOfBounds,
4258 };4258 };
4259}4259}
lib/std/array_hash_map.zig+4-4
...@@ -2270,13 +2270,13 @@ test "reIndex" {...@@ -2270,13 +2270,13 @@ test "reIndex" {
2270test "auto store_hash" {2270test "auto store_hash" {
2271 const HasCheapEql = AutoArrayHashMap(i32, i32);2271 const HasCheapEql = AutoArrayHashMap(i32, i32);
2272 const HasExpensiveEql = AutoArrayHashMap([32]i32, i32);2272 const HasExpensiveEql = AutoArrayHashMap([32]i32, i32);
2273 try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).field_type == void);2273 try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).type == void);
2274 try testing.expect(meta.fieldInfo(HasExpensiveEql.Data, .hash).field_type != void);2274 try testing.expect(meta.fieldInfo(HasExpensiveEql.Data, .hash).type != void);
22752275
2276 const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32);2276 const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32);
2277 const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32);2277 const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32);
2278 try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).field_type == void);2278 try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).type == void);
2279 try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Data, .hash).field_type != void);2279 try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Data, .hash).type != void);
2280}2280}
22812281
2282test "sort" {2282test "sort" {
lib/std/builtin.zig+2-3
...@@ -280,8 +280,7 @@ pub const Type = union(enum) {...@@ -280,8 +280,7 @@ pub const Type = union(enum) {
280 /// therefore must be kept in sync with the compiler implementation.280 /// therefore must be kept in sync with the compiler implementation.
281 pub const StructField = struct {281 pub const StructField = struct {
282 name: []const u8,282 name: []const u8,
283 /// TODO rename to `type`283 type: type,
284 field_type: type,
285 default_value: ?*const anyopaque,284 default_value: ?*const anyopaque,
286 is_comptime: bool,285 is_comptime: bool,
287 alignment: comptime_int,286 alignment: comptime_int,
...@@ -343,7 +342,7 @@ pub const Type = union(enum) {...@@ -343,7 +342,7 @@ pub const Type = union(enum) {
343 /// therefore must be kept in sync with the compiler implementation.342 /// therefore must be kept in sync with the compiler implementation.
344 pub const UnionField = struct {343 pub const UnionField = struct {
345 name: []const u8,344 name: []const u8,
346 field_type: type,345 type: type,
347 alignment: comptime_int,346 alignment: comptime_int,
348 };347 };
349348
lib/std/crypto/phc_encoding.zig+4-4
...@@ -110,9 +110,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult...@@ -110,9 +110,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
110 var found = false;110 var found = false;
111 inline for (comptime meta.fields(HashResult)) |p| {111 inline for (comptime meta.fields(HashResult)) |p| {
112 if (mem.eql(u8, p.name, param.key)) {112 if (mem.eql(u8, p.name, param.key)) {
113 switch (@typeInfo(p.field_type)) {113 switch (@typeInfo(p.type)) {
114 .Int => @field(out, p.name) = fmt.parseUnsigned(114 .Int => @field(out, p.name) = fmt.parseUnsigned(
115 p.field_type,115 p.type,
116 param.value,116 param.value,
117 10,117 10,
118 ) catch return Error.InvalidEncoding,118 ) catch return Error.InvalidEncoding,
...@@ -161,7 +161,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult...@@ -161,7 +161,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult
161 // with default values161 // with default values
162 var expected_fields: usize = 0;162 var expected_fields: usize = 0;
163 inline for (comptime meta.fields(HashResult)) |p| {163 inline for (comptime meta.fields(HashResult)) |p| {
164 if (@typeInfo(p.field_type) != .Optional and p.default_value == null) {164 if (@typeInfo(p.type) != .Optional and p.default_value == null) {
165 expected_fields += 1;165 expected_fields += 1;
166 }166 }
167 }167 }
...@@ -223,7 +223,7 @@ fn serializeTo(params: anytype, out: anytype) !void {...@@ -223,7 +223,7 @@ fn serializeTo(params: anytype, out: anytype) !void {
223 {223 {
224 const value = @field(params, p.name);224 const value = @field(params, p.name);
225 try out.writeAll(if (has_params) params_delimiter else fields_delimiter);225 try out.writeAll(if (has_params) params_delimiter else fields_delimiter);
226 if (@typeInfo(p.field_type) == .Struct) {226 if (@typeInfo(p.type) == .Struct) {
227 var buf: [@TypeOf(value).max_encoded_length]u8 = undefined;227 var buf: [@TypeOf(value).max_encoded_length]u8 = undefined;
228 try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) });228 try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) });
229 } else {229 } else {
lib/std/enums.zig+1-1
...@@ -15,7 +15,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def...@@ -15,7 +15,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
15 for (std.meta.fields(E)) |field| {15 for (std.meta.fields(E)) |field| {
16 fields = fields ++ &[_]StructField{.{16 fields = fields ++ &[_]StructField{.{
17 .name = field.name,17 .name = field.name,
18 .field_type = Data,18 .type = Data,
19 .default_value = if (field_default) |d| @ptrCast(?*const anyopaque, &d) else null,19 .default_value = if (field_default) |d| @ptrCast(?*const anyopaque, &d) else null,
20 .is_comptime = false,20 .is_comptime = false,
21 .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0,21 .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0,
lib/std/hash/auto_hash.zig+3-3
...@@ -134,7 +134,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {...@@ -134,7 +134,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void {
134 hash(hasher, tag, strat);134 hash(hasher, tag, strat);
135 inline for (info.fields) |field| {135 inline for (info.fields) |field| {
136 if (@field(tag_type, field.name) == tag) {136 if (@field(tag_type, field.name) == tag) {
137 if (field.field_type != void) {137 if (field.type != void) {
138 hash(hasher, @field(key, field.name), strat);138 hash(hasher, @field(key, field.name), strat);
139 }139 }
140 // TODO use a labelled break when it does not crash the compiler. cf #2908140 // TODO use a labelled break when it does not crash the compiler. cf #2908
...@@ -163,14 +163,14 @@ fn typeContainsSlice(comptime K: type) bool {...@@ -163,14 +163,14 @@ fn typeContainsSlice(comptime K: type) bool {
163 }163 }
164 if (meta.trait.is(.Struct)(K)) {164 if (meta.trait.is(.Struct)(K)) {
165 inline for (@typeInfo(K).Struct.fields) |field| {165 inline for (@typeInfo(K).Struct.fields) |field| {
166 if (typeContainsSlice(field.field_type)) {166 if (typeContainsSlice(field.type)) {
167 return true;167 return true;
168 }168 }
169 }169 }
170 }170 }
171 if (meta.trait.is(.Union)(K)) {171 if (meta.trait.is(.Union)(K)) {
172 inline for (@typeInfo(K).Union.fields) |field| {172 inline for (@typeInfo(K).Union.fields) |field| {
173 if (typeContainsSlice(field.field_type)) {173 if (typeContainsSlice(field.type)) {
174 return true;174 return true;
175 }175 }
176 }176 }
lib/std/io/multi_writer.zig+1-1
...@@ -6,7 +6,7 @@ const testing = std.testing;...@@ -6,7 +6,7 @@ const testing = std.testing;
6pub fn MultiWriter(comptime Writers: type) type {6pub fn MultiWriter(comptime Writers: type) type {
7 comptime var ErrSet = error{};7 comptime var ErrSet = error{};
8 inline for (@typeInfo(Writers).Struct.fields) |field| {8 inline for (@typeInfo(Writers).Struct.fields) |field| {
9 const StreamType = field.field_type;9 const StreamType = field.type;
10 ErrSet = ErrSet || StreamType.Error;10 ErrSet = ErrSet || StreamType.Error;
11 }11 }
1212
lib/std/json.zig+13-13
...@@ -1362,7 +1362,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ...@@ -1362,7 +1362,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ
1362 if (unionInfo.tag_type) |_| {1362 if (unionInfo.tag_type) |_| {
1363 var errors = error{NoUnionMembersMatched};1363 var errors = error{NoUnionMembersMatched};
1364 for (unionInfo.fields) |u_field| {1364 for (unionInfo.fields) |u_field| {
1365 errors = errors || ParseInternalErrorImpl(u_field.field_type, inferred_types ++ [_]type{T});1365 errors = errors || ParseInternalErrorImpl(u_field.type, inferred_types ++ [_]type{T});
1366 }1366 }
1367 return errors;1367 return errors;
1368 } else {1368 } else {
...@@ -1379,7 +1379,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ...@@ -1379,7 +1379,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ
1379 MissingField,1379 MissingField,
1380 } || SkipValueError || TokenStream.Error;1380 } || SkipValueError || TokenStream.Error;
1381 for (structInfo.fields) |field| {1381 for (structInfo.fields) |field| {
1382 errors = errors || ParseInternalErrorImpl(field.field_type, inferred_types ++ [_]type{T});1382 errors = errors || ParseInternalErrorImpl(field.type, inferred_types ++ [_]type{T});
1383 }1383 }
1384 return errors;1384 return errors;
1385 },1385 },
...@@ -1491,7 +1491,7 @@ fn parseInternal(...@@ -1491,7 +1491,7 @@ fn parseInternal(
1491 inline for (unionInfo.fields) |u_field| {1491 inline for (unionInfo.fields) |u_field| {
1492 // take a copy of tokens so we can withhold mutations until success1492 // take a copy of tokens so we can withhold mutations until success
1493 var tokens_copy = tokens.*;1493 var tokens_copy = tokens.*;
1494 if (parseInternal(u_field.field_type, token, &tokens_copy, options)) |value| {1494 if (parseInternal(u_field.type, token, &tokens_copy, options)) |value| {
1495 tokens.* = tokens_copy;1495 tokens.* = tokens_copy;
1496 return @unionInit(T, u_field.name, value);1496 return @unionInit(T, u_field.name, value);
1497 } else |err| {1497 } else |err| {
...@@ -1519,7 +1519,7 @@ fn parseInternal(...@@ -1519,7 +1519,7 @@ fn parseInternal(
1519 errdefer {1519 errdefer {
1520 inline for (structInfo.fields) |field, i| {1520 inline for (structInfo.fields) |field, i| {
1521 if (fields_seen[i] and !field.is_comptime) {1521 if (fields_seen[i] and !field.is_comptime) {
1522 parseFree(field.field_type, @field(r, field.name), options);1522 parseFree(field.type, @field(r, field.name), options);
1523 }1523 }
1524 }1524 }
1525 }1525 }
...@@ -1547,24 +1547,24 @@ fn parseInternal(...@@ -1547,24 +1547,24 @@ fn parseInternal(
1547 // }1547 // }
1548 if (options.duplicate_field_behavior == .UseFirst) {1548 if (options.duplicate_field_behavior == .UseFirst) {
1549 // unconditonally ignore value. for comptime fields, this skips check against default_value1549 // unconditonally ignore value. for comptime fields, this skips check against default_value
1550 parseFree(field.field_type, try parse(field.field_type, tokens, child_options), child_options);1550 parseFree(field.type, try parse(field.type, tokens, child_options), child_options);
1551 found = true;1551 found = true;
1552 break;1552 break;
1553 } else if (options.duplicate_field_behavior == .Error) {1553 } else if (options.duplicate_field_behavior == .Error) {
1554 return error.DuplicateJSONField;1554 return error.DuplicateJSONField;
1555 } else if (options.duplicate_field_behavior == .UseLast) {1555 } else if (options.duplicate_field_behavior == .UseLast) {
1556 if (!field.is_comptime) {1556 if (!field.is_comptime) {
1557 parseFree(field.field_type, @field(r, field.name), child_options);1557 parseFree(field.type, @field(r, field.name), child_options);
1558 }1558 }
1559 fields_seen[i] = false;1559 fields_seen[i] = false;
1560 }1560 }
1561 }1561 }
1562 if (field.is_comptime) {1562 if (field.is_comptime) {
1563 if (!try parsesTo(field.field_type, @ptrCast(*align(1) const field.field_type, field.default_value.?).*, tokens, child_options)) {1563 if (!try parsesTo(field.type, @ptrCast(*align(1) const field.type, field.default_value.?).*, tokens, child_options)) {
1564 return error.UnexpectedValue;1564 return error.UnexpectedValue;
1565 }1565 }
1566 } else {1566 } else {
1567 @field(r, field.name) = try parse(field.field_type, tokens, child_options);1567 @field(r, field.name) = try parse(field.type, tokens, child_options);
1568 }1568 }
1569 fields_seen[i] = true;1569 fields_seen[i] = true;
1570 found = true;1570 found = true;
...@@ -1587,7 +1587,7 @@ fn parseInternal(...@@ -1587,7 +1587,7 @@ fn parseInternal(
1587 if (!fields_seen[i]) {1587 if (!fields_seen[i]) {
1588 if (field.default_value) |default_ptr| {1588 if (field.default_value) |default_ptr| {
1589 if (!field.is_comptime) {1589 if (!field.is_comptime) {
1590 const default = @ptrCast(*align(1) const field.field_type, default_ptr).*;1590 const default = @ptrCast(*align(1) const field.type, default_ptr).*;
1591 @field(r, field.name) = default;1591 @field(r, field.name) = default;
1592 }1592 }
1593 } else {1593 } else {
...@@ -1732,7 +1732,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {...@@ -1732,7 +1732,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {
1732 if (unionInfo.tag_type) |UnionTagType| {1732 if (unionInfo.tag_type) |UnionTagType| {
1733 inline for (unionInfo.fields) |u_field| {1733 inline for (unionInfo.fields) |u_field| {
1734 if (value == @field(UnionTagType, u_field.name)) {1734 if (value == @field(UnionTagType, u_field.name)) {
1735 parseFree(u_field.field_type, @field(value, u_field.name), options);1735 parseFree(u_field.type, @field(value, u_field.name), options);
1736 break;1736 break;
1737 }1737 }
1738 }1738 }
...@@ -1743,7 +1743,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {...@@ -1743,7 +1743,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void {
1743 .Struct => |structInfo| {1743 .Struct => |structInfo| {
1744 inline for (structInfo.fields) |field| {1744 inline for (structInfo.fields) |field| {
1745 if (!field.is_comptime) {1745 if (!field.is_comptime) {
1746 parseFree(field.field_type, @field(value, field.name), options);1746 parseFree(field.type, @field(value, field.name), options);
1747 }1747 }
1748 }1748 }
1749 },1749 },
...@@ -2270,12 +2270,12 @@ pub fn stringify(...@@ -2270,12 +2270,12 @@ pub fn stringify(
2270 }2270 }
2271 inline for (S.fields) |Field| {2271 inline for (S.fields) |Field| {
2272 // don't include void fields2272 // don't include void fields
2273 if (Field.field_type == void) continue;2273 if (Field.type == void) continue;
22742274
2275 var emit_field = true;2275 var emit_field = true;
22762276
2277 // don't include optional fields that are null when emit_null_optional_fields is set to false2277 // don't include optional fields that are null when emit_null_optional_fields is set to false
2278 if (@typeInfo(Field.field_type) == .Optional) {2278 if (@typeInfo(Field.type) == .Optional) {
2279 if (options.emit_null_optional_fields == false) {2279 if (options.emit_null_optional_fields == false) {
2280 if (@field(value, Field.name) == null) {2280 if (@field(value, Field.name) == null) {
2281 emit_field = false;2281 emit_field = false;
lib/std/mem.zig+4-4
...@@ -300,7 +300,7 @@ pub fn zeroes(comptime T: type) T {...@@ -300,7 +300,7 @@ pub fn zeroes(comptime T: type) T {
300 if (comptime meta.containerLayout(T) == .Extern) {300 if (comptime meta.containerLayout(T) == .Extern) {
301 // The C language specification states that (global) unions301 // The C language specification states that (global) unions
302 // should be zero initialized to the first named member.302 // should be zero initialized to the first named member.
303 return @unionInit(T, info.fields[0].name, zeroes(info.fields[0].field_type));303 return @unionInit(T, info.fields[0].name, zeroes(info.fields[0].type));
304 }304 }
305305
306 @compileError("Can't set a " ++ @typeName(T) ++ " to zero.");306 @compileError("Can't set a " ++ @typeName(T) ++ " to zero.");
...@@ -435,7 +435,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {...@@ -435,7 +435,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
435435
436 inline for (struct_info.fields) |field| {436 inline for (struct_info.fields) |field| {
437 if (field.default_value) |default_value_ptr| {437 if (field.default_value) |default_value_ptr| {
438 const default_value = @ptrCast(*align(1) const field.field_type, default_value_ptr).*;438 const default_value = @ptrCast(*align(1) const field.type, default_value_ptr).*;
439 @field(value, field.name) = default_value;439 @field(value, field.name) = default_value;
440 }440 }
441 }441 }
...@@ -452,9 +452,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T {...@@ -452,9 +452,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
452 @compileError("Encountered an initializer for `" ++ field.name ++ "`, but it is not a field of " ++ @typeName(T));452 @compileError("Encountered an initializer for `" ++ field.name ++ "`, but it is not a field of " ++ @typeName(T));
453 }453 }
454454
455 switch (@typeInfo(field.field_type)) {455 switch (@typeInfo(field.type)) {
456 .Struct => {456 .Struct => {
457 @field(value, field.name) = zeroInit(field.field_type, @field(init, field.name));457 @field(value, field.name) = zeroInit(field.type, @field(init, field.name));
458 },458 },
459 else => {459 else => {
460 @field(value, field.name) = @field(init, field.name);460 @field(value, field.name) = @field(init, field.name);
lib/std/meta.zig+8-8
...@@ -522,8 +522,8 @@ test "std.meta.fields" {...@@ -522,8 +522,8 @@ test "std.meta.fields" {
522 try testing.expect(mem.eql(u8, e2f[0].name, "A"));522 try testing.expect(mem.eql(u8, e2f[0].name, "A"));
523 try testing.expect(mem.eql(u8, sf[0].name, "a"));523 try testing.expect(mem.eql(u8, sf[0].name, "a"));
524 try testing.expect(mem.eql(u8, uf[0].name, "a"));524 try testing.expect(mem.eql(u8, uf[0].name, "a"));
525 try testing.expect(comptime sf[0].field_type == u8);525 try testing.expect(comptime sf[0].type == u8);
526 try testing.expect(comptime uf[0].field_type == u8);526 try testing.expect(comptime uf[0].type == u8);
527}527}
528528
529pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {529pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
...@@ -557,8 +557,8 @@ test "std.meta.fieldInfo" {...@@ -557,8 +557,8 @@ test "std.meta.fieldInfo" {
557 try testing.expect(mem.eql(u8, e2f.name, "A"));557 try testing.expect(mem.eql(u8, e2f.name, "A"));
558 try testing.expect(mem.eql(u8, sf.name, "a"));558 try testing.expect(mem.eql(u8, sf.name, "a"));
559 try testing.expect(mem.eql(u8, uf.name, "a"));559 try testing.expect(mem.eql(u8, uf.name, "a"));
560 try testing.expect(comptime sf.field_type == u8);560 try testing.expect(comptime sf.type == u8);
561 try testing.expect(comptime uf.field_type == u8);561 try testing.expect(comptime uf.type == u8);
562}562}
563563
564pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 {564pub fn fieldNames(comptime T: type) *const [fields(T).len][]const u8 {
...@@ -831,7 +831,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {...@@ -831,7 +831,7 @@ pub fn TagPayload(comptime U: type, comptime tag: Tag(U)) type {
831831
832 inline for (info.fields) |field_info| {832 inline for (info.fields) |field_info| {
833 if (comptime mem.eql(u8, field_info.name, @tagName(tag)))833 if (comptime mem.eql(u8, field_info.name, @tagName(tag)))
834 return field_info.field_type;834 return field_info.type;
835 }835 }
836836
837 unreachable;837 unreachable;
...@@ -1111,7 +1111,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {...@@ -1111,7 +1111,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type {
1111 var num_buf: [128]u8 = undefined;1111 var num_buf: [128]u8 = undefined;
1112 tuple_fields[i] = .{1112 tuple_fields[i] = .{
1113 .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable,1113 .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable,
1114 .field_type = T,1114 .type = T,
1115 .default_value = null,1115 .default_value = null,
1116 .is_comptime = false,1116 .is_comptime = false,
1117 .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0,1117 .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0,
...@@ -1146,8 +1146,8 @@ const TupleTester = struct {...@@ -1146,8 +1146,8 @@ const TupleTester = struct {
1146 @compileError("Argument count mismatch");1146 @compileError("Argument count mismatch");
11471147
1148 inline for (fields_list) |fld, i| {1148 inline for (fields_list) |fld, i| {
1149 if (expected[i] != fld.field_type) {1149 if (expected[i] != fld.type) {
1150 @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.field_type));1150 @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.type));
1151 }1151 }
1152 }1152 }
1153 }1153 }
lib/std/meta/trailer_flags.zig+10-10
...@@ -24,10 +24,10 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -24,10 +24,10 @@ pub fn TrailerFlags(comptime Fields: type) type {
24 inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| {24 inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| {
25 fields[i] = Type.StructField{25 fields[i] = Type.StructField{
26 .name = struct_field.name,26 .name = struct_field.name,
27 .field_type = ?struct_field.field_type,27 .type = ?struct_field.type,
28 .default_value = &@as(?struct_field.field_type, null),28 .default_value = &@as(?struct_field.type, null),
29 .is_comptime = false,29 .is_comptime = false,
30 .alignment = @alignOf(?struct_field.field_type),30 .alignment = @alignOf(?struct_field.type),
31 };31 };
32 }32 }
33 break :blk @Type(.{33 break :blk @Type(.{
...@@ -105,26 +105,26 @@ pub fn TrailerFlags(comptime Fields: type) type {...@@ -105,26 +105,26 @@ pub fn TrailerFlags(comptime Fields: type) type {
105 const active = (self.bits & (1 << i)) != 0;105 const active = (self.bits & (1 << i)) != 0;
106 if (i == @enumToInt(field)) {106 if (i == @enumToInt(field)) {
107 assert(active);107 assert(active);
108 return mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type));108 return mem.alignForwardGeneric(usize, off, @alignOf(field_info.type));
109 } else if (active) {109 } else if (active) {
110 off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type));110 off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.type));
111 off += @sizeOf(field_info.field_type);111 off += @sizeOf(field_info.type);
112 }112 }
113 }113 }
114 }114 }
115115
116 pub fn Field(comptime field: FieldEnum) type {116 pub fn Field(comptime field: FieldEnum) type {
117 return @typeInfo(Fields).Struct.fields[@enumToInt(field)].field_type;117 return @typeInfo(Fields).Struct.fields[@enumToInt(field)].type;
118 }118 }
119119
120 pub fn sizeInBytes(self: Self) usize {120 pub fn sizeInBytes(self: Self) usize {
121 var off: usize = 0;121 var off: usize = 0;
122 inline for (@typeInfo(Fields).Struct.fields) |field, i| {122 inline for (@typeInfo(Fields).Struct.fields) |field, i| {
123 if (@sizeOf(field.field_type) == 0)123 if (@sizeOf(field.type) == 0)
124 continue;124 continue;
125 if ((self.bits & (1 << i)) != 0) {125 if ((self.bits & (1 << i)) != 0) {
126 off = mem.alignForwardGeneric(usize, off, @alignOf(field.field_type));126 off = mem.alignForwardGeneric(usize, off, @alignOf(field.type));
127 off += @sizeOf(field.field_type);127 off += @sizeOf(field.type);
128 }128 }
129 }129 }
130 return off;130 return off;
lib/std/meta/trait.zig+1-1
...@@ -566,7 +566,7 @@ pub fn hasUniqueRepresentation(comptime T: type) bool {...@@ -566,7 +566,7 @@ pub fn hasUniqueRepresentation(comptime T: type) bool {
566 var sum_size = @as(usize, 0);566 var sum_size = @as(usize, 0);
567567
568 inline for (info.fields) |field| {568 inline for (info.fields) |field| {
569 const FieldType = field.field_type;569 const FieldType = field.type;
570 if (comptime !hasUniqueRepresentation(FieldType)) return false;570 if (comptime !hasUniqueRepresentation(FieldType)) return false;
571 sum_size += @sizeOf(FieldType);571 sum_size += @sizeOf(FieldType);
572 }572 }
lib/std/multi_array_list.zig+13-13
...@@ -84,9 +84,9 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -84,9 +84,9 @@ pub fn MultiArrayList(comptime S: type) type {
84 var data: [fields.len]Data = undefined;84 var data: [fields.len]Data = undefined;
85 for (fields) |field_info, i| {85 for (fields) |field_info, i| {
86 data[i] = .{86 data[i] = .{
87 .size = @sizeOf(field_info.field_type),87 .size = @sizeOf(field_info.type),
88 .size_index = i,88 .size_index = i,
89 .alignment = if (@sizeOf(field_info.field_type) == 0) 1 else field_info.alignment,89 .alignment = if (@sizeOf(field_info.type) == 0) 1 else field_info.alignment,
90 };90 };
91 }91 }
92 const Sort = struct {92 const Sort = struct {
...@@ -294,10 +294,10 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -294,10 +294,10 @@ pub fn MultiArrayList(comptime S: type) type {
294 ) catch {294 ) catch {
295 const self_slice = self.slice();295 const self_slice = self.slice();
296 inline for (fields) |field_info, i| {296 inline for (fields) |field_info, i| {
297 if (@sizeOf(field_info.field_type) != 0) {297 if (@sizeOf(field_info.type) != 0) {
298 const field = @intToEnum(Field, i);298 const field = @intToEnum(Field, i);
299 const dest_slice = self_slice.items(field)[new_len..];299 const dest_slice = self_slice.items(field)[new_len..];
300 const byte_count = dest_slice.len * @sizeOf(field_info.field_type);300 const byte_count = dest_slice.len * @sizeOf(field_info.type);
301 // We use memset here for more efficient codegen in safety-checked,301 // We use memset here for more efficient codegen in safety-checked,
302 // valgrind-enabled builds. Otherwise the valgrind client request302 // valgrind-enabled builds. Otherwise the valgrind client request
303 // will be repeated for every element.303 // will be repeated for every element.
...@@ -316,9 +316,9 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -316,9 +316,9 @@ pub fn MultiArrayList(comptime S: type) type {
316 const self_slice = self.slice();316 const self_slice = self.slice();
317 const other_slice = other.slice();317 const other_slice = other.slice();
318 inline for (fields) |field_info, i| {318 inline for (fields) |field_info, i| {
319 if (@sizeOf(field_info.field_type) != 0) {319 if (@sizeOf(field_info.type) != 0) {
320 const field = @intToEnum(Field, i);320 const field = @intToEnum(Field, i);
321 mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field));321 mem.copy(field_info.type, other_slice.items(field), self_slice.items(field));
322 }322 }
323 }323 }
324 gpa.free(self.allocatedBytes());324 gpa.free(self.allocatedBytes());
...@@ -377,9 +377,9 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -377,9 +377,9 @@ pub fn MultiArrayList(comptime S: type) type {
377 const self_slice = self.slice();377 const self_slice = self.slice();
378 const other_slice = other.slice();378 const other_slice = other.slice();
379 inline for (fields) |field_info, i| {379 inline for (fields) |field_info, i| {
380 if (@sizeOf(field_info.field_type) != 0) {380 if (@sizeOf(field_info.type) != 0) {
381 const field = @intToEnum(Field, i);381 const field = @intToEnum(Field, i);
382 mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field));382 mem.copy(field_info.type, other_slice.items(field), self_slice.items(field));
383 }383 }
384 }384 }
385 gpa.free(self.allocatedBytes());385 gpa.free(self.allocatedBytes());
...@@ -396,9 +396,9 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -396,9 +396,9 @@ pub fn MultiArrayList(comptime S: type) type {
396 const self_slice = self.slice();396 const self_slice = self.slice();
397 const result_slice = result.slice();397 const result_slice = result.slice();
398 inline for (fields) |field_info, i| {398 inline for (fields) |field_info, i| {
399 if (@sizeOf(field_info.field_type) != 0) {399 if (@sizeOf(field_info.type) != 0) {
400 const field = @intToEnum(Field, i);400 const field = @intToEnum(Field, i);
401 mem.copy(field_info.field_type, result_slice.items(field), self_slice.items(field));401 mem.copy(field_info.type, result_slice.items(field), self_slice.items(field));
402 }402 }
403 }403 }
404 return result;404 return result;
...@@ -413,10 +413,10 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -413,10 +413,10 @@ pub fn MultiArrayList(comptime S: type) type {
413413
414 pub fn swap(sc: @This(), a_index: usize, b_index: usize) void {414 pub fn swap(sc: @This(), a_index: usize, b_index: usize) void {
415 inline for (fields) |field_info, i| {415 inline for (fields) |field_info, i| {
416 if (@sizeOf(field_info.field_type) != 0) {416 if (@sizeOf(field_info.type) != 0) {
417 const field = @intToEnum(Field, i);417 const field = @intToEnum(Field, i);
418 const ptr = sc.slice.items(field);418 const ptr = sc.slice.items(field);
419 mem.swap(field_info.field_type, &ptr[a_index], &ptr[b_index]);419 mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]);
420 }420 }
421 }421 }
422 }422 }
...@@ -449,7 +449,7 @@ pub fn MultiArrayList(comptime S: type) type {...@@ -449,7 +449,7 @@ pub fn MultiArrayList(comptime S: type) type {
449 }449 }
450450
451 fn FieldType(comptime field: Field) type {451 fn FieldType(comptime field: Field) type {
452 return meta.fieldInfo(S, field).field_type;452 return meta.fieldInfo(S, field).type;
453 }453 }
454454
455 /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate455 /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate
lib/std/os/uefi/protocols/device_path_protocol.zig+2-2
...@@ -81,7 +81,7 @@ pub const DevicePathProtocol = extern struct {...@@ -81,7 +81,7 @@ pub const DevicePathProtocol = extern struct {
81 // Got the associated union type for self.type, now81 // Got the associated union type for self.type, now
82 // we need to initialize it and its subtype82 // we need to initialize it and its subtype
83 if (self.type == enum_value) {83 if (self.type == enum_value) {
84 var subtype = self.initSubtype(ufield.field_type);84 var subtype = self.initSubtype(ufield.type);
8585
86 if (subtype) |sb| {86 if (subtype) |sb| {
87 // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } }87 // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } }
...@@ -103,7 +103,7 @@ pub const DevicePathProtocol = extern struct {...@@ -103,7 +103,7 @@ pub const DevicePathProtocol = extern struct {
103103
104 if (self.subtype == tag_val) {104 if (self.subtype == tag_val) {
105 // e.g. expr = .{ .Pci = @ptrCast(...) }105 // e.g. expr = .{ .Pci = @ptrCast(...) }
106 return @unionInit(TUnion, subtype.name, @ptrCast(subtype.field_type, self));106 return @unionInit(TUnion, subtype.name, @ptrCast(subtype.type, self));
107 }107 }
108 }108 }
109109
lib/std/testing.zig+1-1
...@@ -802,7 +802,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime...@@ -802,7 +802,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime
802802
803 const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn));803 const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn));
804 const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields;804 const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields;
805 if (fn_args_fields.len == 0 or fn_args_fields[0].field_type != std.mem.Allocator) {805 if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) {
806 @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");806 @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument");
807 }807 }
808 const expected_args_tuple_len = fn_args_fields.len - 1;808 const expected_args_tuple_len = fn_args_fields.len - 1;
lib/std/x/os/socket.zig+4-4
...@@ -230,12 +230,12 @@ pub const Socket = struct {...@@ -230,12 +230,12 @@ pub const Socket = struct {
230230
231 pub fn setName(self: *Self, name: []const u8) void {231 pub fn setName(self: *Self, name: []const u8) void {
232 self.name = @ptrToInt(name.ptr);232 self.name = @ptrToInt(name.ptr);
233 self.name_len = @intCast(meta.fieldInfo(Self, .name_len).field_type, name.len);233 self.name_len = @intCast(meta.fieldInfo(Self, .name_len).type, name.len);
234 }234 }
235235
236 pub fn setBuffers(self: *Self, buffers: []const Buffer) void {236 pub fn setBuffers(self: *Self, buffers: []const Buffer) void {
237 self.buffers = @ptrToInt(buffers.ptr);237 self.buffers = @ptrToInt(buffers.ptr);
238 self.buffers_len = @intCast(meta.fieldInfo(Self, .buffers_len).field_type, buffers.len);238 self.buffers_len = @intCast(meta.fieldInfo(Self, .buffers_len).type, buffers.len);
239 }239 }
240240
241 pub fn setControl(self: *Self, control: []const u8) void {241 pub fn setControl(self: *Self, control: []const u8) void {
...@@ -243,12 +243,12 @@ pub const Socket = struct {...@@ -243,12 +243,12 @@ pub const Socket = struct {
243 self.control = Buffer.from(control);243 self.control = Buffer.from(control);
244 } else {244 } else {
245 self.control = @ptrToInt(control.ptr);245 self.control = @ptrToInt(control.ptr);
246 self.control_len = @intCast(meta.fieldInfo(Self, .control_len).field_type, control.len);246 self.control_len = @intCast(meta.fieldInfo(Self, .control_len).type, control.len);
247 }247 }
248 }248 }
249249
250 pub fn setFlags(self: *Self, flags: u32) void {250 pub fn setFlags(self: *Self, flags: u32) void {
251 self.flags = @intCast(meta.fieldInfo(Self, .flags).field_type, flags);251 self.flags = @intCast(meta.fieldInfo(Self, .flags).type, flags);
252 }252 }
253253
254 pub fn getName(self: Self) []const u8 {254 pub fn getName(self: Self) []const u8 {
lib/std/zig/Ast.zig+1-1
...@@ -125,7 +125,7 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T {...@@ -125,7 +125,7 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T {
125 const fields = std.meta.fields(T);125 const fields = std.meta.fields(T);
126 var result: T = undefined;126 var result: T = undefined;
127 inline for (fields) |field, i| {127 inline for (fields) |field, i| {
128 comptime assert(field.field_type == Node.Index);128 comptime assert(field.type == Node.Index);
129 @field(result, field.name) = tree.extra_data[index + i];129 @field(result, field.name) = tree.extra_data[index + i];
130 }130 }
131 return result;131 return result;
lib/std/zig/c_translation.zig+1-1
...@@ -50,7 +50,7 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {...@@ -50,7 +50,7 @@ pub fn cast(comptime DestType: type, target: anytype) DestType {
50 },50 },
51 .Union => |info| {51 .Union => |info| {
52 inline for (info.fields) |field| {52 inline for (info.fields) |field| {
53 if (field.field_type == SourceType) return @unionInit(DestType, field.name, target);53 if (field.type == SourceType) return @unionInit(DestType, field.name, target);
54 }54 }
55 @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");55 @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union");
56 },56 },
lib/std/zig/parse.zig+1-1
...@@ -153,7 +153,7 @@ const Parser = struct {...@@ -153,7 +153,7 @@ const Parser = struct {
153 try p.extra_data.ensureUnusedCapacity(p.gpa, fields.len);153 try p.extra_data.ensureUnusedCapacity(p.gpa, fields.len);
154 const result = @intCast(u32, p.extra_data.items.len);154 const result = @intCast(u32, p.extra_data.items.len);
155 inline for (fields) |field| {155 inline for (fields) |field| {
156 comptime assert(field.field_type == Node.Index);156 comptime assert(field.type == Node.Index);
157 p.extra_data.appendAssumeCapacity(@field(extra, field.name));157 p.extra_data.appendAssumeCapacity(@field(extra, field.name));
158 }158 }
159 return result;159 return result;
src/Air.zig+1-1
...@@ -1260,7 +1260,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end...@@ -1260,7 +1260,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end
1260 var i: usize = index;1260 var i: usize = index;
1261 var result: T = undefined;1261 var result: T = undefined;
1262 inline for (fields) |field| {1262 inline for (fields) |field| {
1263 @field(result, field.name) = switch (field.field_type) {1263 @field(result, field.name) = switch (field.type) {
1264 u32 => air.extra[i],1264 u32 => air.extra[i],
1265 Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]),1265 Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]),
1266 i32 => @bitCast(i32, air.extra[i]),1266 i32 => @bitCast(i32, air.extra[i]),
src/AstGen.zig+1-1
...@@ -79,7 +79,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {...@@ -79,7 +79,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void {
79 const fields = std.meta.fields(@TypeOf(extra));79 const fields = std.meta.fields(@TypeOf(extra));
80 var i = index;80 var i = index;
81 inline for (fields) |field| {81 inline for (fields) |field| {
82 astgen.extra.items[i] = switch (field.field_type) {82 astgen.extra.items[i] = switch (field.type) {
83 u32 => @field(extra, field.name),83 u32 => @field(extra, field.name),
84 Zir.Inst.Ref => @enumToInt(@field(extra, field.name)),84 Zir.Inst.Ref => @enumToInt(@field(extra, field.name)),
85 i32 => @bitCast(u32, @field(extra, field.name)),85 i32 => @bitCast(u32, @field(extra, field.name)),
src/Autodoc.zig+2-2
...@@ -637,9 +637,9 @@ const DocData = struct {...@@ -637,9 +637,9 @@ const DocData = struct {
637 inline for (comptime std.meta.fields(Type)) |case| {637 inline for (comptime std.meta.fields(Type)) |case| {
638 if (@field(Type, case.name) == active_tag) {638 if (@field(Type, case.name) == active_tag) {
639 const current_value = @field(self, case.name);639 const current_value = @field(self, case.name);
640 inline for (comptime std.meta.fields(case.field_type)) |f| {640 inline for (comptime std.meta.fields(case.type)) |f| {
641 try jsw.arrayElem();641 try jsw.arrayElem();
642 if (f.field_type == std.builtin.Type.Pointer.Size) {642 if (f.type == std.builtin.Type.Pointer.Size) {
643 try jsw.emitNumber(@enumToInt(@field(current_value, f.name)));643 try jsw.emitNumber(@enumToInt(@field(current_value, f.name)));
644 } else {644 } else {
645 try std.json.stringify(@field(current_value, f.name), opts, w);645 try std.json.stringify(@field(current_value, f.name), opts, w);
src/InternPool.zig+2-2
...@@ -259,7 +259,7 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {...@@ -259,7 +259,7 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 {
259 const fields = std.meta.fields(@TypeOf(extra));259 const fields = std.meta.fields(@TypeOf(extra));
260 const result = @intCast(u32, ip.extra.items.len);260 const result = @intCast(u32, ip.extra.items.len);
261 inline for (fields) |field| {261 inline for (fields) |field| {
262 ip.extra.appendAssumeCapacity(switch (field.field_type) {262 ip.extra.appendAssumeCapacity(switch (field.type) {
263 u32 => @field(extra, field.name),263 u32 => @field(extra, field.name),
264 Index => @enumToInt(@field(extra, field.name)),264 Index => @enumToInt(@field(extra, field.name)),
265 i32 => @bitCast(u32, @field(extra, field.name)),265 i32 => @bitCast(u32, @field(extra, field.name)),
...@@ -274,7 +274,7 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T {...@@ -274,7 +274,7 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T {
274 var i: usize = index;274 var i: usize = index;
275 var result: T = undefined;275 var result: T = undefined;
276 inline for (fields) |field| {276 inline for (fields) |field| {
277 @field(result, field.name) = switch (field.field_type) {277 @field(result, field.name) = switch (field.type) {
278 u32 => ip.extra.items[i],278 u32 => ip.extra.items[i],
279 Index => @intToEnum(Index, ip.extra.items[i]),279 Index => @intToEnum(Index, ip.extra.items[i]),
280 i32 => @bitCast(i32, ip.extra.items[i]),280 i32 => @bitCast(i32, ip.extra.items[i]),
src/Liveness.zig+1-1
...@@ -718,7 +718,7 @@ const Analysis = struct {...@@ -718,7 +718,7 @@ const Analysis = struct {
718 const fields = std.meta.fields(@TypeOf(extra));718 const fields = std.meta.fields(@TypeOf(extra));
719 const result = @intCast(u32, a.extra.items.len);719 const result = @intCast(u32, a.extra.items.len);
720 inline for (fields) |field| {720 inline for (fields) |field| {
721 a.extra.appendAssumeCapacity(switch (field.field_type) {721 a.extra.appendAssumeCapacity(switch (field.type) {
722 u32 => @field(extra, field.name),722 u32 => @field(extra, field.name),
723 else => @compileError("bad field type"),723 else => @compileError("bad field type"),
724 });724 });
src/Sema.zig+11-11
...@@ -15767,7 +15767,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15767,7 +15767,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15767 union_field_fields.* = .{15767 union_field_fields.* = .{
15768 // name: []const u8,15768 // name: []const u8,
15769 name_val,15769 name_val,
15770 // field_type: type,15770 // type: type,
15771 try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty),15771 try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty),
15772 // alignment: comptime_int,15772 // alignment: comptime_int,
15773 try Value.Tag.int_u64.create(fields_anon_decl.arena(), alignment),15773 try Value.Tag.int_u64.create(fields_anon_decl.arena(), alignment),
...@@ -15880,7 +15880,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15880,7 +15880,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15880 struct_field_fields.* = .{15880 struct_field_fields.* = .{
15881 // name: []const u8,15881 // name: []const u8,
15882 name_val,15882 name_val,
15883 // field_type: type,15883 // type: type,
15884 try Value.Tag.ty.create(fields_anon_decl.arena(), field_ty),15884 try Value.Tag.ty.create(fields_anon_decl.arena(), field_ty),
15885 // default_value: ?*const anyopaque,15885 // default_value: ?*const anyopaque,
15886 try default_val_ptr.copy(fields_anon_decl.arena()),15886 try default_val_ptr.copy(fields_anon_decl.arena()),
...@@ -15925,7 +15925,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai...@@ -15925,7 +15925,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
15925 struct_field_fields.* = .{15925 struct_field_fields.* = .{
15926 // name: []const u8,15926 // name: []const u8,
15927 name_val,15927 name_val,
15928 // field_type: type,15928 // type: type,
15929 try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty),15929 try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty),
15930 // default_value: ?*const anyopaque,15930 // default_value: ?*const anyopaque,
15931 try default_val_ptr.copy(fields_anon_decl.arena()),15931 try default_val_ptr.copy(fields_anon_decl.arena()),
...@@ -18574,8 +18574,8 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in...@@ -18574,8 +18574,8 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
18574 // TODO use reflection instead of magic numbers here18574 // TODO use reflection instead of magic numbers here
18575 // name: []const u818575 // name: []const u8
18576 const name_val = field_struct_val[0];18576 const name_val = field_struct_val[0];
18577 // field_type: type,18577 // type: type,
18578 const field_type_val = field_struct_val[1];18578 const type_val = field_struct_val[1];
18579 // alignment: comptime_int,18579 // alignment: comptime_int,
18580 const alignment_val = field_struct_val[2];18580 const alignment_val = field_struct_val[2];
1858118581
...@@ -18609,7 +18609,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in...@@ -18609,7 +18609,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in
18609 }18609 }
1861018610
18611 var buffer: Value.ToTypeBuffer = undefined;18611 var buffer: Value.ToTypeBuffer = undefined;
18612 const field_ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator);18612 const field_ty = try type_val.toType(&buffer).copy(new_decl_arena_allocator);
18613 gop.value_ptr.* = .{18613 gop.value_ptr.* = .{
18614 .ty = field_ty,18614 .ty = field_ty,
18615 .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema)).?),18615 .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema)).?),
...@@ -18828,9 +18828,9 @@ fn reifyStruct(...@@ -18828,9 +18828,9 @@ fn reifyStruct(
18828 // TODO use reflection instead of magic numbers here18828 // TODO use reflection instead of magic numbers here
18829 // name: []const u818829 // name: []const u8
18830 const name_val = field_struct_val[0];18830 const name_val = field_struct_val[0];
18831 // field_type: type,18831 // type: type,
18832 const field_type_val = field_struct_val[1];18832 const type_val = field_struct_val[1];
18833 //default_value: ?*const anyopaque,18833 // default_value: ?*const anyopaque,
18834 const default_value_val = field_struct_val[2];18834 const default_value_val = field_struct_val[2];
18835 // is_comptime: bool,18835 // is_comptime: bool,
18836 const is_comptime_val = field_struct_val[3];18836 const is_comptime_val = field_struct_val[3];
...@@ -18893,7 +18893,7 @@ fn reifyStruct(...@@ -18893,7 +18893,7 @@ fn reifyStruct(
18893 }18893 }
1889418894
18895 var buffer: Value.ToTypeBuffer = undefined;18895 var buffer: Value.ToTypeBuffer = undefined;
18896 const field_ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator);18896 const field_ty = try type_val.toType(&buffer).copy(new_decl_arena_allocator);
18897 gop.value_ptr.* = .{18897 gop.value_ptr.* = .{
18898 .ty = field_ty,18898 .ty = field_ty,
18899 .abi_align = abi_align,18899 .abi_align = abi_align,
...@@ -31439,7 +31439,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {...@@ -31439,7 +31439,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 {
31439 const fields = std.meta.fields(@TypeOf(extra));31439 const fields = std.meta.fields(@TypeOf(extra));
31440 const result = @intCast(u32, sema.air_extra.items.len);31440 const result = @intCast(u32, sema.air_extra.items.len);
31441 inline for (fields) |field| {31441 inline for (fields) |field| {
31442 sema.air_extra.appendAssumeCapacity(switch (field.field_type) {31442 sema.air_extra.appendAssumeCapacity(switch (field.type) {
31443 u32 => @field(extra, field.name),31443 u32 => @field(extra, field.name),
31444 Air.Inst.Ref => @enumToInt(@field(extra, field.name)),31444 Air.Inst.Ref => @enumToInt(@field(extra, field.name)),
31445 i32 => @bitCast(u32, @field(extra, field.name)),31445 i32 => @bitCast(u32, @field(extra, field.name)),
src/Zir.zig+1-1
...@@ -71,7 +71,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en...@@ -71,7 +71,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en
71 var i: usize = index;71 var i: usize = index;
72 var result: T = undefined;72 var result: T = undefined;
73 inline for (fields) |field| {73 inline for (fields) |field| {
74 @field(result, field.name) = switch (field.field_type) {74 @field(result, field.name) = switch (field.type) {
75 u32 => code.extra[i],75 u32 => code.extra[i],
76 Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]),76 Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]),
77 i32 => @bitCast(i32, code.extra[i]),77 i32 => @bitCast(i32, code.extra[i]),
src/arch/aarch64/CodeGen.zig+1-1
...@@ -477,7 +477,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -477,7 +477,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
477 const fields = std.meta.fields(@TypeOf(extra));477 const fields = std.meta.fields(@TypeOf(extra));
478 const result = @intCast(u32, self.mir_extra.items.len);478 const result = @intCast(u32, self.mir_extra.items.len);
479 inline for (fields) |field| {479 inline for (fields) |field| {
480 self.mir_extra.appendAssumeCapacity(switch (field.field_type) {480 self.mir_extra.appendAssumeCapacity(switch (field.type) {
481 u32 => @field(extra, field.name),481 u32 => @field(extra, field.name),
482 i32 => @bitCast(u32, @field(extra, field.name)),482 i32 => @bitCast(u32, @field(extra, field.name)),
483 else => @compileError("bad field type"),483 else => @compileError("bad field type"),
src/arch/aarch64/Mir.zig+1-1
...@@ -505,7 +505,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end...@@ -505,7 +505,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end
505 var i: usize = index;505 var i: usize = index;
506 var result: T = undefined;506 var result: T = undefined;
507 inline for (fields) |field| {507 inline for (fields) |field| {
508 @field(result, field.name) = switch (field.field_type) {508 @field(result, field.name) = switch (field.type) {
509 u32 => mir.extra[i],509 u32 => mir.extra[i],
510 i32 => @bitCast(i32, mir.extra[i]),510 i32 => @bitCast(i32, mir.extra[i]),
511 else => @compileError("bad field type"),511 else => @compileError("bad field type"),
src/arch/arm/CodeGen.zig+1-1
...@@ -386,7 +386,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -386,7 +386,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
386 const fields = std.meta.fields(@TypeOf(extra));386 const fields = std.meta.fields(@TypeOf(extra));
387 const result = @intCast(u32, self.mir_extra.items.len);387 const result = @intCast(u32, self.mir_extra.items.len);
388 inline for (fields) |field| {388 inline for (fields) |field| {
389 self.mir_extra.appendAssumeCapacity(switch (field.field_type) {389 self.mir_extra.appendAssumeCapacity(switch (field.type) {
390 u32 => @field(extra, field.name),390 u32 => @field(extra, field.name),
391 i32 => @bitCast(u32, @field(extra, field.name)),391 i32 => @bitCast(u32, @field(extra, field.name)),
392 else => @compileError("bad field type"),392 else => @compileError("bad field type"),
src/arch/arm/Mir.zig+1-1
...@@ -283,7 +283,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end...@@ -283,7 +283,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end
283 var i: usize = index;283 var i: usize = index;
284 var result: T = undefined;284 var result: T = undefined;
285 inline for (fields) |field| {285 inline for (fields) |field| {
286 @field(result, field.name) = switch (field.field_type) {286 @field(result, field.name) = switch (field.type) {
287 u32 => mir.extra[i],287 u32 => mir.extra[i],
288 i32 => @bitCast(i32, mir.extra[i]),288 i32 => @bitCast(i32, mir.extra[i]),
289 else => @compileError("bad field type"),289 else => @compileError("bad field type"),
src/arch/riscv64/CodeGen.zig+1-1
...@@ -340,7 +340,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -340,7 +340,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
340 const fields = std.meta.fields(@TypeOf(extra));340 const fields = std.meta.fields(@TypeOf(extra));
341 const result = @intCast(u32, self.mir_extra.items.len);341 const result = @intCast(u32, self.mir_extra.items.len);
342 inline for (fields) |field| {342 inline for (fields) |field| {
343 self.mir_extra.appendAssumeCapacity(switch (field.field_type) {343 self.mir_extra.appendAssumeCapacity(switch (field.type) {
344 u32 => @field(extra, field.name),344 u32 => @field(extra, field.name),
345 i32 => @bitCast(u32, @field(extra, field.name)),345 i32 => @bitCast(u32, @field(extra, field.name)),
346 else => @compileError("bad field type"),346 else => @compileError("bad field type"),
src/arch/riscv64/Mir.zig+1-1
...@@ -132,7 +132,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end...@@ -132,7 +132,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end
132 var i: usize = index;132 var i: usize = index;
133 var result: T = undefined;133 var result: T = undefined;
134 inline for (fields) |field| {134 inline for (fields) |field| {
135 @field(result, field.name) = switch (field.field_type) {135 @field(result, field.name) = switch (field.type) {
136 u32 => mir.extra[i],136 u32 => mir.extra[i],
137 i32 => @bitCast(i32, mir.extra[i]),137 i32 => @bitCast(i32, mir.extra[i]),
138 else => @compileError("bad field type"),138 else => @compileError("bad field type"),
src/arch/sparc64/Mir.zig+1-1
...@@ -347,7 +347,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end...@@ -347,7 +347,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end
347 var i: usize = index;347 var i: usize = index;
348 var result: T = undefined;348 var result: T = undefined;
349 inline for (fields) |field| {349 inline for (fields) |field| {
350 @field(result, field.name) = switch (field.field_type) {350 @field(result, field.name) = switch (field.type) {
351 u32 => mir.extra[i],351 u32 => mir.extra[i],
352 i32 => @bitCast(i32, mir.extra[i]),352 i32 => @bitCast(i32, mir.extra[i]),
353 else => @compileError("bad field type"),353 else => @compileError("bad field type"),
src/arch/wasm/CodeGen.zig+1-1
...@@ -960,7 +960,7 @@ fn addExtraAssumeCapacity(func: *CodeGen, extra: anytype) error{OutOfMemory}!u32...@@ -960,7 +960,7 @@ fn addExtraAssumeCapacity(func: *CodeGen, extra: anytype) error{OutOfMemory}!u32
960 const fields = std.meta.fields(@TypeOf(extra));960 const fields = std.meta.fields(@TypeOf(extra));
961 const result = @intCast(u32, func.mir_extra.items.len);961 const result = @intCast(u32, func.mir_extra.items.len);
962 inline for (fields) |field| {962 inline for (fields) |field| {
963 func.mir_extra.appendAssumeCapacity(switch (field.field_type) {963 func.mir_extra.appendAssumeCapacity(switch (field.type) {
964 u32 => @field(extra, field.name),964 u32 => @field(extra, field.name),
965 else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)),965 else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)),
966 });966 });
src/arch/wasm/Mir.zig+1-1
...@@ -589,7 +589,7 @@ pub fn extraData(self: *const Mir, comptime T: type, index: usize) struct { data...@@ -589,7 +589,7 @@ pub fn extraData(self: *const Mir, comptime T: type, index: usize) struct { data
589 var i: usize = index;589 var i: usize = index;
590 var result: T = undefined;590 var result: T = undefined;
591 inline for (fields) |field| {591 inline for (fields) |field| {
592 @field(result, field.name) = switch (field.field_type) {592 @field(result, field.name) = switch (field.type) {
593 u32 => self.extra[i],593 u32 => self.extra[i],
594 else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)),594 else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)),
595 };595 };
src/arch/x86_64/CodeGen.zig+1-1
...@@ -374,7 +374,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {...@@ -374,7 +374,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 {
374 const fields = std.meta.fields(@TypeOf(extra));374 const fields = std.meta.fields(@TypeOf(extra));
375 const result = @intCast(u32, self.mir_extra.items.len);375 const result = @intCast(u32, self.mir_extra.items.len);
376 inline for (fields) |field| {376 inline for (fields) |field| {
377 self.mir_extra.appendAssumeCapacity(switch (field.field_type) {377 self.mir_extra.appendAssumeCapacity(switch (field.type) {
378 u32 => @field(extra, field.name),378 u32 => @field(extra, field.name),
379 i32 => @bitCast(u32, @field(extra, field.name)),379 i32 => @bitCast(u32, @field(extra, field.name)),
380 else => @compileError("bad field type"),380 else => @compileError("bad field type"),
src/arch/x86_64/Mir.zig+1-1
...@@ -612,7 +612,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end...@@ -612,7 +612,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end
612 var i: usize = index;612 var i: usize = index;
613 var result: T = undefined;613 var result: T = undefined;
614 inline for (fields) |field| {614 inline for (fields) |field| {
615 @field(result, field.name) = switch (field.field_type) {615 @field(result, field.name) = switch (field.type) {
616 u32 => mir.extra[i],616 u32 => mir.extra[i],
617 i32 => @bitCast(i32, mir.extra[i]),617 i32 => @bitCast(i32, mir.extra[i]),
618 else => @compileError("bad field type"),618 else => @compileError("bad field type"),
src/codegen/spirv/Section.zig+7-7
...@@ -116,7 +116,7 @@ fn writeOperands(section: *Section, comptime Operands: type, operands: Operands)...@@ -116,7 +116,7 @@ fn writeOperands(section: *Section, comptime Operands: type, operands: Operands)
116 };116 };
117117
118 inline for (fields) |field| {118 inline for (fields) |field| {
119 section.writeOperand(field.field_type, @field(operands, field.name));119 section.writeOperand(field.type, @field(operands, field.name));
120 }120 }
121}121}
122122
...@@ -196,7 +196,7 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe...@@ -196,7 +196,7 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe
196fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void {196fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void {
197 var mask: Word = 0;197 var mask: Word = 0;
198 inline for (@typeInfo(Operand).Struct.fields) |field, bit| {198 inline for (@typeInfo(Operand).Struct.fields) |field, bit| {
199 switch (@typeInfo(field.field_type)) {199 switch (@typeInfo(field.type)) {
200 .Optional => if (@field(operand, field.name) != null) {200 .Optional => if (@field(operand, field.name) != null) {
201 mask |= 1 << @intCast(u5, bit);201 mask |= 1 << @intCast(u5, bit);
202 },202 },
...@@ -214,7 +214,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand...@@ -214,7 +214,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand
214 section.writeWord(mask);214 section.writeWord(mask);
215215
216 inline for (@typeInfo(Operand).Struct.fields) |field| {216 inline for (@typeInfo(Operand).Struct.fields) |field| {
217 switch (@typeInfo(field.field_type)) {217 switch (@typeInfo(field.type)) {
218 .Optional => |info| if (@field(operand, field.name)) |child| {218 .Optional => |info| if (@field(operand, field.name)) |child| {
219 section.writeOperands(info.child, child);219 section.writeOperands(info.child, child);
220 },220 },
...@@ -230,7 +230,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan...@@ -230,7 +230,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan
230230
231 inline for (@typeInfo(Operand).Union.fields) |field| {231 inline for (@typeInfo(Operand).Union.fields) |field| {
232 if (@field(Operand, field.name) == tag) {232 if (@field(Operand, field.name) == tag) {
233 section.writeOperands(field.field_type, @field(operand, field.name));233 section.writeOperands(field.type, @field(operand, field.name));
234 return;234 return;
235 }235 }
236 }236 }
...@@ -250,7 +250,7 @@ fn operandsSize(comptime Operands: type, operands: Operands) usize {...@@ -250,7 +250,7 @@ fn operandsSize(comptime Operands: type, operands: Operands) usize {
250250
251 var total: usize = 0;251 var total: usize = 0;
252 inline for (fields) |field| {252 inline for (fields) |field| {
253 total += operandSize(field.field_type, @field(operands, field.name));253 total += operandSize(field.type, @field(operands, field.name));
254 }254 }
255255
256 return total;256 return total;
...@@ -304,7 +304,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize {...@@ -304,7 +304,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize {
304 var total: usize = 0;304 var total: usize = 0;
305 var any_set = false;305 var any_set = false;
306 inline for (@typeInfo(Operand).Struct.fields) |field| {306 inline for (@typeInfo(Operand).Struct.fields) |field| {
307 switch (@typeInfo(field.field_type)) {307 switch (@typeInfo(field.type)) {
308 .Optional => |info| if (@field(operand, field.name)) |child| {308 .Optional => |info| if (@field(operand, field.name)) |child| {
309 total += operandsSize(info.child, child);309 total += operandsSize(info.child, child);
310 any_set = true;310 any_set = true;
...@@ -326,7 +326,7 @@ fn extendedUnionSize(comptime Operand: type, operand: Operand) usize {...@@ -326,7 +326,7 @@ fn extendedUnionSize(comptime Operand: type, operand: Operand) usize {
326 inline for (@typeInfo(Operand).Union.fields) |field| {326 inline for (@typeInfo(Operand).Union.fields) |field| {
327 if (@field(Operand, field.name) == tag) {327 if (@field(Operand, field.name) == tag) {
328 // Add one for the tag itself.328 // Add one for the tag itself.
329 return 1 + operandsSize(field.field_type, @field(operand, field.name));329 return 1 + operandsSize(field.type, @field(operand, field.name));
330 }330 }
331 }331 }
332 unreachable;332 unreachable;
src/link/tapi/yaml.zig+5-5
...@@ -339,7 +339,7 @@ pub const Yaml = struct {...@@ -339,7 +339,7 @@ pub const Yaml = struct {
339339
340 if (union_info.tag_type) |_| {340 if (union_info.tag_type) |_| {
341 inline for (union_info.fields) |field| {341 inline for (union_info.fields) |field| {
342 if (self.parseValue(field.field_type, value)) |u_value| {342 if (self.parseValue(field.type, value)) |u_value| {
343 return @unionInit(T, field.name, u_value);343 return @unionInit(T, field.name, u_value);
344 } else |err| {344 } else |err| {
345 if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err;345 if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err;
...@@ -366,16 +366,16 @@ pub const Yaml = struct {...@@ -366,16 +366,16 @@ pub const Yaml = struct {
366 break :blk map.get(field_name);366 break :blk map.get(field_name);
367 };367 };
368368
369 if (@typeInfo(field.field_type) == .Optional) {369 if (@typeInfo(field.type) == .Optional) {
370 @field(parsed, field.name) = try self.parseOptional(field.field_type, value);370 @field(parsed, field.name) = try self.parseOptional(field.type, value);
371 continue;371 continue;
372 }372 }
373373
374 const unwrapped = value orelse {374 const unwrapped = value orelse {
375 log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.field_type) });375 log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.type) });
376 return error.StructFieldMissing;376 return error.StructFieldMissing;
377 };377 };
378 @field(parsed, field.name) = try self.parseValue(field.field_type, unwrapped);378 @field(parsed, field.name) = try self.parseValue(field.type, unwrapped);
379 }379 }
380380
381 return parsed;381 return parsed;
src/print_zir.zig+4-4
...@@ -1312,7 +1312,7 @@ const Writer = struct {...@@ -1312,7 +1312,7 @@ const Writer = struct {
1312 type_len: u32 = 0,1312 type_len: u32 = 0,
1313 align_len: u32 = 0,1313 align_len: u32 = 0,
1314 init_len: u32 = 0,1314 init_len: u32 = 0,
1315 field_type: Zir.Inst.Ref = .none,1315 type: Zir.Inst.Ref = .none,
1316 name: u32,1316 name: u32,
1317 is_comptime: bool,1317 is_comptime: bool,
1318 };1318 };
...@@ -1353,7 +1353,7 @@ const Writer = struct {...@@ -1353,7 +1353,7 @@ const Writer = struct {
1353 if (has_type_body) {1353 if (has_type_body) {
1354 fields[field_i].type_len = self.code.extra[extra_index];1354 fields[field_i].type_len = self.code.extra[extra_index];
1355 } else {1355 } else {
1356 fields[field_i].field_type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);1356 fields[field_i].type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]);
1357 }1357 }
1358 extra_index += 1;1358 extra_index += 1;
13591359
...@@ -1384,8 +1384,8 @@ const Writer = struct {...@@ -1384,8 +1384,8 @@ const Writer = struct {
1384 } else {1384 } else {
1385 try stream.print("@\"{d}\": ", .{i});1385 try stream.print("@\"{d}\": ", .{i});
1386 }1386 }
1387 if (field.field_type != .none) {1387 if (field.type != .none) {
1388 try self.writeInstRef(stream, field.field_type);1388 try self.writeInstRef(stream, field.type);
1389 }1389 }
13901390
1391 if (field.type_len > 0) {1391 if (field.type_len > 0) {
src/translate_c/ast.zig+2-2
...@@ -392,7 +392,7 @@ pub const Node = extern union {...@@ -392,7 +392,7 @@ pub const Node = extern union {
392 }392 }
393393
394 pub fn Data(comptime t: Tag) type {394 pub fn Data(comptime t: Tag) type {
395 return std.meta.fieldInfo(t.Type(), .data).field_type;395 return std.meta.fieldInfo(t.Type(), .data).type;
396 }396 }
397 };397 };
398398
...@@ -845,7 +845,7 @@ const Context = struct {...@@ -845,7 +845,7 @@ const Context = struct {
845 try c.extra_data.ensureUnusedCapacity(c.gpa, fields.len);845 try c.extra_data.ensureUnusedCapacity(c.gpa, fields.len);
846 const result = @intCast(u32, c.extra_data.items.len);846 const result = @intCast(u32, c.extra_data.items.len);
847 inline for (fields) |field| {847 inline for (fields) |field| {
848 comptime std.debug.assert(field.field_type == NodeIndex);848 comptime std.debug.assert(field.type == NodeIndex);
849 c.extra_data.appendAssumeCapacity(@field(extra, field.name));849 c.extra_data.appendAssumeCapacity(@field(extra, field.name));
850 }850 }
851 return result;851 return result;
src/type.zig+1-1
...@@ -6216,7 +6216,7 @@ pub const Type = extern union {...@@ -6216,7 +6216,7 @@ pub const Type = extern union {
6216 }6216 }
62176217
6218 pub fn Data(comptime t: Tag) type {6218 pub fn Data(comptime t: Tag) type {
6219 return std.meta.fieldInfo(t.Type(), .data).field_type;6219 return std.meta.fieldInfo(t.Type(), .data).type;
6220 }6220 }
6221 };6221 };
62226222
src/value.zig+1-1
...@@ -338,7 +338,7 @@ pub const Value = extern union {...@@ -338,7 +338,7 @@ pub const Value = extern union {
338 }338 }
339339
340 pub fn Data(comptime t: Tag) type {340 pub fn Data(comptime t: Tag) type {
341 return std.meta.fieldInfo(t.Type(), .data).field_type;341 return std.meta.fieldInfo(t.Type(), .data).type;
342 }342 }
343 };343 };
344344
test/behavior/bitcast.zig+1-1
...@@ -358,7 +358,7 @@ test "comptime @bitCast packed struct to int and back" {...@@ -358,7 +358,7 @@ test "comptime @bitCast packed struct to int and back" {
358 const rt_cast = @bitCast(S, i);358 const rt_cast = @bitCast(S, i);
359 const ct_cast = comptime @bitCast(S, @as(Int, 0));359 const ct_cast = comptime @bitCast(S, @as(Int, 0));
360 inline for (@typeInfo(S).Struct.fields) |field| {360 inline for (@typeInfo(S).Struct.fields) |field| {
361 if (@typeInfo(field.field_type) == .Vector)361 if (@typeInfo(field.type) == .Vector)
362 continue; //TODO: https://github.com/ziglang/zig/issues/13201362 continue; //TODO: https://github.com/ziglang/zig/issues/13201
363363
364 try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name));364 try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name));
test/behavior/bugs/12786.zig+1-1
...@@ -8,7 +8,7 @@ fn NamespacedGlobals(comptime modules: anytype) type {...@@ -8,7 +8,7 @@ fn NamespacedGlobals(comptime modules: anytype) type {
8 .fields = &.{8 .fields = &.{
9 .{9 .{
10 .name = "globals",10 .name = "globals",
11 .field_type = modules.mach.globals,11 .type = modules.mach.globals,
12 .default_value = null,12 .default_value = null,
13 .is_comptime = false,13 .is_comptime = false,
14 .alignment = @alignOf(modules.mach.globals),14 .alignment = @alignOf(modules.mach.globals),
test/behavior/bugs/12794.zig+1-1
...@@ -7,7 +7,7 @@ fn NamespacedComponents(comptime modules: anytype) type {...@@ -7,7 +7,7 @@ fn NamespacedComponents(comptime modules: anytype) type {
7 .is_tuple = false,7 .is_tuple = false,
8 .fields = &.{.{8 .fields = &.{.{
9 .name = "components",9 .name = "components",
10 .field_type = @TypeOf(modules.components),10 .type = @TypeOf(modules.components),
11 .default_value = null,11 .default_value = null,
12 .is_comptime = false,12 .is_comptime = false,
13 .alignment = @alignOf(@TypeOf(modules.components)),13 .alignment = @alignOf(@TypeOf(modules.components)),
test/behavior/bugs/13435.zig+1-1
...@@ -8,7 +8,7 @@ fn CreateUnion(comptime T: type) type {...@@ -8,7 +8,7 @@ fn CreateUnion(comptime T: type) type {
8 .fields = &[_]std.builtin.Type.UnionField{8 .fields = &[_]std.builtin.Type.UnionField{
9 .{9 .{
10 .name = "field",10 .name = "field",
11 .field_type = T,11 .type = T,
12 .alignment = @alignOf(T),12 .alignment = @alignOf(T),
13 },13 },
14 },14 },
test/behavior/bugs/6456.zig+1-1
...@@ -23,7 +23,7 @@ test "issue 6456" {...@@ -23,7 +23,7 @@ test "issue 6456" {
23 fields = fields ++ &[_]StructField{StructField{23 fields = fields ++ &[_]StructField{StructField{
24 .alignment = 0,24 .alignment = 0,
25 .name = name,25 .name = name,
26 .field_type = usize,26 .type = usize,
27 .default_value = &@as(?usize, null),27 .default_value = &@as(?usize, null),
28 .is_comptime = false,28 .is_comptime = false,
29 }};29 }};
test/behavior/tuple.zig+3-3
...@@ -136,14 +136,14 @@ test "array-like initializer for tuple types" {...@@ -136,14 +136,14 @@ test "array-like initializer for tuple types" {
136 .fields = &.{136 .fields = &.{
137 .{137 .{
138 .name = "0",138 .name = "0",
139 .field_type = i32,139 .type = i32,
140 .default_value = null,140 .default_value = null,
141 .is_comptime = false,141 .is_comptime = false,
142 .alignment = @alignOf(i32),142 .alignment = @alignOf(i32),
143 },143 },
144 .{144 .{
145 .name = "1",145 .name = "1",
146 .field_type = u8,146 .type = u8,
147 .default_value = null,147 .default_value = null,
148 .is_comptime = false,148 .is_comptime = false,
149 .alignment = @alignOf(i32),149 .alignment = @alignOf(i32),
...@@ -314,7 +314,7 @@ test "zero sized struct in tuple handled correctly" {...@@ -314,7 +314,7 @@ test "zero sized struct in tuple handled correctly" {
314 .decls = &.{},314 .decls = &.{},
315 .fields = &.{.{315 .fields = &.{.{
316 .name = "0",316 .name = "0",
317 .field_type = struct {},317 .type = struct {},
318 .default_value = null,318 .default_value = null,
319 .is_comptime = false,319 .is_comptime = false,
320 .alignment = 0,320 .alignment = 0,
test/behavior/tuple_declarations.zig+5-5
...@@ -20,13 +20,13 @@ test "tuple declaration type info" {...@@ -20,13 +20,13 @@ test "tuple declaration type info" {
20 try expect(info.is_tuple);20 try expect(info.is_tuple);
2121
22 try expectEqualStrings(info.fields[0].name, "0");22 try expectEqualStrings(info.fields[0].name, "0");
23 try expect(info.fields[0].field_type == u32);23 try expect(info.fields[0].type == u32);
24 try expect(@ptrCast(*const u32, @alignCast(@alignOf(u32), info.fields[0].default_value)).* == 1);24 try expect(@ptrCast(*const u32, @alignCast(@alignOf(u32), info.fields[0].default_value)).* == 1);
25 try expect(info.fields[0].is_comptime);25 try expect(info.fields[0].is_comptime);
26 try expect(info.fields[0].alignment == 2);26 try expect(info.fields[0].alignment == 2);
2727
28 try expectEqualStrings(info.fields[1].name, "1");28 try expectEqualStrings(info.fields[1].name, "1");
29 try expect(info.fields[1].field_type == []const u8);29 try expect(info.fields[1].type == []const u8);
30 try expect(info.fields[1].default_value == null);30 try expect(info.fields[1].default_value == null);
31 try expect(!info.fields[1].is_comptime);31 try expect(!info.fields[1].is_comptime);
32 try expect(info.fields[1].alignment == @alignOf([]const u8));32 try expect(info.fields[1].alignment == @alignOf([]const u8));
...@@ -44,13 +44,13 @@ test "tuple declaration type info" {...@@ -44,13 +44,13 @@ test "tuple declaration type info" {
44 try expect(info.is_tuple);44 try expect(info.is_tuple);
4545
46 try expectEqualStrings(info.fields[0].name, "0");46 try expectEqualStrings(info.fields[0].name, "0");
47 try expect(info.fields[0].field_type == u1);47 try expect(info.fields[0].type == u1);
4848
49 try expectEqualStrings(info.fields[1].name, "1");49 try expectEqualStrings(info.fields[1].name, "1");
50 try expect(info.fields[1].field_type == u30);50 try expect(info.fields[1].type == u30);
5151
52 try expectEqualStrings(info.fields[2].name, "2");52 try expectEqualStrings(info.fields[2].name, "2");
53 try expect(info.fields[2].field_type == u1);53 try expect(info.fields[2].type == u1);
54 }54 }
55}55}
5656
test/behavior/type.zig+19-19
...@@ -268,10 +268,10 @@ test "Type.Struct" {...@@ -268,10 +268,10 @@ test "Type.Struct" {
268 const infoA = @typeInfo(A).Struct;268 const infoA = @typeInfo(A).Struct;
269 try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout);269 try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout);
270 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);270 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);
271 try testing.expectEqual(u8, infoA.fields[0].field_type);271 try testing.expectEqual(u8, infoA.fields[0].type);
272 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);272 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);
273 try testing.expectEqualSlices(u8, "y", infoA.fields[1].name);273 try testing.expectEqualSlices(u8, "y", infoA.fields[1].name);
274 try testing.expectEqual(u32, infoA.fields[1].field_type);274 try testing.expectEqual(u32, infoA.fields[1].type);
275 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value);275 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value);
276 try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls);276 try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls);
277 try testing.expectEqual(@as(bool, false), infoA.is_tuple);277 try testing.expectEqual(@as(bool, false), infoA.is_tuple);
...@@ -286,10 +286,10 @@ test "Type.Struct" {...@@ -286,10 +286,10 @@ test "Type.Struct" {
286 const infoB = @typeInfo(B).Struct;286 const infoB = @typeInfo(B).Struct;
287 try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout);287 try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout);
288 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);288 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);
289 try testing.expectEqual(u8, infoB.fields[0].field_type);289 try testing.expectEqual(u8, infoB.fields[0].type);
290 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);290 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);
291 try testing.expectEqualSlices(u8, "y", infoB.fields[1].name);291 try testing.expectEqualSlices(u8, "y", infoB.fields[1].name);
292 try testing.expectEqual(u32, infoB.fields[1].field_type);292 try testing.expectEqual(u32, infoB.fields[1].type);
293 try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoB.fields[1].default_value.?).*);293 try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoB.fields[1].default_value.?).*);
294 try testing.expectEqual(@as(usize, 0), infoB.decls.len);294 try testing.expectEqual(@as(usize, 0), infoB.decls.len);
295 try testing.expectEqual(@as(bool, false), infoB.is_tuple);295 try testing.expectEqual(@as(bool, false), infoB.is_tuple);
...@@ -298,10 +298,10 @@ test "Type.Struct" {...@@ -298,10 +298,10 @@ test "Type.Struct" {
298 const infoC = @typeInfo(C).Struct;298 const infoC = @typeInfo(C).Struct;
299 try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout);299 try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout);
300 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);300 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);
301 try testing.expectEqual(u8, infoC.fields[0].field_type);301 try testing.expectEqual(u8, infoC.fields[0].type);
302 try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*);302 try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*);
303 try testing.expectEqualSlices(u8, "y", infoC.fields[1].name);303 try testing.expectEqualSlices(u8, "y", infoC.fields[1].name);
304 try testing.expectEqual(u32, infoC.fields[1].field_type);304 try testing.expectEqual(u32, infoC.fields[1].type);
305 try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoC.fields[1].default_value.?).*);305 try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoC.fields[1].default_value.?).*);
306 try testing.expectEqual(@as(usize, 0), infoC.decls.len);306 try testing.expectEqual(@as(usize, 0), infoC.decls.len);
307 try testing.expectEqual(@as(bool, false), infoC.is_tuple);307 try testing.expectEqual(@as(bool, false), infoC.is_tuple);
...@@ -311,10 +311,10 @@ test "Type.Struct" {...@@ -311,10 +311,10 @@ test "Type.Struct" {
311 const infoD = @typeInfo(D).Struct;311 const infoD = @typeInfo(D).Struct;
312 try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout);312 try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout);
313 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);313 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);
314 try testing.expectEqual(comptime_int, infoD.fields[0].field_type);314 try testing.expectEqual(comptime_int, infoD.fields[0].type);
315 try testing.expectEqual(@as(comptime_int, 3), @ptrCast(*const comptime_int, infoD.fields[0].default_value.?).*);315 try testing.expectEqual(@as(comptime_int, 3), @ptrCast(*const comptime_int, infoD.fields[0].default_value.?).*);
316 try testing.expectEqualSlices(u8, "y", infoD.fields[1].name);316 try testing.expectEqualSlices(u8, "y", infoD.fields[1].name);
317 try testing.expectEqual(comptime_int, infoD.fields[1].field_type);317 try testing.expectEqual(comptime_int, infoD.fields[1].type);
318 try testing.expectEqual(@as(comptime_int, 5), @ptrCast(*const comptime_int, infoD.fields[1].default_value.?).*);318 try testing.expectEqual(@as(comptime_int, 5), @ptrCast(*const comptime_int, infoD.fields[1].default_value.?).*);
319 try testing.expectEqual(@as(usize, 0), infoD.decls.len);319 try testing.expectEqual(@as(usize, 0), infoD.decls.len);
320 try testing.expectEqual(@as(bool, false), infoD.is_tuple);320 try testing.expectEqual(@as(bool, false), infoD.is_tuple);
...@@ -324,10 +324,10 @@ test "Type.Struct" {...@@ -324,10 +324,10 @@ test "Type.Struct" {
324 const infoE = @typeInfo(E).Struct;324 const infoE = @typeInfo(E).Struct;
325 try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout);325 try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout);
326 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);326 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);
327 try testing.expectEqual(comptime_int, infoE.fields[0].field_type);327 try testing.expectEqual(comptime_int, infoE.fields[0].type);
328 try testing.expectEqual(@as(comptime_int, 1), @ptrCast(*const comptime_int, infoE.fields[0].default_value.?).*);328 try testing.expectEqual(@as(comptime_int, 1), @ptrCast(*const comptime_int, infoE.fields[0].default_value.?).*);
329 try testing.expectEqualSlices(u8, "1", infoE.fields[1].name);329 try testing.expectEqualSlices(u8, "1", infoE.fields[1].name);
330 try testing.expectEqual(comptime_int, infoE.fields[1].field_type);330 try testing.expectEqual(comptime_int, infoE.fields[1].type);
331 try testing.expectEqual(@as(comptime_int, 2), @ptrCast(*const comptime_int, infoE.fields[1].default_value.?).*);331 try testing.expectEqual(@as(comptime_int, 2), @ptrCast(*const comptime_int, infoE.fields[1].default_value.?).*);
332 try testing.expectEqual(@as(usize, 0), infoE.decls.len);332 try testing.expectEqual(@as(usize, 0), infoE.decls.len);
333 try testing.expectEqual(@as(bool, true), infoE.is_tuple);333 try testing.expectEqual(@as(bool, true), infoE.is_tuple);
...@@ -396,8 +396,8 @@ test "Type.Union" {...@@ -396,8 +396,8 @@ test "Type.Union" {
396 .layout = .Extern,396 .layout = .Extern,
397 .tag_type = null,397 .tag_type = null,
398 .fields = &.{398 .fields = &.{
399 .{ .name = "int", .field_type = i32, .alignment = @alignOf(f32) },399 .{ .name = "int", .type = i32, .alignment = @alignOf(f32) },
400 .{ .name = "float", .field_type = f32, .alignment = @alignOf(f32) },400 .{ .name = "float", .type = f32, .alignment = @alignOf(f32) },
401 },401 },
402 .decls = &.{},402 .decls = &.{},
403 },403 },
...@@ -412,8 +412,8 @@ test "Type.Union" {...@@ -412,8 +412,8 @@ test "Type.Union" {
412 .layout = .Packed,412 .layout = .Packed,
413 .tag_type = null,413 .tag_type = null,
414 .fields = &.{414 .fields = &.{
415 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },415 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
416 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },416 .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) },
417 },417 },
418 .decls = &.{},418 .decls = &.{},
419 },419 },
...@@ -439,8 +439,8 @@ test "Type.Union" {...@@ -439,8 +439,8 @@ test "Type.Union" {
439 .layout = .Auto,439 .layout = .Auto,
440 .tag_type = Tag,440 .tag_type = Tag,
441 .fields = &.{441 .fields = &.{
442 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },442 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
443 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },443 .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) },
444 },444 },
445 .decls = &.{},445 .decls = &.{},
446 },446 },
...@@ -470,7 +470,7 @@ test "Type.Union from Type.Enum" {...@@ -470,7 +470,7 @@ test "Type.Union from Type.Enum" {
470 .layout = .Auto,470 .layout = .Auto,
471 .tag_type = Tag,471 .tag_type = Tag,
472 .fields = &.{472 .fields = &.{
473 .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) },473 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },
474 },474 },
475 .decls = &.{},475 .decls = &.{},
476 },476 },
...@@ -487,7 +487,7 @@ test "Type.Union from regular enum" {...@@ -487,7 +487,7 @@ test "Type.Union from regular enum" {
487 .layout = .Auto,487 .layout = .Auto,
488 .tag_type = E,488 .tag_type = E,
489 .fields = &.{489 .fields = &.{
490 .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) },490 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },
491 },491 },
492 .decls = &.{},492 .decls = &.{},
493 },493 },
...@@ -537,7 +537,7 @@ test "reified struct field name from optional payload" {...@@ -537,7 +537,7 @@ test "reified struct field name from optional payload" {
537 .layout = .Auto,537 .layout = .Auto,
538 .fields = &.{.{538 .fields = &.{.{
539 .name = name,539 .name = name,
540 .field_type = u8,540 .type = u8,
541 .default_value = null,541 .default_value = null,
542 .is_comptime = false,542 .is_comptime = false,
543 .alignment = 1,543 .alignment = 1,
test/behavior/type_info.zig+4-4
...@@ -257,7 +257,7 @@ fn testUnion() !void {...@@ -257,7 +257,7 @@ fn testUnion() !void {
257 try expect(typeinfo_info.Union.layout == .Auto);257 try expect(typeinfo_info.Union.layout == .Auto);
258 try expect(typeinfo_info.Union.tag_type.? == TypeId);258 try expect(typeinfo_info.Union.tag_type.? == TypeId);
259 try expect(typeinfo_info.Union.fields.len == 24);259 try expect(typeinfo_info.Union.fields.len == 24);
260 try expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int));260 try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int));
261 try expect(typeinfo_info.Union.decls.len == 22);261 try expect(typeinfo_info.Union.decls.len == 22);
262262
263 const TestNoTagUnion = union {263 const TestNoTagUnion = union {
...@@ -271,7 +271,7 @@ fn testUnion() !void {...@@ -271,7 +271,7 @@ fn testUnion() !void {
271 try expect(notag_union_info.Union.layout == .Auto);271 try expect(notag_union_info.Union.layout == .Auto);
272 try expect(notag_union_info.Union.fields.len == 2);272 try expect(notag_union_info.Union.fields.len == 2);
273 try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void));273 try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void));
274 try expect(notag_union_info.Union.fields[1].field_type == u32);274 try expect(notag_union_info.Union.fields[1].type == u32);
275 try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32));275 try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32));
276276
277 const TestExternUnion = extern union {277 const TestExternUnion = extern union {
...@@ -281,7 +281,7 @@ fn testUnion() !void {...@@ -281,7 +281,7 @@ fn testUnion() !void {
281 const extern_union_info = @typeInfo(TestExternUnion);281 const extern_union_info = @typeInfo(TestExternUnion);
282 try expect(extern_union_info.Union.layout == .Extern);282 try expect(extern_union_info.Union.layout == .Extern);
283 try expect(extern_union_info.Union.tag_type == null);283 try expect(extern_union_info.Union.tag_type == null);
284 try expect(extern_union_info.Union.fields[0].field_type == *anyopaque);284 try expect(extern_union_info.Union.fields[0].type == *anyopaque);
285}285}
286286
287test "type info: struct info" {287test "type info: struct info" {
...@@ -319,7 +319,7 @@ fn testPackedStruct() !void {...@@ -319,7 +319,7 @@ fn testPackedStruct() !void {
319 try expect(struct_info.Struct.backing_integer == u128);319 try expect(struct_info.Struct.backing_integer == u128);
320 try expect(struct_info.Struct.fields.len == 4);320 try expect(struct_info.Struct.fields.len == 4);
321 try expect(struct_info.Struct.fields[0].alignment == 0);321 try expect(struct_info.Struct.fields[0].alignment == 0);
322 try expect(struct_info.Struct.fields[2].field_type == f32);322 try expect(struct_info.Struct.fields[2].type == f32);
323 try expect(struct_info.Struct.fields[2].default_value == null);323 try expect(struct_info.Struct.fields[2].default_value == null);
324 try expect(@ptrCast(*align(1) const u32, struct_info.Struct.fields[3].default_value.?).* == 4);324 try expect(@ptrCast(*align(1) const u32, struct_info.Struct.fields[3].default_value.?).* == 4);
325 try expect(struct_info.Struct.fields[3].alignment == 0);325 try expect(struct_info.Struct.fields[3].alignment == 0);
test/behavior/union.zig+1-1
...@@ -454,7 +454,7 @@ test "global union with single field is correctly initialized" {...@@ -454,7 +454,7 @@ test "global union with single field is correctly initialized" {
454 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO454 if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO
455455
456 glbl = Foo1{456 glbl = Foo1{
457 .f = @typeInfo(Foo1).Union.fields[0].field_type{ .x = 123 },457 .f = @typeInfo(Foo1).Union.fields[0].type{ .x = 123 },
458 };458 };
459 try expect(glbl.f.x == 123);459 try expect(glbl.f.x == 123);
460}460}
test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig+1-1
...@@ -9,7 +9,7 @@ pub export fn entry() void {...@@ -9,7 +9,7 @@ pub export fn entry() void {
9 const info = @typeInfo(Widget).Union;9 const info = @typeInfo(Widget).Union;
10 inline for (info.fields) |field| {10 inline for (info.fields) |field| {
11 if (foo()) {11 if (foo()) {
12 switch (field.field_type) {12 switch (field.type) {
13 u0 => a = 2,13 u0 => a = 2,
14 else => unreachable,14 else => unreachable,
15 }15 }
test/cases/compile_errors/dereference_anyopaque.zig+1-1
...@@ -16,7 +16,7 @@ fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void {...@@ -16,7 +16,7 @@ fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void {
16 .Struct => |structInfo| {16 .Struct => |structInfo| {
17 inline for (structInfo.fields) |field| {17 inline for (structInfo.fields) |field| {
18 if (!field.is_comptime)18 if (!field.is_comptime)
19 parseFree(field.field_type, undefined, allocator);19 parseFree(field.type, undefined, allocator);
20 }20 }
21 },21 },
22 .Pointer => |ptrInfo| {22 .Pointer => |ptrInfo| {
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1
...@@ -1,6 +1,6 @@...@@ -1,6 +1,6 @@
1export fn entry() void {1export fn entry() void {
2 _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{2 _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{
3 .{ .name = "one", .field_type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },3 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },
4 }, .decls = &.{}, .is_tuple = false } });4 }, .decls = &.{}, .is_tuple = false } });
5}5}
66
test/cases/compile_errors/reify_struct.zig+5-5
...@@ -3,7 +3,7 @@ comptime {...@@ -3,7 +3,7 @@ comptime {
3 .layout = .Auto,3 .layout = .Auto,
4 .fields = &.{.{4 .fields = &.{.{
5 .name = "foo",5 .name = "foo",
6 .field_type = u32,6 .type = u32,
7 .default_value = null,7 .default_value = null,
8 .is_comptime = false,8 .is_comptime = false,
9 .alignment = 4,9 .alignment = 4,
...@@ -17,7 +17,7 @@ comptime {...@@ -17,7 +17,7 @@ comptime {
17 .layout = .Auto,17 .layout = .Auto,
18 .fields = &.{.{18 .fields = &.{.{
19 .name = "3",19 .name = "3",
20 .field_type = u32,20 .type = u32,
21 .default_value = null,21 .default_value = null,
22 .is_comptime = false,22 .is_comptime = false,
23 .alignment = 4,23 .alignment = 4,
...@@ -31,7 +31,7 @@ comptime {...@@ -31,7 +31,7 @@ comptime {
31 .layout = .Auto,31 .layout = .Auto,
32 .fields = &.{.{32 .fields = &.{.{
33 .name = "0",33 .name = "0",
34 .field_type = u32,34 .type = u32,
35 .default_value = null,35 .default_value = null,
36 .is_comptime = true,36 .is_comptime = true,
37 .alignment = 4,37 .alignment = 4,
...@@ -45,7 +45,7 @@ comptime {...@@ -45,7 +45,7 @@ comptime {
45 .layout = .Extern,45 .layout = .Extern,
46 .fields = &.{.{46 .fields = &.{.{
47 .name = "0",47 .name = "0",
48 .field_type = u32,48 .type = u32,
49 .default_value = null,49 .default_value = null,
50 .is_comptime = true,50 .is_comptime = true,
51 .alignment = 4,51 .alignment = 4,
...@@ -59,7 +59,7 @@ comptime {...@@ -59,7 +59,7 @@ comptime {
59 .layout = .Packed,59 .layout = .Packed,
60 .fields = &.{.{60 .fields = &.{.{
61 .name = "0",61 .name = "0",
62 .field_type = u32,62 .type = u32,
63 .default_value = null,63 .default_value = null,
64 .is_comptime = true,64 .is_comptime = true,
65 .alignment = 4,65 .alignment = 4,
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+2-2
...@@ -16,8 +16,8 @@ const Tagged = @Type(.{...@@ -16,8 +16,8 @@ const Tagged = @Type(.{
16 .layout = .Auto,16 .layout = .Auto,
17 .tag_type = Tag,17 .tag_type = Tag,
18 .fields = &.{18 .fields = &.{
19 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },19 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
20 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },20 .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) },
21 },21 },
22 .decls = &.{},22 .decls = &.{},
23 },23 },
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+3-3
...@@ -15,9 +15,9 @@ const Tagged = @Type(.{...@@ -15,9 +15,9 @@ const Tagged = @Type(.{
15 .layout = .Auto,15 .layout = .Auto,
16 .tag_type = Tag,16 .tag_type = Tag,
17 .fields = &.{17 .fields = &.{
18 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },18 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
19 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },19 .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) },
20 .{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) },20 .{ .name = "arst", .type = f32, .alignment = @alignOf(f32) },
21 },21 },
22 .decls = &.{},22 .decls = &.{},
23 },23 },
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+2-2
...@@ -3,7 +3,7 @@ const Untagged = @Type(.{...@@ -3,7 +3,7 @@ const Untagged = @Type(.{
3 .layout = .Auto,3 .layout = .Auto,
4 .tag_type = null,4 .tag_type = null,
5 .fields = &.{5 .fields = &.{
6 .{ .name = "foo", .field_type = opaque {}, .alignment = 1 },6 .{ .name = "foo", .type = opaque {}, .alignment = 1 },
7 },7 },
8 .decls = &.{},8 .decls = &.{},
9 },9 },
...@@ -17,4 +17,4 @@ export fn entry() usize {...@@ -17,4 +17,4 @@ export fn entry() usize {
17// target=native17// target=native
18//18//
19// :1:18: error: opaque types have unknown size and therefore cannot be directly embedded in unions19// :1:18: error: opaque types have unknown size and therefore cannot be directly embedded in unions
20// :6:45: note: opaque declared here20// :6:39: note: opaque declared here