| author | |
| committer | |
| log | aac2d6b56f32134ea32fb3d984e3fcdfddd8aaf6 |
| tree | 941528727d4d0a5b92f58c0b862f0d5f372b89e0 |
| parent | 7350ea3e2da4d4e6ef5092cd9f0832beef0291d5 |
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 | 4253 | return switch (field_index) { |
| 4254 | 4254 | // This prong is analyzed `fields.len - 1` times with `idx` being an |
| 4255 | 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 | 4257 | else => return error.IndexOutOfBounds, |
| 4258 | 4258 | }; |
| 4259 | 4259 | } |
lib/std/array_hash_map.zig+4-4| ... | ... | @@ -2270,13 +2270,13 @@ test "reIndex" { |
| 2270 | 2270 | test "auto store_hash" { |
| 2271 | 2271 | const HasCheapEql = AutoArrayHashMap(i32, i32); |
| 2272 | 2272 | const HasExpensiveEql = AutoArrayHashMap([32]i32, i32); |
| 2273 | try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).field_type == void); | |
| 2274 | try testing.expect(meta.fieldInfo(HasExpensiveEql.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).type != void); | |
| 2275 | 2275 | |
| 2276 | 2276 | const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32); |
| 2277 | 2277 | const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32); |
| 2278 | try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).field_type == void); | |
| 2279 | try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.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).type != void); | |
| 2280 | 2280 | } |
| 2281 | 2281 | |
| 2282 | 2282 | test "sort" { |
lib/std/builtin.zig+2-3| ... | ... | @@ -280,8 +280,7 @@ pub const Type = union(enum) { |
| 280 | 280 | /// therefore must be kept in sync with the compiler implementation. |
| 281 | 281 | pub const StructField = struct { |
| 282 | 282 | name: []const u8, |
| 283 | /// TODO rename to `type` | |
| 284 | field_type: type, | |
| 283 | type: type, | |
| 285 | 284 | default_value: ?*const anyopaque, |
| 286 | 285 | is_comptime: bool, |
| 287 | 286 | alignment: comptime_int, |
| ... | ... | @@ -343,7 +342,7 @@ pub const Type = union(enum) { |
| 343 | 342 | /// therefore must be kept in sync with the compiler implementation. |
| 344 | 343 | pub const UnionField = struct { |
| 345 | 344 | name: []const u8, |
| 346 | field_type: type, | |
| 345 | type: type, | |
| 347 | 346 | alignment: comptime_int, |
| 348 | 347 | }; |
| 349 | 348 |
lib/std/crypto/phc_encoding.zig+4-4| ... | ... | @@ -110,9 +110,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 110 | 110 | var found = false; |
| 111 | 111 | inline for (comptime meta.fields(HashResult)) |p| { |
| 112 | 112 | if (mem.eql(u8, p.name, param.key)) { |
| 113 | switch (@typeInfo(p.field_type)) { | |
| 113 | switch (@typeInfo(p.type)) { | |
| 114 | 114 | .Int => @field(out, p.name) = fmt.parseUnsigned( |
| 115 | p.field_type, | |
| 115 | p.type, | |
| 116 | 116 | param.value, |
| 117 | 117 | 10, |
| 118 | 118 | ) catch return Error.InvalidEncoding, |
| ... | ... | @@ -161,7 +161,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult |
| 161 | 161 | // with default values |
| 162 | 162 | var expected_fields: usize = 0; |
| 163 | 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 | 165 | expected_fields += 1; |
| 166 | 166 | } |
| 167 | 167 | } |
| ... | ... | @@ -223,7 +223,7 @@ fn serializeTo(params: anytype, out: anytype) !void { |
| 223 | 223 | { |
| 224 | 224 | const value = @field(params, p.name); |
| 225 | 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 | 227 | var buf: [@TypeOf(value).max_encoded_length]u8 = undefined; |
| 228 | 228 | try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) }); |
| 229 | 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 | 15 | for (std.meta.fields(E)) |field| { |
| 16 | 16 | fields = fields ++ &[_]StructField{.{ |
| 17 | 17 | .name = field.name, |
| 18 | .field_type = Data, | |
| 18 | .type = Data, | |
| 19 | 19 | .default_value = if (field_default) |d| @ptrCast(?*const anyopaque, &d) else null, |
| 20 | 20 | .is_comptime = false, |
| 21 | 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 | 134 | hash(hasher, tag, strat); |
| 135 | 135 | inline for (info.fields) |field| { |
| 136 | 136 | if (@field(tag_type, field.name) == tag) { |
| 137 | if (field.field_type != void) { | |
| 137 | if (field.type != void) { | |
| 138 | 138 | hash(hasher, @field(key, field.name), strat); |
| 139 | 139 | } |
| 140 | 140 | // 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 | 163 | } |
| 164 | 164 | if (meta.trait.is(.Struct)(K)) { |
| 165 | 165 | inline for (@typeInfo(K).Struct.fields) |field| { |
| 166 | if (typeContainsSlice(field.field_type)) { | |
| 166 | if (typeContainsSlice(field.type)) { | |
| 167 | 167 | return true; |
| 168 | 168 | } |
| 169 | 169 | } |
| 170 | 170 | } |
| 171 | 171 | if (meta.trait.is(.Union)(K)) { |
| 172 | 172 | inline for (@typeInfo(K).Union.fields) |field| { |
| 173 | if (typeContainsSlice(field.field_type)) { | |
| 173 | if (typeContainsSlice(field.type)) { | |
| 174 | 174 | return true; |
| 175 | 175 | } |
| 176 | 176 | } |
lib/std/io/multi_writer.zig+1-1| ... | ... | @@ -6,7 +6,7 @@ const testing = std.testing; |
| 6 | 6 | pub fn MultiWriter(comptime Writers: type) type { |
| 7 | 7 | comptime var ErrSet = error{}; |
| 8 | 8 | inline for (@typeInfo(Writers).Struct.fields) |field| { |
| 9 | const StreamType = field.field_type; | |
| 9 | const StreamType = field.type; | |
| 10 | 10 | ErrSet = ErrSet || StreamType.Error; |
| 11 | 11 | } |
| 12 | 12 |
lib/std/json.zig+13-13| ... | ... | @@ -1362,7 +1362,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ |
| 1362 | 1362 | if (unionInfo.tag_type) |_| { |
| 1363 | 1363 | var errors = error{NoUnionMembersMatched}; |
| 1364 | 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 | 1367 | return errors; |
| 1368 | 1368 | } else { |
| ... | ... | @@ -1379,7 +1379,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ |
| 1379 | 1379 | MissingField, |
| 1380 | 1380 | } || SkipValueError || TokenStream.Error; |
| 1381 | 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 | 1384 | return errors; |
| 1385 | 1385 | }, |
| ... | ... | @@ -1491,7 +1491,7 @@ fn parseInternal( |
| 1491 | 1491 | inline for (unionInfo.fields) |u_field| { |
| 1492 | 1492 | // take a copy of tokens so we can withhold mutations until success |
| 1493 | 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 | 1495 | tokens.* = tokens_copy; |
| 1496 | 1496 | return @unionInit(T, u_field.name, value); |
| 1497 | 1497 | } else |err| { |
| ... | ... | @@ -1519,7 +1519,7 @@ fn parseInternal( |
| 1519 | 1519 | errdefer { |
| 1520 | 1520 | inline for (structInfo.fields) |field, i| { |
| 1521 | 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 | 1547 | // } |
| 1548 | 1548 | if (options.duplicate_field_behavior == .UseFirst) { |
| 1549 | 1549 | // 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 | 1551 | found = true; |
| 1552 | 1552 | break; |
| 1553 | 1553 | } else if (options.duplicate_field_behavior == .Error) { |
| 1554 | 1554 | return error.DuplicateJSONField; |
| 1555 | 1555 | } else if (options.duplicate_field_behavior == .UseLast) { |
| 1556 | 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 | 1559 | fields_seen[i] = false; |
| 1560 | 1560 | } |
| 1561 | 1561 | } |
| 1562 | 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 | 1564 | return error.UnexpectedValue; |
| 1565 | 1565 | } |
| 1566 | 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 | 1569 | fields_seen[i] = true; |
| 1570 | 1570 | found = true; |
| ... | ... | @@ -1587,7 +1587,7 @@ fn parseInternal( |
| 1587 | 1587 | if (!fields_seen[i]) { |
| 1588 | 1588 | if (field.default_value) |default_ptr| { |
| 1589 | 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 | 1591 | @field(r, field.name) = default; |
| 1592 | 1592 | } |
| 1593 | 1593 | } else { |
| ... | ... | @@ -1732,7 +1732,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { |
| 1732 | 1732 | if (unionInfo.tag_type) |UnionTagType| { |
| 1733 | 1733 | inline for (unionInfo.fields) |u_field| { |
| 1734 | 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 | 1736 | break; |
| 1737 | 1737 | } |
| 1738 | 1738 | } |
| ... | ... | @@ -1743,7 +1743,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { |
| 1743 | 1743 | .Struct => |structInfo| { |
| 1744 | 1744 | inline for (structInfo.fields) |field| { |
| 1745 | 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 | 2270 | } |
| 2271 | 2271 | inline for (S.fields) |Field| { |
| 2272 | 2272 | // don't include void fields |
| 2273 | if (Field.field_type == void) continue; | |
| 2273 | if (Field.type == void) continue; | |
| 2274 | 2274 | |
| 2275 | 2275 | var emit_field = true; |
| 2276 | 2276 | |
| 2277 | 2277 | // 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 | 2279 | if (options.emit_null_optional_fields == false) { |
| 2280 | 2280 | if (@field(value, Field.name) == null) { |
| 2281 | 2281 | emit_field = false; |
lib/std/mem.zig+4-4| ... | ... | @@ -300,7 +300,7 @@ pub fn zeroes(comptime T: type) T { |
| 300 | 300 | if (comptime meta.containerLayout(T) == .Extern) { |
| 301 | 301 | // The C language specification states that (global) unions |
| 302 | 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 | } |
| 305 | 305 | |
| 306 | 306 | @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); |
| ... | ... | @@ -435,7 +435,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 435 | 435 | |
| 436 | 436 | inline for (struct_info.fields) |field| { |
| 437 | 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 | 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 | 452 | @compileError("Encountered an initializer for `" ++ field.name ++ "`, but it is not a field of " ++ @typeName(T)); |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | switch (@typeInfo(field.field_type)) { | |
| 455 | switch (@typeInfo(field.type)) { | |
| 456 | 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 | 459 | else => { |
| 460 | 460 | @field(value, field.name) = @field(init, field.name); |
lib/std/meta.zig+8-8| ... | ... | @@ -522,8 +522,8 @@ test "std.meta.fields" { |
| 522 | 522 | try testing.expect(mem.eql(u8, e2f[0].name, "A")); |
| 523 | 523 | try testing.expect(mem.eql(u8, sf[0].name, "a")); |
| 524 | 524 | try testing.expect(mem.eql(u8, uf[0].name, "a")); |
| 525 | try testing.expect(comptime sf[0].field_type == u8); | |
| 526 | try testing.expect(comptime uf[0].field_type == u8); | |
| 525 | try testing.expect(comptime sf[0].type == u8); | |
| 526 | try testing.expect(comptime uf[0].type == u8); | |
| 527 | 527 | } |
| 528 | 528 | |
| 529 | 529 | pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { |
| ... | ... | @@ -557,8 +557,8 @@ test "std.meta.fieldInfo" { |
| 557 | 557 | try testing.expect(mem.eql(u8, e2f.name, "A")); |
| 558 | 558 | try testing.expect(mem.eql(u8, sf.name, "a")); |
| 559 | 559 | try testing.expect(mem.eql(u8, uf.name, "a")); |
| 560 | try testing.expect(comptime sf.field_type == u8); | |
| 561 | try testing.expect(comptime uf.field_type == u8); | |
| 560 | try testing.expect(comptime sf.type == u8); | |
| 561 | try testing.expect(comptime uf.type == u8); | |
| 562 | 562 | } |
| 563 | 563 | |
| 564 | 564 | pub 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 | 831 | |
| 832 | 832 | inline for (info.fields) |field_info| { |
| 833 | 833 | if (comptime mem.eql(u8, field_info.name, @tagName(tag))) |
| 834 | return field_info.field_type; | |
| 834 | return field_info.type; | |
| 835 | 835 | } |
| 836 | 836 | |
| 837 | 837 | unreachable; |
| ... | ... | @@ -1111,7 +1111,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { |
| 1111 | 1111 | var num_buf: [128]u8 = undefined; |
| 1112 | 1112 | tuple_fields[i] = .{ |
| 1113 | 1113 | .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable, |
| 1114 | .field_type = T, | |
| 1114 | .type = T, | |
| 1115 | 1115 | .default_value = null, |
| 1116 | 1116 | .is_comptime = false, |
| 1117 | 1117 | .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0, |
| ... | ... | @@ -1146,8 +1146,8 @@ const TupleTester = struct { |
| 1146 | 1146 | @compileError("Argument count mismatch"); |
| 1147 | 1147 | |
| 1148 | 1148 | inline for (fields_list) |fld, i| { |
| 1149 | if (expected[i] != fld.field_type) { | |
| 1150 | @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(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.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 | 24 | inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| { |
| 25 | 25 | fields[i] = Type.StructField{ |
| 26 | 26 | .name = struct_field.name, |
| 27 | .field_type = ?struct_field.field_type, | |
| 28 | .default_value = &@as(?struct_field.field_type, null), | |
| 27 | .type = ?struct_field.type, | |
| 28 | .default_value = &@as(?struct_field.type, null), | |
| 29 | 29 | .is_comptime = false, |
| 30 | .alignment = @alignOf(?struct_field.field_type), | |
| 30 | .alignment = @alignOf(?struct_field.type), | |
| 31 | 31 | }; |
| 32 | 32 | } |
| 33 | 33 | break :blk @Type(.{ |
| ... | ... | @@ -105,26 +105,26 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 105 | 105 | const active = (self.bits & (1 << i)) != 0; |
| 106 | 106 | if (i == @enumToInt(field)) { |
| 107 | 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 | 109 | } else if (active) { |
| 110 | off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type)); | |
| 111 | off += @sizeOf(field_info.field_type); | |
| 110 | off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.type)); | |
| 111 | off += @sizeOf(field_info.type); | |
| 112 | 112 | } |
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | 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 | } |
| 119 | 119 | |
| 120 | 120 | pub fn sizeInBytes(self: Self) usize { |
| 121 | 121 | var off: usize = 0; |
| 122 | 122 | inline for (@typeInfo(Fields).Struct.fields) |field, i| { |
| 123 | if (@sizeOf(field.field_type) == 0) | |
| 123 | if (@sizeOf(field.type) == 0) | |
| 124 | 124 | continue; |
| 125 | 125 | if ((self.bits & (1 << i)) != 0) { |
| 126 | off = mem.alignForwardGeneric(usize, off, @alignOf(field.field_type)); | |
| 127 | off += @sizeOf(field.field_type); | |
| 126 | off = mem.alignForwardGeneric(usize, off, @alignOf(field.type)); | |
| 127 | off += @sizeOf(field.type); | |
| 128 | 128 | } |
| 129 | 129 | } |
| 130 | 130 | return off; |
lib/std/meta/trait.zig+1-1| ... | ... | @@ -566,7 +566,7 @@ pub fn hasUniqueRepresentation(comptime T: type) bool { |
| 566 | 566 | var sum_size = @as(usize, 0); |
| 567 | 567 | |
| 568 | 568 | inline for (info.fields) |field| { |
| 569 | const FieldType = field.field_type; | |
| 569 | const FieldType = field.type; | |
| 570 | 570 | if (comptime !hasUniqueRepresentation(FieldType)) return false; |
| 571 | 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 | 84 | var data: [fields.len]Data = undefined; |
| 85 | 85 | for (fields) |field_info, i| { |
| 86 | 86 | data[i] = .{ |
| 87 | .size = @sizeOf(field_info.field_type), | |
| 87 | .size = @sizeOf(field_info.type), | |
| 88 | 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 | 92 | const Sort = struct { |
| ... | ... | @@ -294,10 +294,10 @@ pub fn MultiArrayList(comptime S: type) type { |
| 294 | 294 | ) catch { |
| 295 | 295 | const self_slice = self.slice(); |
| 296 | 296 | inline for (fields) |field_info, i| { |
| 297 | if (@sizeOf(field_info.field_type) != 0) { | |
| 297 | if (@sizeOf(field_info.type) != 0) { | |
| 298 | 298 | const field = @intToEnum(Field, i); |
| 299 | 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 | 301 | // We use memset here for more efficient codegen in safety-checked, |
| 302 | 302 | // valgrind-enabled builds. Otherwise the valgrind client request |
| 303 | 303 | // will be repeated for every element. |
| ... | ... | @@ -316,9 +316,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 316 | 316 | const self_slice = self.slice(); |
| 317 | 317 | const other_slice = other.slice(); |
| 318 | 318 | inline for (fields) |field_info, i| { |
| 319 | if (@sizeOf(field_info.field_type) != 0) { | |
| 319 | if (@sizeOf(field_info.type) != 0) { | |
| 320 | 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 | 324 | gpa.free(self.allocatedBytes()); |
| ... | ... | @@ -377,9 +377,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 377 | 377 | const self_slice = self.slice(); |
| 378 | 378 | const other_slice = other.slice(); |
| 379 | 379 | inline for (fields) |field_info, i| { |
| 380 | if (@sizeOf(field_info.field_type) != 0) { | |
| 380 | if (@sizeOf(field_info.type) != 0) { | |
| 381 | 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 | 385 | gpa.free(self.allocatedBytes()); |
| ... | ... | @@ -396,9 +396,9 @@ pub fn MultiArrayList(comptime S: type) type { |
| 396 | 396 | const self_slice = self.slice(); |
| 397 | 397 | const result_slice = result.slice(); |
| 398 | 398 | inline for (fields) |field_info, i| { |
| 399 | if (@sizeOf(field_info.field_type) != 0) { | |
| 399 | if (@sizeOf(field_info.type) != 0) { | |
| 400 | 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 | 404 | return result; |
| ... | ... | @@ -413,10 +413,10 @@ pub fn MultiArrayList(comptime S: type) type { |
| 413 | 413 | |
| 414 | 414 | pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { |
| 415 | 415 | inline for (fields) |field_info, i| { |
| 416 | if (@sizeOf(field_info.field_type) != 0) { | |
| 416 | if (@sizeOf(field_info.type) != 0) { | |
| 417 | 417 | const field = @intToEnum(Field, i); |
| 418 | 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 | 449 | } |
| 450 | 450 | |
| 451 | 451 | fn FieldType(comptime field: Field) type { |
| 452 | return meta.fieldInfo(S, field).field_type; | |
| 452 | return meta.fieldInfo(S, field).type; | |
| 453 | 453 | } |
| 454 | 454 | |
| 455 | 455 | /// 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 | 81 | // Got the associated union type for self.type, now |
| 82 | 82 | // we need to initialize it and its subtype |
| 83 | 83 | if (self.type == enum_value) { |
| 84 | var subtype = self.initSubtype(ufield.field_type); | |
| 84 | var subtype = self.initSubtype(ufield.type); | |
| 85 | 85 | |
| 86 | 86 | if (subtype) |sb| { |
| 87 | 87 | // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } } |
| ... | ... | @@ -103,7 +103,7 @@ pub const DevicePathProtocol = extern struct { |
| 103 | 103 | |
| 104 | 104 | if (self.subtype == tag_val) { |
| 105 | 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 | } |
| 109 | 109 |
lib/std/testing.zig+1-1| ... | ... | @@ -802,7 +802,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime |
| 802 | 802 | |
| 803 | 803 | const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn)); |
| 804 | 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 | 806 | @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument"); |
| 807 | 807 | } |
| 808 | 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 | 230 | |
| 231 | 231 | pub fn setName(self: *Self, name: []const u8) void { |
| 232 | 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 | } |
| 235 | 235 | |
| 236 | 236 | pub fn setBuffers(self: *Self, buffers: []const Buffer) void { |
| 237 | 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 | } |
| 240 | 240 | |
| 241 | 241 | pub fn setControl(self: *Self, control: []const u8) void { |
| ... | ... | @@ -243,12 +243,12 @@ pub const Socket = struct { |
| 243 | 243 | self.control = Buffer.from(control); |
| 244 | 244 | } else { |
| 245 | 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 | } |
| 249 | 249 | |
| 250 | 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 | } |
| 253 | 253 | |
| 254 | 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 | 125 | const fields = std.meta.fields(T); |
| 126 | 126 | var result: T = undefined; |
| 127 | 127 | inline for (fields) |field, i| { |
| 128 | comptime assert(field.field_type == Node.Index); | |
| 128 | comptime assert(field.type == Node.Index); | |
| 129 | 129 | @field(result, field.name) = tree.extra_data[index + i]; |
| 130 | 130 | } |
| 131 | 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 | 50 | }, |
| 51 | 51 | .Union => |info| { |
| 52 | 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 | 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 | 153 | try p.extra_data.ensureUnusedCapacity(p.gpa, fields.len); |
| 154 | 154 | const result = @intCast(u32, p.extra_data.items.len); |
| 155 | 155 | inline for (fields) |field| { |
| 156 | comptime assert(field.field_type == Node.Index); | |
| 156 | comptime assert(field.type == Node.Index); | |
| 157 | 157 | p.extra_data.appendAssumeCapacity(@field(extra, field.name)); |
| 158 | 158 | } |
| 159 | 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 | 1260 | var i: usize = index; |
| 1261 | 1261 | var result: T = undefined; |
| 1262 | 1262 | inline for (fields) |field| { |
| 1263 | @field(result, field.name) = switch (field.field_type) { | |
| 1263 | @field(result, field.name) = switch (field.type) { | |
| 1264 | 1264 | u32 => air.extra[i], |
| 1265 | 1265 | Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), |
| 1266 | 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 | 79 | const fields = std.meta.fields(@TypeOf(extra)); |
| 80 | 80 | var i = index; |
| 81 | 81 | inline for (fields) |field| { |
| 82 | astgen.extra.items[i] = switch (field.field_type) { | |
| 82 | astgen.extra.items[i] = switch (field.type) { | |
| 83 | 83 | u32 => @field(extra, field.name), |
| 84 | 84 | Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), |
| 85 | 85 | i32 => @bitCast(u32, @field(extra, field.name)), |
src/Autodoc.zig+2-2| ... | ... | @@ -637,9 +637,9 @@ const DocData = struct { |
| 637 | 637 | inline for (comptime std.meta.fields(Type)) |case| { |
| 638 | 638 | if (@field(Type, case.name) == active_tag) { |
| 639 | 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 | 641 | try jsw.arrayElem(); |
| 642 | if (f.field_type == std.builtin.Type.Pointer.Size) { | |
| 642 | if (f.type == std.builtin.Type.Pointer.Size) { | |
| 643 | 643 | try jsw.emitNumber(@enumToInt(@field(current_value, f.name))); |
| 644 | 644 | } else { |
| 645 | 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 | 259 | const fields = std.meta.fields(@TypeOf(extra)); |
| 260 | 260 | const result = @intCast(u32, ip.extra.items.len); |
| 261 | 261 | inline for (fields) |field| { |
| 262 | ip.extra.appendAssumeCapacity(switch (field.field_type) { | |
| 262 | ip.extra.appendAssumeCapacity(switch (field.type) { | |
| 263 | 263 | u32 => @field(extra, field.name), |
| 264 | 264 | Index => @enumToInt(@field(extra, field.name)), |
| 265 | 265 | i32 => @bitCast(u32, @field(extra, field.name)), |
| ... | ... | @@ -274,7 +274,7 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T { |
| 274 | 274 | var i: usize = index; |
| 275 | 275 | var result: T = undefined; |
| 276 | 276 | inline for (fields) |field| { |
| 277 | @field(result, field.name) = switch (field.field_type) { | |
| 277 | @field(result, field.name) = switch (field.type) { | |
| 278 | 278 | u32 => ip.extra.items[i], |
| 279 | 279 | Index => @intToEnum(Index, ip.extra.items[i]), |
| 280 | 280 | i32 => @bitCast(i32, ip.extra.items[i]), |
src/Liveness.zig+1-1| ... | ... | @@ -718,7 +718,7 @@ const Analysis = struct { |
| 718 | 718 | const fields = std.meta.fields(@TypeOf(extra)); |
| 719 | 719 | const result = @intCast(u32, a.extra.items.len); |
| 720 | 720 | inline for (fields) |field| { |
| 721 | a.extra.appendAssumeCapacity(switch (field.field_type) { | |
| 721 | a.extra.appendAssumeCapacity(switch (field.type) { | |
| 722 | 722 | u32 => @field(extra, field.name), |
| 723 | 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 | 15767 | union_field_fields.* = .{ |
| 15768 | 15768 | // name: []const u8, |
| 15769 | 15769 | name_val, |
| 15770 | // field_type: type, | |
| 15770 | // type: type, | |
| 15771 | 15771 | try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), |
| 15772 | 15772 | // alignment: comptime_int, |
| 15773 | 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 | 15880 | struct_field_fields.* = .{ |
| 15881 | 15881 | // name: []const u8, |
| 15882 | 15882 | name_val, |
| 15883 | // field_type: type, | |
| 15883 | // type: type, | |
| 15884 | 15884 | try Value.Tag.ty.create(fields_anon_decl.arena(), field_ty), |
| 15885 | 15885 | // default_value: ?*const anyopaque, |
| 15886 | 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 | 15925 | struct_field_fields.* = .{ |
| 15926 | 15926 | // name: []const u8, |
| 15927 | 15927 | name_val, |
| 15928 | // field_type: type, | |
| 15928 | // type: type, | |
| 15929 | 15929 | try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), |
| 15930 | 15930 | // default_value: ?*const anyopaque, |
| 15931 | 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 | 18574 | // TODO use reflection instead of magic numbers here |
| 18575 | 18575 | // name: []const u8 |
| 18576 | 18576 | const name_val = field_struct_val[0]; |
| 18577 | // field_type: type, | |
| 18578 | const field_type_val = field_struct_val[1]; | |
| 18577 | // type: type, | |
| 18578 | const type_val = field_struct_val[1]; | |
| 18579 | 18579 | // alignment: comptime_int, |
| 18580 | 18580 | const alignment_val = field_struct_val[2]; |
| 18581 | 18581 | |
| ... | ... | @@ -18609,7 +18609,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in |
| 18609 | 18609 | } |
| 18610 | 18610 | |
| 18611 | 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 | 18613 | gop.value_ptr.* = .{ |
| 18614 | 18614 | .ty = field_ty, |
| 18615 | 18615 | .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema)).?), |
| ... | ... | @@ -18828,9 +18828,9 @@ fn reifyStruct( |
| 18828 | 18828 | // TODO use reflection instead of magic numbers here |
| 18829 | 18829 | // name: []const u8 |
| 18830 | 18830 | const name_val = field_struct_val[0]; |
| 18831 | // field_type: type, | |
| 18832 | const field_type_val = field_struct_val[1]; | |
| 18833 | //default_value: ?*const anyopaque, | |
| 18831 | // type: type, | |
| 18832 | const type_val = field_struct_val[1]; | |
| 18833 | // default_value: ?*const anyopaque, | |
| 18834 | 18834 | const default_value_val = field_struct_val[2]; |
| 18835 | 18835 | // is_comptime: bool, |
| 18836 | 18836 | const is_comptime_val = field_struct_val[3]; |
| ... | ... | @@ -18893,7 +18893,7 @@ fn reifyStruct( |
| 18893 | 18893 | } |
| 18894 | 18894 | |
| 18895 | 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 | 18897 | gop.value_ptr.* = .{ |
| 18898 | 18898 | .ty = field_ty, |
| 18899 | 18899 | .abi_align = abi_align, |
| ... | ... | @@ -31439,7 +31439,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { |
| 31439 | 31439 | const fields = std.meta.fields(@TypeOf(extra)); |
| 31440 | 31440 | const result = @intCast(u32, sema.air_extra.items.len); |
| 31441 | 31441 | inline for (fields) |field| { |
| 31442 | sema.air_extra.appendAssumeCapacity(switch (field.field_type) { | |
| 31442 | sema.air_extra.appendAssumeCapacity(switch (field.type) { | |
| 31443 | 31443 | u32 => @field(extra, field.name), |
| 31444 | 31444 | Air.Inst.Ref => @enumToInt(@field(extra, field.name)), |
| 31445 | 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 | 71 | var i: usize = index; |
| 72 | 72 | var result: T = undefined; |
| 73 | 73 | inline for (fields) |field| { |
| 74 | @field(result, field.name) = switch (field.field_type) { | |
| 74 | @field(result, field.name) = switch (field.type) { | |
| 75 | 75 | u32 => code.extra[i], |
| 76 | 76 | Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]), |
| 77 | 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 | 477 | const fields = std.meta.fields(@TypeOf(extra)); |
| 478 | 478 | const result = @intCast(u32, self.mir_extra.items.len); |
| 479 | 479 | inline for (fields) |field| { |
| 480 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | |
| 480 | self.mir_extra.appendAssumeCapacity(switch (field.type) { | |
| 481 | 481 | u32 => @field(extra, field.name), |
| 482 | 482 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 483 | 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 | 505 | var i: usize = index; |
| 506 | 506 | var result: T = undefined; |
| 507 | 507 | inline for (fields) |field| { |
| 508 | @field(result, field.name) = switch (field.field_type) { | |
| 508 | @field(result, field.name) = switch (field.type) { | |
| 509 | 509 | u32 => mir.extra[i], |
| 510 | 510 | i32 => @bitCast(i32, mir.extra[i]), |
| 511 | 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 | 386 | const fields = std.meta.fields(@TypeOf(extra)); |
| 387 | 387 | const result = @intCast(u32, self.mir_extra.items.len); |
| 388 | 388 | inline for (fields) |field| { |
| 389 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | |
| 389 | self.mir_extra.appendAssumeCapacity(switch (field.type) { | |
| 390 | 390 | u32 => @field(extra, field.name), |
| 391 | 391 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 392 | 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 | 283 | var i: usize = index; |
| 284 | 284 | var result: T = undefined; |
| 285 | 285 | inline for (fields) |field| { |
| 286 | @field(result, field.name) = switch (field.field_type) { | |
| 286 | @field(result, field.name) = switch (field.type) { | |
| 287 | 287 | u32 => mir.extra[i], |
| 288 | 288 | i32 => @bitCast(i32, mir.extra[i]), |
| 289 | 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 | 340 | const fields = std.meta.fields(@TypeOf(extra)); |
| 341 | 341 | const result = @intCast(u32, self.mir_extra.items.len); |
| 342 | 342 | inline for (fields) |field| { |
| 343 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | |
| 343 | self.mir_extra.appendAssumeCapacity(switch (field.type) { | |
| 344 | 344 | u32 => @field(extra, field.name), |
| 345 | 345 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 346 | 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 | 132 | var i: usize = index; |
| 133 | 133 | var result: T = undefined; |
| 134 | 134 | inline for (fields) |field| { |
| 135 | @field(result, field.name) = switch (field.field_type) { | |
| 135 | @field(result, field.name) = switch (field.type) { | |
| 136 | 136 | u32 => mir.extra[i], |
| 137 | 137 | i32 => @bitCast(i32, mir.extra[i]), |
| 138 | 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 | 347 | var i: usize = index; |
| 348 | 348 | var result: T = undefined; |
| 349 | 349 | inline for (fields) |field| { |
| 350 | @field(result, field.name) = switch (field.field_type) { | |
| 350 | @field(result, field.name) = switch (field.type) { | |
| 351 | 351 | u32 => mir.extra[i], |
| 352 | 352 | i32 => @bitCast(i32, mir.extra[i]), |
| 353 | 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 | 960 | const fields = std.meta.fields(@TypeOf(extra)); |
| 961 | 961 | const result = @intCast(u32, func.mir_extra.items.len); |
| 962 | 962 | inline for (fields) |field| { |
| 963 | func.mir_extra.appendAssumeCapacity(switch (field.field_type) { | |
| 963 | func.mir_extra.appendAssumeCapacity(switch (field.type) { | |
| 964 | 964 | u32 => @field(extra, field.name), |
| 965 | 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 | 589 | var i: usize = index; |
| 590 | 590 | var result: T = undefined; |
| 591 | 591 | inline for (fields) |field| { |
| 592 | @field(result, field.name) = switch (field.field_type) { | |
| 592 | @field(result, field.name) = switch (field.type) { | |
| 593 | 593 | u32 => self.extra[i], |
| 594 | 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 | 374 | const fields = std.meta.fields(@TypeOf(extra)); |
| 375 | 375 | const result = @intCast(u32, self.mir_extra.items.len); |
| 376 | 376 | inline for (fields) |field| { |
| 377 | self.mir_extra.appendAssumeCapacity(switch (field.field_type) { | |
| 377 | self.mir_extra.appendAssumeCapacity(switch (field.type) { | |
| 378 | 378 | u32 => @field(extra, field.name), |
| 379 | 379 | i32 => @bitCast(u32, @field(extra, field.name)), |
| 380 | 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 | 612 | var i: usize = index; |
| 613 | 613 | var result: T = undefined; |
| 614 | 614 | inline for (fields) |field| { |
| 615 | @field(result, field.name) = switch (field.field_type) { | |
| 615 | @field(result, field.name) = switch (field.type) { | |
| 616 | 616 | u32 => mir.extra[i], |
| 617 | 617 | i32 => @bitCast(i32, mir.extra[i]), |
| 618 | 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 | 116 | }; |
| 117 | 117 | |
| 118 | 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 | } |
| 122 | 122 | |
| ... | ... | @@ -196,7 +196,7 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe |
| 196 | 196 | fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void { |
| 197 | 197 | var mask: Word = 0; |
| 198 | 198 | inline for (@typeInfo(Operand).Struct.fields) |field, bit| { |
| 199 | switch (@typeInfo(field.field_type)) { | |
| 199 | switch (@typeInfo(field.type)) { | |
| 200 | 200 | .Optional => if (@field(operand, field.name) != null) { |
| 201 | 201 | mask |= 1 << @intCast(u5, bit); |
| 202 | 202 | }, |
| ... | ... | @@ -214,7 +214,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand |
| 214 | 214 | section.writeWord(mask); |
| 215 | 215 | |
| 216 | 216 | inline for (@typeInfo(Operand).Struct.fields) |field| { |
| 217 | switch (@typeInfo(field.field_type)) { | |
| 217 | switch (@typeInfo(field.type)) { | |
| 218 | 218 | .Optional => |info| if (@field(operand, field.name)) |child| { |
| 219 | 219 | section.writeOperands(info.child, child); |
| 220 | 220 | }, |
| ... | ... | @@ -230,7 +230,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan |
| 230 | 230 | |
| 231 | 231 | inline for (@typeInfo(Operand).Union.fields) |field| { |
| 232 | 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 | 234 | return; |
| 235 | 235 | } |
| 236 | 236 | } |
| ... | ... | @@ -250,7 +250,7 @@ fn operandsSize(comptime Operands: type, operands: Operands) usize { |
| 250 | 250 | |
| 251 | 251 | var total: usize = 0; |
| 252 | 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 | } |
| 255 | 255 | |
| 256 | 256 | return total; |
| ... | ... | @@ -304,7 +304,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { |
| 304 | 304 | var total: usize = 0; |
| 305 | 305 | var any_set = false; |
| 306 | 306 | inline for (@typeInfo(Operand).Struct.fields) |field| { |
| 307 | switch (@typeInfo(field.field_type)) { | |
| 307 | switch (@typeInfo(field.type)) { | |
| 308 | 308 | .Optional => |info| if (@field(operand, field.name)) |child| { |
| 309 | 309 | total += operandsSize(info.child, child); |
| 310 | 310 | any_set = true; |
| ... | ... | @@ -326,7 +326,7 @@ fn extendedUnionSize(comptime Operand: type, operand: Operand) usize { |
| 326 | 326 | inline for (@typeInfo(Operand).Union.fields) |field| { |
| 327 | 327 | if (@field(Operand, field.name) == tag) { |
| 328 | 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 | 332 | unreachable; |
src/link/tapi/yaml.zig+5-5| ... | ... | @@ -339,7 +339,7 @@ pub const Yaml = struct { |
| 339 | 339 | |
| 340 | 340 | if (union_info.tag_type) |_| { |
| 341 | 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 | 343 | return @unionInit(T, field.name, u_value); |
| 344 | 344 | } else |err| { |
| 345 | 345 | if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err; |
| ... | ... | @@ -366,16 +366,16 @@ pub const Yaml = struct { |
| 366 | 366 | break :blk map.get(field_name); |
| 367 | 367 | }; |
| 368 | 368 | |
| 369 | if (@typeInfo(field.field_type) == .Optional) { | |
| 370 | @field(parsed, field.name) = try self.parseOptional(field.field_type, value); | |
| 369 | if (@typeInfo(field.type) == .Optional) { | |
| 370 | @field(parsed, field.name) = try self.parseOptional(field.type, value); | |
| 371 | 371 | continue; |
| 372 | 372 | } |
| 373 | 373 | |
| 374 | 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 | 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 | } |
| 380 | 380 | |
| 381 | 381 | return parsed; |
src/print_zir.zig+4-4| ... | ... | @@ -1312,7 +1312,7 @@ const Writer = struct { |
| 1312 | 1312 | type_len: u32 = 0, |
| 1313 | 1313 | align_len: u32 = 0, |
| 1314 | 1314 | init_len: u32 = 0, |
| 1315 | field_type: Zir.Inst.Ref = .none, | |
| 1315 | type: Zir.Inst.Ref = .none, | |
| 1316 | 1316 | name: u32, |
| 1317 | 1317 | is_comptime: bool, |
| 1318 | 1318 | }; |
| ... | ... | @@ -1353,7 +1353,7 @@ const Writer = struct { |
| 1353 | 1353 | if (has_type_body) { |
| 1354 | 1354 | fields[field_i].type_len = self.code.extra[extra_index]; |
| 1355 | 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 | 1358 | extra_index += 1; |
| 1359 | 1359 | |
| ... | ... | @@ -1384,8 +1384,8 @@ const Writer = struct { |
| 1384 | 1384 | } else { |
| 1385 | 1385 | try stream.print("@\"{d}\": ", .{i}); |
| 1386 | 1386 | } |
| 1387 | if (field.field_type != .none) { | |
| 1388 | try self.writeInstRef(stream, field.field_type); | |
| 1387 | if (field.type != .none) { | |
| 1388 | try self.writeInstRef(stream, field.type); | |
| 1389 | 1389 | } |
| 1390 | 1390 | |
| 1391 | 1391 | if (field.type_len > 0) { |
src/translate_c/ast.zig+2-2| ... | ... | @@ -392,7 +392,7 @@ pub const Node = extern union { |
| 392 | 392 | } |
| 393 | 393 | |
| 394 | 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 | }; |
| 398 | 398 | |
| ... | ... | @@ -845,7 +845,7 @@ const Context = struct { |
| 845 | 845 | try c.extra_data.ensureUnusedCapacity(c.gpa, fields.len); |
| 846 | 846 | const result = @intCast(u32, c.extra_data.items.len); |
| 847 | 847 | inline for (fields) |field| { |
| 848 | comptime std.debug.assert(field.field_type == NodeIndex); | |
| 848 | comptime std.debug.assert(field.type == NodeIndex); | |
| 849 | 849 | c.extra_data.appendAssumeCapacity(@field(extra, field.name)); |
| 850 | 850 | } |
| 851 | 851 | return result; |
src/type.zig+1-1| ... | ... | @@ -6216,7 +6216,7 @@ pub const Type = extern union { |
| 6216 | 6216 | } |
| 6217 | 6217 | |
| 6218 | 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 | }; |
| 6222 | 6222 |
src/value.zig+1-1| ... | ... | @@ -338,7 +338,7 @@ pub const Value = extern union { |
| 338 | 338 | } |
| 339 | 339 | |
| 340 | 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 | }; |
| 344 | 344 |
test/behavior/bitcast.zig+1-1| ... | ... | @@ -358,7 +358,7 @@ test "comptime @bitCast packed struct to int and back" { |
| 358 | 358 | const rt_cast = @bitCast(S, i); |
| 359 | 359 | const ct_cast = comptime @bitCast(S, @as(Int, 0)); |
| 360 | 360 | inline for (@typeInfo(S).Struct.fields) |field| { |
| 361 | if (@typeInfo(field.field_type) == .Vector) | |
| 361 | if (@typeInfo(field.type) == .Vector) | |
| 362 | 362 | continue; //TODO: https://github.com/ziglang/zig/issues/13201 |
| 363 | 363 | |
| 364 | 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 | 8 | .fields = &.{ |
| 9 | 9 | .{ |
| 10 | 10 | .name = "globals", |
| 11 | .field_type = modules.mach.globals, | |
| 11 | .type = modules.mach.globals, | |
| 12 | 12 | .default_value = null, |
| 13 | 13 | .is_comptime = false, |
| 14 | 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 | .is_tuple = false, |
| 8 | 8 | .fields = &.{.{ |
| 9 | 9 | .name = "components", |
| 10 | .field_type = @TypeOf(modules.components), | |
| 10 | .type = @TypeOf(modules.components), | |
| 11 | 11 | .default_value = null, |
| 12 | 12 | .is_comptime = false, |
| 13 | 13 | .alignment = @alignOf(@TypeOf(modules.components)), |
test/behavior/bugs/13435.zig+1-1| ... | ... | @@ -8,7 +8,7 @@ fn CreateUnion(comptime T: type) type { |
| 8 | 8 | .fields = &[_]std.builtin.Type.UnionField{ |
| 9 | 9 | .{ |
| 10 | 10 | .name = "field", |
| 11 | .field_type = T, | |
| 11 | .type = T, | |
| 12 | 12 | .alignment = @alignOf(T), |
| 13 | 13 | }, |
| 14 | 14 | }, |
test/behavior/bugs/6456.zig+1-1| ... | ... | @@ -23,7 +23,7 @@ test "issue 6456" { |
| 23 | 23 | fields = fields ++ &[_]StructField{StructField{ |
| 24 | 24 | .alignment = 0, |
| 25 | 25 | .name = name, |
| 26 | .field_type = usize, | |
| 26 | .type = usize, | |
| 27 | 27 | .default_value = &@as(?usize, null), |
| 28 | 28 | .is_comptime = false, |
| 29 | 29 | }}; |
test/behavior/tuple.zig+3-3| ... | ... | @@ -136,14 +136,14 @@ test "array-like initializer for tuple types" { |
| 136 | 136 | .fields = &.{ |
| 137 | 137 | .{ |
| 138 | 138 | .name = "0", |
| 139 | .field_type = i32, | |
| 139 | .type = i32, | |
| 140 | 140 | .default_value = null, |
| 141 | 141 | .is_comptime = false, |
| 142 | 142 | .alignment = @alignOf(i32), |
| 143 | 143 | }, |
| 144 | 144 | .{ |
| 145 | 145 | .name = "1", |
| 146 | .field_type = u8, | |
| 146 | .type = u8, | |
| 147 | 147 | .default_value = null, |
| 148 | 148 | .is_comptime = false, |
| 149 | 149 | .alignment = @alignOf(i32), |
| ... | ... | @@ -314,7 +314,7 @@ test "zero sized struct in tuple handled correctly" { |
| 314 | 314 | .decls = &.{}, |
| 315 | 315 | .fields = &.{.{ |
| 316 | 316 | .name = "0", |
| 317 | .field_type = struct {}, | |
| 317 | .type = struct {}, | |
| 318 | 318 | .default_value = null, |
| 319 | 319 | .is_comptime = false, |
| 320 | 320 | .alignment = 0, |
test/behavior/tuple_declarations.zig+5-5| ... | ... | @@ -20,13 +20,13 @@ test "tuple declaration type info" { |
| 20 | 20 | try expect(info.is_tuple); |
| 21 | 21 | |
| 22 | 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 | 24 | try expect(@ptrCast(*const u32, @alignCast(@alignOf(u32), info.fields[0].default_value)).* == 1); |
| 25 | 25 | try expect(info.fields[0].is_comptime); |
| 26 | 26 | try expect(info.fields[0].alignment == 2); |
| 27 | 27 | |
| 28 | 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 | 30 | try expect(info.fields[1].default_value == null); |
| 31 | 31 | try expect(!info.fields[1].is_comptime); |
| 32 | 32 | try expect(info.fields[1].alignment == @alignOf([]const u8)); |
| ... | ... | @@ -44,13 +44,13 @@ test "tuple declaration type info" { |
| 44 | 44 | try expect(info.is_tuple); |
| 45 | 45 | |
| 46 | 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); | |
| 48 | 48 | |
| 49 | 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); | |
| 51 | 51 | |
| 52 | 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 | } |
| 56 | 56 |
test/behavior/type.zig+19-19| ... | ... | @@ -268,10 +268,10 @@ test "Type.Struct" { |
| 268 | 268 | const infoA = @typeInfo(A).Struct; |
| 269 | 269 | try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); |
| 270 | 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 | 272 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); |
| 273 | 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 | 275 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value); |
| 276 | 276 | try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls); |
| 277 | 277 | try testing.expectEqual(@as(bool, false), infoA.is_tuple); |
| ... | ... | @@ -286,10 +286,10 @@ test "Type.Struct" { |
| 286 | 286 | const infoB = @typeInfo(B).Struct; |
| 287 | 287 | try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); |
| 288 | 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 | 290 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); |
| 291 | 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 | 293 | try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoB.fields[1].default_value.?).*); |
| 294 | 294 | try testing.expectEqual(@as(usize, 0), infoB.decls.len); |
| 295 | 295 | try testing.expectEqual(@as(bool, false), infoB.is_tuple); |
| ... | ... | @@ -298,10 +298,10 @@ test "Type.Struct" { |
| 298 | 298 | const infoC = @typeInfo(C).Struct; |
| 299 | 299 | try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); |
| 300 | 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 | 302 | try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*); |
| 303 | 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 | 305 | try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoC.fields[1].default_value.?).*); |
| 306 | 306 | try testing.expectEqual(@as(usize, 0), infoC.decls.len); |
| 307 | 307 | try testing.expectEqual(@as(bool, false), infoC.is_tuple); |
| ... | ... | @@ -311,10 +311,10 @@ test "Type.Struct" { |
| 311 | 311 | const infoD = @typeInfo(D).Struct; |
| 312 | 312 | try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); |
| 313 | 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 | 315 | try testing.expectEqual(@as(comptime_int, 3), @ptrCast(*const comptime_int, infoD.fields[0].default_value.?).*); |
| 316 | 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 | 318 | try testing.expectEqual(@as(comptime_int, 5), @ptrCast(*const comptime_int, infoD.fields[1].default_value.?).*); |
| 319 | 319 | try testing.expectEqual(@as(usize, 0), infoD.decls.len); |
| 320 | 320 | try testing.expectEqual(@as(bool, false), infoD.is_tuple); |
| ... | ... | @@ -324,10 +324,10 @@ test "Type.Struct" { |
| 324 | 324 | const infoE = @typeInfo(E).Struct; |
| 325 | 325 | try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); |
| 326 | 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 | 328 | try testing.expectEqual(@as(comptime_int, 1), @ptrCast(*const comptime_int, infoE.fields[0].default_value.?).*); |
| 329 | 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 | 331 | try testing.expectEqual(@as(comptime_int, 2), @ptrCast(*const comptime_int, infoE.fields[1].default_value.?).*); |
| 332 | 332 | try testing.expectEqual(@as(usize, 0), infoE.decls.len); |
| 333 | 333 | try testing.expectEqual(@as(bool, true), infoE.is_tuple); |
| ... | ... | @@ -396,8 +396,8 @@ test "Type.Union" { |
| 396 | 396 | .layout = .Extern, |
| 397 | 397 | .tag_type = null, |
| 398 | 398 | .fields = &.{ |
| 399 | .{ .name = "int", .field_type = i32, .alignment = @alignOf(f32) }, | |
| 400 | .{ .name = "float", .field_type = f32, .alignment = @alignOf(f32) }, | |
| 399 | .{ .name = "int", .type = i32, .alignment = @alignOf(f32) }, | |
| 400 | .{ .name = "float", .type = f32, .alignment = @alignOf(f32) }, | |
| 401 | 401 | }, |
| 402 | 402 | .decls = &.{}, |
| 403 | 403 | }, |
| ... | ... | @@ -412,8 +412,8 @@ test "Type.Union" { |
| 412 | 412 | .layout = .Packed, |
| 413 | 413 | .tag_type = null, |
| 414 | 414 | .fields = &.{ |
| 415 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | |
| 416 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | |
| 415 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, | |
| 416 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, | |
| 417 | 417 | }, |
| 418 | 418 | .decls = &.{}, |
| 419 | 419 | }, |
| ... | ... | @@ -439,8 +439,8 @@ test "Type.Union" { |
| 439 | 439 | .layout = .Auto, |
| 440 | 440 | .tag_type = Tag, |
| 441 | 441 | .fields = &.{ |
| 442 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | |
| 443 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | |
| 442 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, | |
| 443 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, | |
| 444 | 444 | }, |
| 445 | 445 | .decls = &.{}, |
| 446 | 446 | }, |
| ... | ... | @@ -470,7 +470,7 @@ test "Type.Union from Type.Enum" { |
| 470 | 470 | .layout = .Auto, |
| 471 | 471 | .tag_type = Tag, |
| 472 | 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 | 475 | .decls = &.{}, |
| 476 | 476 | }, |
| ... | ... | @@ -487,7 +487,7 @@ test "Type.Union from regular enum" { |
| 487 | 487 | .layout = .Auto, |
| 488 | 488 | .tag_type = E, |
| 489 | 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 | 492 | .decls = &.{}, |
| 493 | 493 | }, |
| ... | ... | @@ -537,7 +537,7 @@ test "reified struct field name from optional payload" { |
| 537 | 537 | .layout = .Auto, |
| 538 | 538 | .fields = &.{.{ |
| 539 | 539 | .name = name, |
| 540 | .field_type = u8, | |
| 540 | .type = u8, | |
| 541 | 541 | .default_value = null, |
| 542 | 542 | .is_comptime = false, |
| 543 | 543 | .alignment = 1, |
test/behavior/type_info.zig+4-4| ... | ... | @@ -257,7 +257,7 @@ fn testUnion() !void { |
| 257 | 257 | try expect(typeinfo_info.Union.layout == .Auto); |
| 258 | 258 | try expect(typeinfo_info.Union.tag_type.? == TypeId); |
| 259 | 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 | 261 | try expect(typeinfo_info.Union.decls.len == 22); |
| 262 | 262 | |
| 263 | 263 | const TestNoTagUnion = union { |
| ... | ... | @@ -271,7 +271,7 @@ fn testUnion() !void { |
| 271 | 271 | try expect(notag_union_info.Union.layout == .Auto); |
| 272 | 272 | try expect(notag_union_info.Union.fields.len == 2); |
| 273 | 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 | 275 | try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32)); |
| 276 | 276 | |
| 277 | 277 | const TestExternUnion = extern union { |
| ... | ... | @@ -281,7 +281,7 @@ fn testUnion() !void { |
| 281 | 281 | const extern_union_info = @typeInfo(TestExternUnion); |
| 282 | 282 | try expect(extern_union_info.Union.layout == .Extern); |
| 283 | 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 | } |
| 286 | 286 | |
| 287 | 287 | test "type info: struct info" { |
| ... | ... | @@ -319,7 +319,7 @@ fn testPackedStruct() !void { |
| 319 | 319 | try expect(struct_info.Struct.backing_integer == u128); |
| 320 | 320 | try expect(struct_info.Struct.fields.len == 4); |
| 321 | 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 | 323 | try expect(struct_info.Struct.fields[2].default_value == null); |
| 324 | 324 | try expect(@ptrCast(*align(1) const u32, struct_info.Struct.fields[3].default_value.?).* == 4); |
| 325 | 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 | 454 | if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO |
| 455 | 455 | |
| 456 | 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 | 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 | 9 | const info = @typeInfo(Widget).Union; |
| 10 | 10 | inline for (info.fields) |field| { |
| 11 | 11 | if (foo()) { |
| 12 | switch (field.field_type) { | |
| 12 | switch (field.type) { | |
| 13 | 13 | u0 => a = 2, |
| 14 | 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 | 16 | .Struct => |structInfo| { |
| 17 | 17 | inline for (structInfo.fields) |field| { |
| 18 | 18 | if (!field.is_comptime) |
| 19 | parseFree(field.field_type, undefined, allocator); | |
| 19 | parseFree(field.type, undefined, allocator); | |
| 20 | 20 | } |
| 21 | 21 | }, |
| 22 | 22 | .Pointer => |ptrInfo| { |
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | 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 | 4 | }, .decls = &.{}, .is_tuple = false } }); |
| 5 | 5 | } |
| 6 | 6 |
test/cases/compile_errors/reify_struct.zig+5-5| ... | ... | @@ -3,7 +3,7 @@ comptime { |
| 3 | 3 | .layout = .Auto, |
| 4 | 4 | .fields = &.{.{ |
| 5 | 5 | .name = "foo", |
| 6 | .field_type = u32, | |
| 6 | .type = u32, | |
| 7 | 7 | .default_value = null, |
| 8 | 8 | .is_comptime = false, |
| 9 | 9 | .alignment = 4, |
| ... | ... | @@ -17,7 +17,7 @@ comptime { |
| 17 | 17 | .layout = .Auto, |
| 18 | 18 | .fields = &.{.{ |
| 19 | 19 | .name = "3", |
| 20 | .field_type = u32, | |
| 20 | .type = u32, | |
| 21 | 21 | .default_value = null, |
| 22 | 22 | .is_comptime = false, |
| 23 | 23 | .alignment = 4, |
| ... | ... | @@ -31,7 +31,7 @@ comptime { |
| 31 | 31 | .layout = .Auto, |
| 32 | 32 | .fields = &.{.{ |
| 33 | 33 | .name = "0", |
| 34 | .field_type = u32, | |
| 34 | .type = u32, | |
| 35 | 35 | .default_value = null, |
| 36 | 36 | .is_comptime = true, |
| 37 | 37 | .alignment = 4, |
| ... | ... | @@ -45,7 +45,7 @@ comptime { |
| 45 | 45 | .layout = .Extern, |
| 46 | 46 | .fields = &.{.{ |
| 47 | 47 | .name = "0", |
| 48 | .field_type = u32, | |
| 48 | .type = u32, | |
| 49 | 49 | .default_value = null, |
| 50 | 50 | .is_comptime = true, |
| 51 | 51 | .alignment = 4, |
| ... | ... | @@ -59,7 +59,7 @@ comptime { |
| 59 | 59 | .layout = .Packed, |
| 60 | 60 | .fields = &.{.{ |
| 61 | 61 | .name = "0", |
| 62 | .field_type = u32, | |
| 62 | .type = u32, | |
| 63 | 63 | .default_value = null, |
| 64 | 64 | .is_comptime = true, |
| 65 | 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 | 16 | .layout = .Auto, |
| 17 | 17 | .tag_type = Tag, |
| 18 | 18 | .fields = &.{ |
| 19 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | |
| 20 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | |
| 19 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, | |
| 20 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, | |
| 21 | 21 | }, |
| 22 | 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 | 15 | .layout = .Auto, |
| 16 | 16 | .tag_type = Tag, |
| 17 | 17 | .fields = &.{ |
| 18 | .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, | |
| 19 | .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, | |
| 20 | .{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) }, | |
| 18 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, | |
| 19 | .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, | |
| 20 | .{ .name = "arst", .type = f32, .alignment = @alignOf(f32) }, | |
| 21 | 21 | }, |
| 22 | 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 | 3 | .layout = .Auto, |
| 4 | 4 | .tag_type = null, |
| 5 | 5 | .fields = &.{ |
| 6 | .{ .name = "foo", .field_type = opaque {}, .alignment = 1 }, | |
| 6 | .{ .name = "foo", .type = opaque {}, .alignment = 1 }, | |
| 7 | 7 | }, |
| 8 | 8 | .decls = &.{}, |
| 9 | 9 | }, |
| ... | ... | @@ -17,4 +17,4 @@ export fn entry() usize { |
| 17 | 17 | // target=native |
| 18 | 18 | // |
| 19 | 19 | // :1:18: error: opaque types have unknown size and therefore cannot be directly embedded in unions |
| 20 | // :6:45: note: opaque declared here | |
| 20 | // :6:39: note: opaque declared here |