From aac2d6b56f32134ea32fb3d984e3fcdfddd8aaf6 Mon Sep 17 00:00:00 2001 From: r00ster91 Date: Tue, 13 Dec 2022 22:30:06 +0100 Subject: [PATCH] std.builtin: rename Type.UnionField and Type.StructField's field_type to type --- doc/langref.html.in | 2 +- lib/std/array_hash_map.zig | 8 ++-- lib/std/builtin.zig | 5 +-- lib/std/crypto/phc_encoding.zig | 8 ++-- lib/std/enums.zig | 2 +- lib/std/hash/auto_hash.zig | 6 +-- lib/std/io/multi_writer.zig | 2 +- lib/std/json.zig | 26 ++++++------- lib/std/mem.zig | 8 ++-- lib/std/meta.zig | 16 ++++---- lib/std/meta/trailer_flags.zig | 20 +++++----- lib/std/meta/trait.zig | 2 +- lib/std/multi_array_list.zig | 26 ++++++------- .../uefi/protocols/device_path_protocol.zig | 4 +- lib/std/testing.zig | 2 +- lib/std/x/os/socket.zig | 8 ++-- lib/std/zig/Ast.zig | 2 +- lib/std/zig/c_translation.zig | 2 +- lib/std/zig/parse.zig | 2 +- src/Air.zig | 2 +- src/AstGen.zig | 2 +- src/Autodoc.zig | 4 +- src/InternPool.zig | 4 +- src/Liveness.zig | 2 +- src/Sema.zig | 22 +++++------ src/Zir.zig | 2 +- src/arch/aarch64/CodeGen.zig | 2 +- src/arch/aarch64/Mir.zig | 2 +- src/arch/arm/CodeGen.zig | 2 +- src/arch/arm/Mir.zig | 2 +- src/arch/riscv64/CodeGen.zig | 2 +- src/arch/riscv64/Mir.zig | 2 +- src/arch/sparc64/Mir.zig | 2 +- src/arch/wasm/CodeGen.zig | 2 +- src/arch/wasm/Mir.zig | 2 +- src/arch/x86_64/CodeGen.zig | 2 +- src/arch/x86_64/Mir.zig | 2 +- src/codegen/spirv/Section.zig | 14 +++---- src/link/tapi/yaml.zig | 10 ++--- src/print_zir.zig | 8 ++-- src/translate_c/ast.zig | 4 +- src/type.zig | 2 +- src/value.zig | 2 +- test/behavior/bitcast.zig | 2 +- test/behavior/bugs/12786.zig | 2 +- test/behavior/bugs/12794.zig | 2 +- test/behavior/bugs/13435.zig | 2 +- test/behavior/bugs/6456.zig | 2 +- test/behavior/tuple.zig | 6 +-- test/behavior/tuple_declarations.zig | 10 ++--- test/behavior/type.zig | 38 +++++++++---------- test/behavior/type_info.zig | 8 ++-- test/behavior/union.zig | 2 +- ...store_in_comptime_switch_in_runtime_if.zig | 2 +- .../compile_errors/dereference_anyopaque.zig | 2 +- ...d_alignment_unavailable_for_reify_type.zig | 2 +- test/cases/compile_errors/reify_struct.zig | 10 ++--- ...for_tagged_union_with_extra_enum_field.zig | 4 +- ...or_tagged_union_with_extra_union_field.zig | 6 +-- ...reify_type_for_union_with_opaque_field.zig | 4 +- 60 files changed, 177 insertions(+), 178 deletions(-) diff --git a/doc/langref.html.in b/doc/langref.html.in index f93505fbfe334d09762524871c5220051f179a5d..4a927ed17deb917bdd59f1d8af070b9eeca9e9f8 100644 --- a/doc/langref.html.in +++ b/doc/langref.html.in @@ -4253,7 +4253,7 @@ fn isFieldOptional(comptime T: type, field_index: usize) !bool { return switch (field_index) { // This prong is analyzed `fields.len - 1` times with `idx` being an // unique comptime-known value each time. - inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].field_type) == .Optional, + inline 0...fields.len - 1 => |idx| @typeInfo(fields[idx].type) == .Optional, else => return error.IndexOutOfBounds, }; } diff --git a/lib/std/array_hash_map.zig b/lib/std/array_hash_map.zig index 1d6d86f8f52a076f2f835fae4e71f89efc02d852..cf04a54116b029c9836e40fa9cdc4f400671b77a 100644 --- a/lib/std/array_hash_map.zig +++ b/lib/std/array_hash_map.zig @@ -2270,13 +2270,13 @@ test "reIndex" { test "auto store_hash" { const HasCheapEql = AutoArrayHashMap(i32, i32); const HasExpensiveEql = AutoArrayHashMap([32]i32, i32); - try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).field_type == void); - try testing.expect(meta.fieldInfo(HasExpensiveEql.Data, .hash).field_type != void); + try testing.expect(meta.fieldInfo(HasCheapEql.Data, .hash).type == void); + try testing.expect(meta.fieldInfo(HasExpensiveEql.Data, .hash).type != void); const HasCheapEqlUn = AutoArrayHashMapUnmanaged(i32, i32); const HasExpensiveEqlUn = AutoArrayHashMapUnmanaged([32]i32, i32); - try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).field_type == void); - try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Data, .hash).field_type != void); + try testing.expect(meta.fieldInfo(HasCheapEqlUn.Data, .hash).type == void); + try testing.expect(meta.fieldInfo(HasExpensiveEqlUn.Data, .hash).type != void); } test "sort" { diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index a32f8253d49a63391d113403f4c065855865c2a1..349d976ddc5b688b800145e98cbc62cbdcf29942 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -280,8 +280,7 @@ pub const Type = union(enum) { /// therefore must be kept in sync with the compiler implementation. pub const StructField = struct { name: []const u8, - /// TODO rename to `type` - field_type: type, + type: type, default_value: ?*const anyopaque, is_comptime: bool, alignment: comptime_int, @@ -343,7 +342,7 @@ pub const Type = union(enum) { /// therefore must be kept in sync with the compiler implementation. pub const UnionField = struct { name: []const u8, - field_type: type, + type: type, alignment: comptime_int, }; diff --git a/lib/std/crypto/phc_encoding.zig b/lib/std/crypto/phc_encoding.zig index bba03a3fff2f19657dcdd74bf3f65a63477e68ec..4b6965d040ace678262a79a50127aa8624e48ef8 100644 --- a/lib/std/crypto/phc_encoding.zig +++ b/lib/std/crypto/phc_encoding.zig @@ -110,9 +110,9 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult var found = false; inline for (comptime meta.fields(HashResult)) |p| { if (mem.eql(u8, p.name, param.key)) { - switch (@typeInfo(p.field_type)) { + switch (@typeInfo(p.type)) { .Int => @field(out, p.name) = fmt.parseUnsigned( - p.field_type, + p.type, param.value, 10, ) catch return Error.InvalidEncoding, @@ -161,7 +161,7 @@ pub fn deserialize(comptime HashResult: type, str: []const u8) Error!HashResult // with default values var expected_fields: usize = 0; inline for (comptime meta.fields(HashResult)) |p| { - if (@typeInfo(p.field_type) != .Optional and p.default_value == null) { + if (@typeInfo(p.type) != .Optional and p.default_value == null) { expected_fields += 1; } } @@ -223,7 +223,7 @@ fn serializeTo(params: anytype, out: anytype) !void { { const value = @field(params, p.name); try out.writeAll(if (has_params) params_delimiter else fields_delimiter); - if (@typeInfo(p.field_type) == .Struct) { + if (@typeInfo(p.type) == .Struct) { var buf: [@TypeOf(value).max_encoded_length]u8 = undefined; try out.print("{s}{s}{s}", .{ p.name, kv_delimiter, try value.toB64(&buf) }); } else { diff --git a/lib/std/enums.zig b/lib/std/enums.zig index 0fdbf031627ea3375b8335e3937e178e9a75d875..2640e6aac9351c8eb79ec2b8cd9b6982d3faf881 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -15,7 +15,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def for (std.meta.fields(E)) |field| { fields = fields ++ &[_]StructField{.{ .name = field.name, - .field_type = Data, + .type = Data, .default_value = if (field_default) |d| @ptrCast(?*const anyopaque, &d) else null, .is_comptime = false, .alignment = if (@sizeOf(Data) > 0) @alignOf(Data) else 0, diff --git a/lib/std/hash/auto_hash.zig b/lib/std/hash/auto_hash.zig index aac4b0feaf84bf3983cdbba3fb4a6684751bee5c..d4640262f25b4c9e2cac8793f1b53cc5d6e8837a 100644 --- a/lib/std/hash/auto_hash.zig +++ b/lib/std/hash/auto_hash.zig @@ -134,7 +134,7 @@ pub fn hash(hasher: anytype, key: anytype, comptime strat: HashStrategy) void { hash(hasher, tag, strat); inline for (info.fields) |field| { if (@field(tag_type, field.name) == tag) { - if (field.field_type != void) { + if (field.type != void) { hash(hasher, @field(key, field.name), strat); } // TODO use a labelled break when it does not crash the compiler. cf #2908 @@ -163,14 +163,14 @@ fn typeContainsSlice(comptime K: type) bool { } if (meta.trait.is(.Struct)(K)) { inline for (@typeInfo(K).Struct.fields) |field| { - if (typeContainsSlice(field.field_type)) { + if (typeContainsSlice(field.type)) { return true; } } } if (meta.trait.is(.Union)(K)) { inline for (@typeInfo(K).Union.fields) |field| { - if (typeContainsSlice(field.field_type)) { + if (typeContainsSlice(field.type)) { return true; } } diff --git a/lib/std/io/multi_writer.zig b/lib/std/io/multi_writer.zig index ae683848d0dec625e9d5010972d09bbeca132fd2..b3f64f1553fec82862cb6f3dbf18b8e21c4d7e69 100644 --- a/lib/std/io/multi_writer.zig +++ b/lib/std/io/multi_writer.zig @@ -6,7 +6,7 @@ const testing = std.testing; pub fn MultiWriter(comptime Writers: type) type { comptime var ErrSet = error{}; inline for (@typeInfo(Writers).Struct.fields) |field| { - const StreamType = field.field_type; + const StreamType = field.type; ErrSet = ErrSet || StreamType.Error; } diff --git a/lib/std/json.zig b/lib/std/json.zig index 17fc13b0dc2f8434736070d14c4d9719aabb9ee4..f16d70da80428cd77aa62784b2605d183148666c 100644 --- a/lib/std/json.zig +++ b/lib/std/json.zig @@ -1362,7 +1362,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ if (unionInfo.tag_type) |_| { var errors = error{NoUnionMembersMatched}; for (unionInfo.fields) |u_field| { - errors = errors || ParseInternalErrorImpl(u_field.field_type, inferred_types ++ [_]type{T}); + errors = errors || ParseInternalErrorImpl(u_field.type, inferred_types ++ [_]type{T}); } return errors; } else { @@ -1379,7 +1379,7 @@ fn ParseInternalErrorImpl(comptime T: type, comptime inferred_types: []const typ MissingField, } || SkipValueError || TokenStream.Error; for (structInfo.fields) |field| { - errors = errors || ParseInternalErrorImpl(field.field_type, inferred_types ++ [_]type{T}); + errors = errors || ParseInternalErrorImpl(field.type, inferred_types ++ [_]type{T}); } return errors; }, @@ -1491,7 +1491,7 @@ fn parseInternal( inline for (unionInfo.fields) |u_field| { // take a copy of tokens so we can withhold mutations until success var tokens_copy = tokens.*; - if (parseInternal(u_field.field_type, token, &tokens_copy, options)) |value| { + if (parseInternal(u_field.type, token, &tokens_copy, options)) |value| { tokens.* = tokens_copy; return @unionInit(T, u_field.name, value); } else |err| { @@ -1519,7 +1519,7 @@ fn parseInternal( errdefer { inline for (structInfo.fields) |field, i| { if (fields_seen[i] and !field.is_comptime) { - parseFree(field.field_type, @field(r, field.name), options); + parseFree(field.type, @field(r, field.name), options); } } } @@ -1547,24 +1547,24 @@ fn parseInternal( // } if (options.duplicate_field_behavior == .UseFirst) { // unconditonally ignore value. for comptime fields, this skips check against default_value - parseFree(field.field_type, try parse(field.field_type, tokens, child_options), child_options); + parseFree(field.type, try parse(field.type, tokens, child_options), child_options); found = true; break; } else if (options.duplicate_field_behavior == .Error) { return error.DuplicateJSONField; } else if (options.duplicate_field_behavior == .UseLast) { if (!field.is_comptime) { - parseFree(field.field_type, @field(r, field.name), child_options); + parseFree(field.type, @field(r, field.name), child_options); } fields_seen[i] = false; } } if (field.is_comptime) { - if (!try parsesTo(field.field_type, @ptrCast(*align(1) const field.field_type, field.default_value.?).*, tokens, child_options)) { + if (!try parsesTo(field.type, @ptrCast(*align(1) const field.type, field.default_value.?).*, tokens, child_options)) { return error.UnexpectedValue; } } else { - @field(r, field.name) = try parse(field.field_type, tokens, child_options); + @field(r, field.name) = try parse(field.type, tokens, child_options); } fields_seen[i] = true; found = true; @@ -1587,7 +1587,7 @@ fn parseInternal( if (!fields_seen[i]) { if (field.default_value) |default_ptr| { if (!field.is_comptime) { - const default = @ptrCast(*align(1) const field.field_type, default_ptr).*; + const default = @ptrCast(*align(1) const field.type, default_ptr).*; @field(r, field.name) = default; } } else { @@ -1732,7 +1732,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { if (unionInfo.tag_type) |UnionTagType| { inline for (unionInfo.fields) |u_field| { if (value == @field(UnionTagType, u_field.name)) { - parseFree(u_field.field_type, @field(value, u_field.name), options); + parseFree(u_field.type, @field(value, u_field.name), options); break; } } @@ -1743,7 +1743,7 @@ pub fn parseFree(comptime T: type, value: T, options: ParseOptions) void { .Struct => |structInfo| { inline for (structInfo.fields) |field| { if (!field.is_comptime) { - parseFree(field.field_type, @field(value, field.name), options); + parseFree(field.type, @field(value, field.name), options); } } }, @@ -2270,12 +2270,12 @@ pub fn stringify( } inline for (S.fields) |Field| { // don't include void fields - if (Field.field_type == void) continue; + if (Field.type == void) continue; var emit_field = true; // don't include optional fields that are null when emit_null_optional_fields is set to false - if (@typeInfo(Field.field_type) == .Optional) { + if (@typeInfo(Field.type) == .Optional) { if (options.emit_null_optional_fields == false) { if (@field(value, Field.name) == null) { emit_field = false; diff --git a/lib/std/mem.zig b/lib/std/mem.zig index a6b7490dabef2e58c543c18da9794e1acf6f8da6..17281390a80d4d13808ac460a03085943db7a79c 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -300,7 +300,7 @@ pub fn zeroes(comptime T: type) T { if (comptime meta.containerLayout(T) == .Extern) { // The C language specification states that (global) unions // should be zero initialized to the first named member. - return @unionInit(T, info.fields[0].name, zeroes(info.fields[0].field_type)); + return @unionInit(T, info.fields[0].name, zeroes(info.fields[0].type)); } @compileError("Can't set a " ++ @typeName(T) ++ " to zero."); @@ -435,7 +435,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { inline for (struct_info.fields) |field| { if (field.default_value) |default_value_ptr| { - const default_value = @ptrCast(*align(1) const field.field_type, default_value_ptr).*; + const default_value = @ptrCast(*align(1) const field.type, default_value_ptr).*; @field(value, field.name) = default_value; } } @@ -452,9 +452,9 @@ pub fn zeroInit(comptime T: type, init: anytype) T { @compileError("Encountered an initializer for `" ++ field.name ++ "`, but it is not a field of " ++ @typeName(T)); } - switch (@typeInfo(field.field_type)) { + switch (@typeInfo(field.type)) { .Struct => { - @field(value, field.name) = zeroInit(field.field_type, @field(init, field.name)); + @field(value, field.name) = zeroInit(field.type, @field(init, field.name)); }, else => { @field(value, field.name) = @field(init, field.name); diff --git a/lib/std/meta.zig b/lib/std/meta.zig index c2e42679985dc8c0189f7ab6834855c35ae75b21..b4a73ffb3a79e0b5b81a0e8050cc6c483ec05110 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -522,8 +522,8 @@ test "std.meta.fields" { try testing.expect(mem.eql(u8, e2f[0].name, "A")); try testing.expect(mem.eql(u8, sf[0].name, "a")); try testing.expect(mem.eql(u8, uf[0].name, "a")); - try testing.expect(comptime sf[0].field_type == u8); - try testing.expect(comptime uf[0].field_type == u8); + try testing.expect(comptime sf[0].type == u8); + try testing.expect(comptime uf[0].type == u8); } pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) { @@ -557,8 +557,8 @@ test "std.meta.fieldInfo" { try testing.expect(mem.eql(u8, e2f.name, "A")); try testing.expect(mem.eql(u8, sf.name, "a")); try testing.expect(mem.eql(u8, uf.name, "a")); - try testing.expect(comptime sf.field_type == u8); - try testing.expect(comptime uf.field_type == u8); + try testing.expect(comptime sf.type == u8); + try testing.expect(comptime uf.type == u8); } 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 { inline for (info.fields) |field_info| { if (comptime mem.eql(u8, field_info.name, @tagName(tag))) - return field_info.field_type; + return field_info.type; } unreachable; @@ -1111,7 +1111,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { var num_buf: [128]u8 = undefined; tuple_fields[i] = .{ .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable, - .field_type = T, + .type = T, .default_value = null, .is_comptime = false, .alignment = if (@sizeOf(T) > 0) @alignOf(T) else 0, @@ -1146,8 +1146,8 @@ const TupleTester = struct { @compileError("Argument count mismatch"); inline for (fields_list) |fld, i| { - if (expected[i] != fld.field_type) { - @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.field_type)); + if (expected[i] != fld.type) { + @compileError("Field " ++ fld.name ++ " expected to be type " ++ @typeName(expected[i]) ++ ", but was type " ++ @typeName(fld.type)); } } } diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index 34fb17eb0a21c5f579e38a9430df6bca2ed94cff..e50950018d2ca85553e056f85f8d7a8da227fa86 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -24,10 +24,10 @@ pub fn TrailerFlags(comptime Fields: type) type { inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| { fields[i] = Type.StructField{ .name = struct_field.name, - .field_type = ?struct_field.field_type, - .default_value = &@as(?struct_field.field_type, null), + .type = ?struct_field.type, + .default_value = &@as(?struct_field.type, null), .is_comptime = false, - .alignment = @alignOf(?struct_field.field_type), + .alignment = @alignOf(?struct_field.type), }; } break :blk @Type(.{ @@ -105,26 +105,26 @@ pub fn TrailerFlags(comptime Fields: type) type { const active = (self.bits & (1 << i)) != 0; if (i == @enumToInt(field)) { assert(active); - return mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type)); + return mem.alignForwardGeneric(usize, off, @alignOf(field_info.type)); } else if (active) { - off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.field_type)); - off += @sizeOf(field_info.field_type); + off = mem.alignForwardGeneric(usize, off, @alignOf(field_info.type)); + off += @sizeOf(field_info.type); } } } pub fn Field(comptime field: FieldEnum) type { - return @typeInfo(Fields).Struct.fields[@enumToInt(field)].field_type; + return @typeInfo(Fields).Struct.fields[@enumToInt(field)].type; } pub fn sizeInBytes(self: Self) usize { var off: usize = 0; inline for (@typeInfo(Fields).Struct.fields) |field, i| { - if (@sizeOf(field.field_type) == 0) + if (@sizeOf(field.type) == 0) continue; if ((self.bits & (1 << i)) != 0) { - off = mem.alignForwardGeneric(usize, off, @alignOf(field.field_type)); - off += @sizeOf(field.field_type); + off = mem.alignForwardGeneric(usize, off, @alignOf(field.type)); + off += @sizeOf(field.type); } } return off; diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig index 2e9c2165f715412c0e495797820e00a87743b616..73d1292406aa424a0b5e41f7c261b4240fe2936d 100644 --- a/lib/std/meta/trait.zig +++ b/lib/std/meta/trait.zig @@ -566,7 +566,7 @@ pub fn hasUniqueRepresentation(comptime T: type) bool { var sum_size = @as(usize, 0); inline for (info.fields) |field| { - const FieldType = field.field_type; + const FieldType = field.type; if (comptime !hasUniqueRepresentation(FieldType)) return false; sum_size += @sizeOf(FieldType); } diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index e05b87c0be7859a338d267db4ceefdb30a73c4b3..38c8276b9a26d8171d7791d98ab976d8d61e2e68 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -84,9 +84,9 @@ pub fn MultiArrayList(comptime S: type) type { var data: [fields.len]Data = undefined; for (fields) |field_info, i| { data[i] = .{ - .size = @sizeOf(field_info.field_type), + .size = @sizeOf(field_info.type), .size_index = i, - .alignment = if (@sizeOf(field_info.field_type) == 0) 1 else field_info.alignment, + .alignment = if (@sizeOf(field_info.type) == 0) 1 else field_info.alignment, }; } const Sort = struct { @@ -294,10 +294,10 @@ pub fn MultiArrayList(comptime S: type) type { ) catch { const self_slice = self.slice(); inline for (fields) |field_info, i| { - if (@sizeOf(field_info.field_type) != 0) { + if (@sizeOf(field_info.type) != 0) { const field = @intToEnum(Field, i); const dest_slice = self_slice.items(field)[new_len..]; - const byte_count = dest_slice.len * @sizeOf(field_info.field_type); + const byte_count = dest_slice.len * @sizeOf(field_info.type); // We use memset here for more efficient codegen in safety-checked, // valgrind-enabled builds. Otherwise the valgrind client request // will be repeated for every element. @@ -316,9 +316,9 @@ pub fn MultiArrayList(comptime S: type) type { const self_slice = self.slice(); const other_slice = other.slice(); inline for (fields) |field_info, i| { - if (@sizeOf(field_info.field_type) != 0) { + if (@sizeOf(field_info.type) != 0) { const field = @intToEnum(Field, i); - mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field)); + mem.copy(field_info.type, other_slice.items(field), self_slice.items(field)); } } gpa.free(self.allocatedBytes()); @@ -377,9 +377,9 @@ pub fn MultiArrayList(comptime S: type) type { const self_slice = self.slice(); const other_slice = other.slice(); inline for (fields) |field_info, i| { - if (@sizeOf(field_info.field_type) != 0) { + if (@sizeOf(field_info.type) != 0) { const field = @intToEnum(Field, i); - mem.copy(field_info.field_type, other_slice.items(field), self_slice.items(field)); + mem.copy(field_info.type, other_slice.items(field), self_slice.items(field)); } } gpa.free(self.allocatedBytes()); @@ -396,9 +396,9 @@ pub fn MultiArrayList(comptime S: type) type { const self_slice = self.slice(); const result_slice = result.slice(); inline for (fields) |field_info, i| { - if (@sizeOf(field_info.field_type) != 0) { + if (@sizeOf(field_info.type) != 0) { const field = @intToEnum(Field, i); - mem.copy(field_info.field_type, result_slice.items(field), self_slice.items(field)); + mem.copy(field_info.type, result_slice.items(field), self_slice.items(field)); } } return result; @@ -413,10 +413,10 @@ pub fn MultiArrayList(comptime S: type) type { pub fn swap(sc: @This(), a_index: usize, b_index: usize) void { inline for (fields) |field_info, i| { - if (@sizeOf(field_info.field_type) != 0) { + if (@sizeOf(field_info.type) != 0) { const field = @intToEnum(Field, i); const ptr = sc.slice.items(field); - mem.swap(field_info.field_type, &ptr[a_index], &ptr[b_index]); + mem.swap(field_info.type, &ptr[a_index], &ptr[b_index]); } } } @@ -449,7 +449,7 @@ pub fn MultiArrayList(comptime S: type) type { } fn FieldType(comptime field: Field) type { - return meta.fieldInfo(S, field).field_type; + return meta.fieldInfo(S, field).type; } /// This function is used in tools/zig-gdb.py to fetch the child type to facilitate diff --git a/lib/std/os/uefi/protocols/device_path_protocol.zig b/lib/std/os/uefi/protocols/device_path_protocol.zig index 338c9ea50d0ef93bb725de0f17cbbab5c7a50ec0..6df6442fe669ca74213be0ba2e0e60690c64b9b1 100644 --- a/lib/std/os/uefi/protocols/device_path_protocol.zig +++ b/lib/std/os/uefi/protocols/device_path_protocol.zig @@ -81,7 +81,7 @@ pub const DevicePathProtocol = extern struct { // Got the associated union type for self.type, now // we need to initialize it and its subtype if (self.type == enum_value) { - var subtype = self.initSubtype(ufield.field_type); + var subtype = self.initSubtype(ufield.type); if (subtype) |sb| { // e.g. return .{ .Hardware = .{ .Pci = @ptrCast(...) } } @@ -103,7 +103,7 @@ pub const DevicePathProtocol = extern struct { if (self.subtype == tag_val) { // e.g. expr = .{ .Pci = @ptrCast(...) } - return @unionInit(TUnion, subtype.name, @ptrCast(subtype.field_type, self)); + return @unionInit(TUnion, subtype.name, @ptrCast(subtype.type, self)); } } diff --git a/lib/std/testing.zig b/lib/std/testing.zig index 72f3ba2d9ebb89a6e821248e4a6700aa741170f4..53877967c95e1e39bbdc1a95cd2f214d63944c28 100644 --- a/lib/std/testing.zig +++ b/lib/std/testing.zig @@ -802,7 +802,7 @@ pub fn checkAllAllocationFailures(backing_allocator: std.mem.Allocator, comptime const ArgsTuple = std.meta.ArgsTuple(@TypeOf(test_fn)); const fn_args_fields = @typeInfo(ArgsTuple).Struct.fields; - if (fn_args_fields.len == 0 or fn_args_fields[0].field_type != std.mem.Allocator) { + if (fn_args_fields.len == 0 or fn_args_fields[0].type != std.mem.Allocator) { @compileError("The provided function must have an " ++ @typeName(std.mem.Allocator) ++ " as its first argument"); } const expected_args_tuple_len = fn_args_fields.len - 1; diff --git a/lib/std/x/os/socket.zig b/lib/std/x/os/socket.zig index 3de9359cc559a34de7d19c6180adf1b45769bbfd..99782710cbb3ee21daae55b4e665417fa4520577 100644 --- a/lib/std/x/os/socket.zig +++ b/lib/std/x/os/socket.zig @@ -230,12 +230,12 @@ pub const Socket = struct { pub fn setName(self: *Self, name: []const u8) void { self.name = @ptrToInt(name.ptr); - self.name_len = @intCast(meta.fieldInfo(Self, .name_len).field_type, name.len); + self.name_len = @intCast(meta.fieldInfo(Self, .name_len).type, name.len); } pub fn setBuffers(self: *Self, buffers: []const Buffer) void { self.buffers = @ptrToInt(buffers.ptr); - self.buffers_len = @intCast(meta.fieldInfo(Self, .buffers_len).field_type, buffers.len); + self.buffers_len = @intCast(meta.fieldInfo(Self, .buffers_len).type, buffers.len); } pub fn setControl(self: *Self, control: []const u8) void { @@ -243,12 +243,12 @@ pub const Socket = struct { self.control = Buffer.from(control); } else { self.control = @ptrToInt(control.ptr); - self.control_len = @intCast(meta.fieldInfo(Self, .control_len).field_type, control.len); + self.control_len = @intCast(meta.fieldInfo(Self, .control_len).type, control.len); } } pub fn setFlags(self: *Self, flags: u32) void { - self.flags = @intCast(meta.fieldInfo(Self, .flags).field_type, flags); + self.flags = @intCast(meta.fieldInfo(Self, .flags).type, flags); } pub fn getName(self: Self) []const u8 { diff --git a/lib/std/zig/Ast.zig b/lib/std/zig/Ast.zig index 159b4dbb3acd69e4179375c775fe80e6394c13b6..eda0ee09da0d1b086250fe19701bd3877158ddfb 100644 --- a/lib/std/zig/Ast.zig +++ b/lib/std/zig/Ast.zig @@ -125,7 +125,7 @@ pub fn extraData(tree: Ast, index: usize, comptime T: type) T { const fields = std.meta.fields(T); var result: T = undefined; inline for (fields) |field, i| { - comptime assert(field.field_type == Node.Index); + comptime assert(field.type == Node.Index); @field(result, field.name) = tree.extra_data[index + i]; } return result; diff --git a/lib/std/zig/c_translation.zig b/lib/std/zig/c_translation.zig index aa9d59dae9b9354234bb4b322ff05436eccb53ed..a050e592a2fd729423f39219a83e3c99999d4efc 100644 --- a/lib/std/zig/c_translation.zig +++ b/lib/std/zig/c_translation.zig @@ -50,7 +50,7 @@ pub fn cast(comptime DestType: type, target: anytype) DestType { }, .Union => |info| { inline for (info.fields) |field| { - if (field.field_type == SourceType) return @unionInit(DestType, field.name, target); + if (field.type == SourceType) return @unionInit(DestType, field.name, target); } @compileError("cast to union type '" ++ @typeName(DestType) ++ "' from type '" ++ @typeName(SourceType) ++ "' which is not present in union"); }, diff --git a/lib/std/zig/parse.zig b/lib/std/zig/parse.zig index 0155cf0d753be044e7c0bb500e9351d5a8e3dbb5..205b094e933c72b989cdeeb6fe02da270029b410 100644 --- a/lib/std/zig/parse.zig +++ b/lib/std/zig/parse.zig @@ -153,7 +153,7 @@ const Parser = struct { try p.extra_data.ensureUnusedCapacity(p.gpa, fields.len); const result = @intCast(u32, p.extra_data.items.len); inline for (fields) |field| { - comptime assert(field.field_type == Node.Index); + comptime assert(field.type == Node.Index); p.extra_data.appendAssumeCapacity(@field(extra, field.name)); } return result; diff --git a/src/Air.zig b/src/Air.zig index 707e700f0830a9c1c71bf81857b5caecb074901e..7528d72bda11fa025be43e58ab5b17272091abdc 100644 --- a/src/Air.zig +++ b/src/Air.zig @@ -1260,7 +1260,7 @@ pub fn extraData(air: Air, comptime T: type, index: usize) struct { data: T, end var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => air.extra[i], Inst.Ref => @intToEnum(Inst.Ref, air.extra[i]), i32 => @bitCast(i32, air.extra[i]), diff --git a/src/AstGen.zig b/src/AstGen.zig index 8df3d56a88f4c5ef0c4f9e8c1e15118b670709bc..9d9fae3c13cdd7154681c7d7030b9d11d9b0ea33 100644 --- a/src/AstGen.zig +++ b/src/AstGen.zig @@ -79,7 +79,7 @@ fn setExtra(astgen: *AstGen, index: usize, extra: anytype) void { const fields = std.meta.fields(@TypeOf(extra)); var i = index; inline for (fields) |field| { - astgen.extra.items[i] = switch (field.field_type) { + astgen.extra.items[i] = switch (field.type) { u32 => @field(extra, field.name), Zir.Inst.Ref => @enumToInt(@field(extra, field.name)), i32 => @bitCast(u32, @field(extra, field.name)), diff --git a/src/Autodoc.zig b/src/Autodoc.zig index 55ff0484828080a1526f2fb57cfc4c779fd7c58c..246b97037a7536e80920ffb5c6dabc02e74cd43d 100644 --- a/src/Autodoc.zig +++ b/src/Autodoc.zig @@ -637,9 +637,9 @@ const DocData = struct { inline for (comptime std.meta.fields(Type)) |case| { if (@field(Type, case.name) == active_tag) { const current_value = @field(self, case.name); - inline for (comptime std.meta.fields(case.field_type)) |f| { + inline for (comptime std.meta.fields(case.type)) |f| { try jsw.arrayElem(); - if (f.field_type == std.builtin.Type.Pointer.Size) { + if (f.type == std.builtin.Type.Pointer.Size) { try jsw.emitNumber(@enumToInt(@field(current_value, f.name))); } else { try std.json.stringify(@field(current_value, f.name), opts, w); diff --git a/src/InternPool.zig b/src/InternPool.zig index 5e50780315def799e124a7752bde90d222ef411a..74155ca657c1f6bc3c7e3fc75cb03fb26460bfeb 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -259,7 +259,7 @@ fn addExtraAssumeCapacity(ip: *InternPool, extra: anytype) u32 { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, ip.extra.items.len); inline for (fields) |field| { - ip.extra.appendAssumeCapacity(switch (field.field_type) { + ip.extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), Index => @enumToInt(@field(extra, field.name)), i32 => @bitCast(u32, @field(extra, field.name)), @@ -274,7 +274,7 @@ fn extraData(ip: InternPool, comptime T: type, index: usize) T { var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => ip.extra.items[i], Index => @intToEnum(Index, ip.extra.items[i]), i32 => @bitCast(i32, ip.extra.items[i]), diff --git a/src/Liveness.zig b/src/Liveness.zig index d129dc01bfb6b909e22d40b81db2adcecd9933f4..b5fd5973269960f0035e70c36e4fcfa57c3b1f2f 100644 --- a/src/Liveness.zig +++ b/src/Liveness.zig @@ -718,7 +718,7 @@ const Analysis = struct { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, a.extra.items.len); inline for (fields) |field| { - a.extra.appendAssumeCapacity(switch (field.field_type) { + a.extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), else => @compileError("bad field type"), }); diff --git a/src/Sema.zig b/src/Sema.zig index ab839f19a384612a727ad92393a11a37274d1b84..6f1af51d28b783cb1714b93eded1b7a40078b61a 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -15767,7 +15767,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai union_field_fields.* = .{ // name: []const u8, name_val, - // field_type: type, + // type: type, try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), // alignment: comptime_int, 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 struct_field_fields.* = .{ // name: []const u8, name_val, - // field_type: type, + // type: type, try Value.Tag.ty.create(fields_anon_decl.arena(), field_ty), // default_value: ?*const anyopaque, 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 struct_field_fields.* = .{ // name: []const u8, name_val, - // field_type: type, + // type: type, try Value.Tag.ty.create(fields_anon_decl.arena(), field.ty), // default_value: ?*const anyopaque, 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 // TODO use reflection instead of magic numbers here // name: []const u8 const name_val = field_struct_val[0]; - // field_type: type, - const field_type_val = field_struct_val[1]; + // type: type, + const type_val = field_struct_val[1]; // alignment: comptime_int, const alignment_val = field_struct_val[2]; @@ -18609,7 +18609,7 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in } var buffer: Value.ToTypeBuffer = undefined; - const field_ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator); + const field_ty = try type_val.toType(&buffer).copy(new_decl_arena_allocator); gop.value_ptr.* = .{ .ty = field_ty, .abi_align = @intCast(u32, (try alignment_val.getUnsignedIntAdvanced(target, sema)).?), @@ -18828,9 +18828,9 @@ fn reifyStruct( // TODO use reflection instead of magic numbers here // name: []const u8 const name_val = field_struct_val[0]; - // field_type: type, - const field_type_val = field_struct_val[1]; - //default_value: ?*const anyopaque, + // type: type, + const type_val = field_struct_val[1]; + // default_value: ?*const anyopaque, const default_value_val = field_struct_val[2]; // is_comptime: bool, const is_comptime_val = field_struct_val[3]; @@ -18893,7 +18893,7 @@ fn reifyStruct( } var buffer: Value.ToTypeBuffer = undefined; - const field_ty = try field_type_val.toType(&buffer).copy(new_decl_arena_allocator); + const field_ty = try type_val.toType(&buffer).copy(new_decl_arena_allocator); gop.value_ptr.* = .{ .ty = field_ty, .abi_align = abi_align, @@ -31439,7 +31439,7 @@ pub fn addExtraAssumeCapacity(sema: *Sema, extra: anytype) u32 { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, sema.air_extra.items.len); inline for (fields) |field| { - sema.air_extra.appendAssumeCapacity(switch (field.field_type) { + sema.air_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), Air.Inst.Ref => @enumToInt(@field(extra, field.name)), i32 => @bitCast(u32, @field(extra, field.name)), diff --git a/src/Zir.zig b/src/Zir.zig index 6e7164878c92b057541ac8548bce98bcbea4ad10..faa8d436388df3f4a15014105ecc40fca226bc85 100644 --- a/src/Zir.zig +++ b/src/Zir.zig @@ -71,7 +71,7 @@ pub fn extraData(code: Zir, comptime T: type, index: usize) struct { data: T, en var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => code.extra[i], Inst.Ref => @intToEnum(Inst.Ref, code.extra[i]), i32 => @bitCast(i32, code.extra[i]), diff --git a/src/arch/aarch64/CodeGen.zig b/src/arch/aarch64/CodeGen.zig index 8c87a005d551541266ea193f6a8c59b055a2fb75..acaffad5fe52860695d057aef98c8295ff2c2d74 100644 --- a/src/arch/aarch64/CodeGen.zig +++ b/src/arch/aarch64/CodeGen.zig @@ -477,7 +477,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, self.mir_extra.items.len); inline for (fields) |field| { - self.mir_extra.appendAssumeCapacity(switch (field.field_type) { + self.mir_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), i32 => @bitCast(u32, @field(extra, field.name)), else => @compileError("bad field type"), diff --git a/src/arch/aarch64/Mir.zig b/src/arch/aarch64/Mir.zig index e5541a59883721e186259b51c47011337c8e582e..cc478c874a7c4e7d1fbad866aa09c81626f17d86 100644 --- a/src/arch/aarch64/Mir.zig +++ b/src/arch/aarch64/Mir.zig @@ -505,7 +505,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), diff --git a/src/arch/arm/CodeGen.zig b/src/arch/arm/CodeGen.zig index 9d6d18d5c9b6074d710a3fcecd1c9d5c6e52e402..be0a35f54dc59e8e77173432b050cef60fd8d8bf 100644 --- a/src/arch/arm/CodeGen.zig +++ b/src/arch/arm/CodeGen.zig @@ -386,7 +386,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, self.mir_extra.items.len); inline for (fields) |field| { - self.mir_extra.appendAssumeCapacity(switch (field.field_type) { + self.mir_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), i32 => @bitCast(u32, @field(extra, field.name)), else => @compileError("bad field type"), diff --git a/src/arch/arm/Mir.zig b/src/arch/arm/Mir.zig index 3478d8dc58521ab892dd2a801af1ae8dcd74ae77..07a8384c2c8955ca195e2b65ce8dbade0c7d6970 100644 --- a/src/arch/arm/Mir.zig +++ b/src/arch/arm/Mir.zig @@ -283,7 +283,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), diff --git a/src/arch/riscv64/CodeGen.zig b/src/arch/riscv64/CodeGen.zig index 24e24076f7e8fa9684644a4a7233f53e4b7cccda..1aa443341f87a2e47e1cb4d3adb60c0e8be0f439 100644 --- a/src/arch/riscv64/CodeGen.zig +++ b/src/arch/riscv64/CodeGen.zig @@ -340,7 +340,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, self.mir_extra.items.len); inline for (fields) |field| { - self.mir_extra.appendAssumeCapacity(switch (field.field_type) { + self.mir_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), i32 => @bitCast(u32, @field(extra, field.name)), else => @compileError("bad field type"), diff --git a/src/arch/riscv64/Mir.zig b/src/arch/riscv64/Mir.zig index 5df3a86229a93372f428b8e6ced34c771849c3df..97accb7642b89b4d30c8966251f9dd2d2d43110c 100644 --- a/src/arch/riscv64/Mir.zig +++ b/src/arch/riscv64/Mir.zig @@ -132,7 +132,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), diff --git a/src/arch/sparc64/Mir.zig b/src/arch/sparc64/Mir.zig index 744bd849432a577e11f7ebf68f4520a2073f8459..f854152a2f7cd133994f73ce918c7a3f3bb64bdc 100644 --- a/src/arch/sparc64/Mir.zig +++ b/src/arch/sparc64/Mir.zig @@ -347,7 +347,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index 70a2aea3c9d1c0560f6aa8e1d039c1ff4103c3c5..d175b960340f337c17362a394cf2cc719125c3a3 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -960,7 +960,7 @@ fn addExtraAssumeCapacity(func: *CodeGen, extra: anytype) error{OutOfMemory}!u32 const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, func.mir_extra.items.len); inline for (fields) |field| { - func.mir_extra.appendAssumeCapacity(switch (field.field_type) { + func.mir_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)), }); diff --git a/src/arch/wasm/Mir.zig b/src/arch/wasm/Mir.zig index 0f33dd935071433838ec59c1dc5b6f68bdd016d4..66969a9c218acc258d25b5baa8247ad41f12e284 100644 --- a/src/arch/wasm/Mir.zig +++ b/src/arch/wasm/Mir.zig @@ -589,7 +589,7 @@ pub fn extraData(self: *const Mir, comptime T: type, index: usize) struct { data var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => self.extra[i], else => |field_type| @compileError("Unsupported field type " ++ @typeName(field_type)), }; diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index d0599150bd5bf1a21f5b349112289f463b5f8fac..e0cf3b946db00b69557e8bc6fb29e1046e8984ff 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -374,7 +374,7 @@ pub fn addExtraAssumeCapacity(self: *Self, extra: anytype) u32 { const fields = std.meta.fields(@TypeOf(extra)); const result = @intCast(u32, self.mir_extra.items.len); inline for (fields) |field| { - self.mir_extra.appendAssumeCapacity(switch (field.field_type) { + self.mir_extra.appendAssumeCapacity(switch (field.type) { u32 => @field(extra, field.name), i32 => @bitCast(u32, @field(extra, field.name)), else => @compileError("bad field type"), diff --git a/src/arch/x86_64/Mir.zig b/src/arch/x86_64/Mir.zig index 5bd8dc68f6d21d020ccc2325c26bf23f7835ca7e..df2052ca6e46e2d1443a8c4052e0cb6e89877032 100644 --- a/src/arch/x86_64/Mir.zig +++ b/src/arch/x86_64/Mir.zig @@ -612,7 +612,7 @@ pub fn extraData(mir: Mir, comptime T: type, index: usize) struct { data: T, end var i: usize = index; var result: T = undefined; inline for (fields) |field| { - @field(result, field.name) = switch (field.field_type) { + @field(result, field.name) = switch (field.type) { u32 => mir.extra[i], i32 => @bitCast(i32, mir.extra[i]), else => @compileError("bad field type"), diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig index 768525028e36a8709b8bf64a751495e5f15cbc2d..83f594dceffb422a51cf174868728fef5e9d9124 100644 --- a/src/codegen/spirv/Section.zig +++ b/src/codegen/spirv/Section.zig @@ -116,7 +116,7 @@ fn writeOperands(section: *Section, comptime Operands: type, operands: Operands) }; inline for (fields) |field| { - section.writeOperand(field.field_type, @field(operands, field.name)); + section.writeOperand(field.type, @field(operands, field.name)); } } @@ -196,7 +196,7 @@ fn writeContextDependentNumber(section: *Section, operand: spec.LiteralContextDe fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand) void { var mask: Word = 0; inline for (@typeInfo(Operand).Struct.fields) |field, bit| { - switch (@typeInfo(field.field_type)) { + switch (@typeInfo(field.type)) { .Optional => if (@field(operand, field.name) != null) { mask |= 1 << @intCast(u5, bit); }, @@ -214,7 +214,7 @@ fn writeExtendedMask(section: *Section, comptime Operand: type, operand: Operand section.writeWord(mask); inline for (@typeInfo(Operand).Struct.fields) |field| { - switch (@typeInfo(field.field_type)) { + switch (@typeInfo(field.type)) { .Optional => |info| if (@field(operand, field.name)) |child| { section.writeOperands(info.child, child); }, @@ -230,7 +230,7 @@ fn writeExtendedUnion(section: *Section, comptime Operand: type, operand: Operan inline for (@typeInfo(Operand).Union.fields) |field| { if (@field(Operand, field.name) == tag) { - section.writeOperands(field.field_type, @field(operand, field.name)); + section.writeOperands(field.type, @field(operand, field.name)); return; } } @@ -250,7 +250,7 @@ fn operandsSize(comptime Operands: type, operands: Operands) usize { var total: usize = 0; inline for (fields) |field| { - total += operandSize(field.field_type, @field(operands, field.name)); + total += operandSize(field.type, @field(operands, field.name)); } return total; @@ -304,7 +304,7 @@ fn extendedMaskSize(comptime Operand: type, operand: Operand) usize { var total: usize = 0; var any_set = false; inline for (@typeInfo(Operand).Struct.fields) |field| { - switch (@typeInfo(field.field_type)) { + switch (@typeInfo(field.type)) { .Optional => |info| if (@field(operand, field.name)) |child| { total += operandsSize(info.child, child); any_set = true; @@ -326,7 +326,7 @@ fn extendedUnionSize(comptime Operand: type, operand: Operand) usize { inline for (@typeInfo(Operand).Union.fields) |field| { if (@field(Operand, field.name) == tag) { // Add one for the tag itself. - return 1 + operandsSize(field.field_type, @field(operand, field.name)); + return 1 + operandsSize(field.type, @field(operand, field.name)); } } unreachable; diff --git a/src/link/tapi/yaml.zig b/src/link/tapi/yaml.zig index 9039d3b4f1ea1510dbb7d330ac6fe55a851f17c6..748f1c138f26640a1d83a74f1babce62621a7c71 100644 --- a/src/link/tapi/yaml.zig +++ b/src/link/tapi/yaml.zig @@ -339,7 +339,7 @@ pub const Yaml = struct { if (union_info.tag_type) |_| { inline for (union_info.fields) |field| { - if (self.parseValue(field.field_type, value)) |u_value| { + if (self.parseValue(field.type, value)) |u_value| { return @unionInit(T, field.name, u_value); } else |err| { if (@as(@TypeOf(err) || error{TypeMismatch}, err) != error.TypeMismatch) return err; @@ -366,16 +366,16 @@ pub const Yaml = struct { break :blk map.get(field_name); }; - if (@typeInfo(field.field_type) == .Optional) { - @field(parsed, field.name) = try self.parseOptional(field.field_type, value); + if (@typeInfo(field.type) == .Optional) { + @field(parsed, field.name) = try self.parseOptional(field.type, value); continue; } const unwrapped = value orelse { - log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.field_type) }); + log.debug("missing struct field: {s}: {s}", .{ field.name, @typeName(field.type) }); return error.StructFieldMissing; }; - @field(parsed, field.name) = try self.parseValue(field.field_type, unwrapped); + @field(parsed, field.name) = try self.parseValue(field.type, unwrapped); } return parsed; diff --git a/src/print_zir.zig b/src/print_zir.zig index 6dbaf51bc3f36df52eaddfc9c229a0b116311083..b17ef954fc228d8e96eba96b5c532b19a399cfc2 100644 --- a/src/print_zir.zig +++ b/src/print_zir.zig @@ -1312,7 +1312,7 @@ const Writer = struct { type_len: u32 = 0, align_len: u32 = 0, init_len: u32 = 0, - field_type: Zir.Inst.Ref = .none, + type: Zir.Inst.Ref = .none, name: u32, is_comptime: bool, }; @@ -1353,7 +1353,7 @@ const Writer = struct { if (has_type_body) { fields[field_i].type_len = self.code.extra[extra_index]; } else { - fields[field_i].field_type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); + fields[field_i].type = @intToEnum(Zir.Inst.Ref, self.code.extra[extra_index]); } extra_index += 1; @@ -1384,8 +1384,8 @@ const Writer = struct { } else { try stream.print("@\"{d}\": ", .{i}); } - if (field.field_type != .none) { - try self.writeInstRef(stream, field.field_type); + if (field.type != .none) { + try self.writeInstRef(stream, field.type); } if (field.type_len > 0) { diff --git a/src/translate_c/ast.zig b/src/translate_c/ast.zig index 1ed2eb568c63ab65c4f0096d5109cbcbb9b2453e..78175a611b5058bf955e635e97ab206bf88fb80b 100644 --- a/src/translate_c/ast.zig +++ b/src/translate_c/ast.zig @@ -392,7 +392,7 @@ pub const Node = extern union { } pub fn Data(comptime t: Tag) type { - return std.meta.fieldInfo(t.Type(), .data).field_type; + return std.meta.fieldInfo(t.Type(), .data).type; } }; @@ -845,7 +845,7 @@ const Context = struct { try c.extra_data.ensureUnusedCapacity(c.gpa, fields.len); const result = @intCast(u32, c.extra_data.items.len); inline for (fields) |field| { - comptime std.debug.assert(field.field_type == NodeIndex); + comptime std.debug.assert(field.type == NodeIndex); c.extra_data.appendAssumeCapacity(@field(extra, field.name)); } return result; diff --git a/src/type.zig b/src/type.zig index 64702509dc78b37c1317ee0ce2384cc2053bc47f..41e287829b9c9351c3b72cd03c7b4f8b2a0a2fdb 100644 --- a/src/type.zig +++ b/src/type.zig @@ -6216,7 +6216,7 @@ pub const Type = extern union { } pub fn Data(comptime t: Tag) type { - return std.meta.fieldInfo(t.Type(), .data).field_type; + return std.meta.fieldInfo(t.Type(), .data).type; } }; diff --git a/src/value.zig b/src/value.zig index 3d5636ee349a773a78830c78701515655dbcb89f..f63bd4916c587f1a235aa33c1344431dcb5261aa 100644 --- a/src/value.zig +++ b/src/value.zig @@ -338,7 +338,7 @@ pub const Value = extern union { } pub fn Data(comptime t: Tag) type { - return std.meta.fieldInfo(t.Type(), .data).field_type; + return std.meta.fieldInfo(t.Type(), .data).type; } }; diff --git a/test/behavior/bitcast.zig b/test/behavior/bitcast.zig index 73b20f3568f986f8e8c83158bb79ba6a2f2dc737..8e0bf4ec32aba5f0a80bb8d9f31799ae1077024e 100644 --- a/test/behavior/bitcast.zig +++ b/test/behavior/bitcast.zig @@ -358,7 +358,7 @@ test "comptime @bitCast packed struct to int and back" { const rt_cast = @bitCast(S, i); const ct_cast = comptime @bitCast(S, @as(Int, 0)); inline for (@typeInfo(S).Struct.fields) |field| { - if (@typeInfo(field.field_type) == .Vector) + if (@typeInfo(field.type) == .Vector) continue; //TODO: https://github.com/ziglang/zig/issues/13201 try expectEqual(@field(rt_cast, field.name), @field(ct_cast, field.name)); diff --git a/test/behavior/bugs/12786.zig b/test/behavior/bugs/12786.zig index e8c1a2333fe1234859a414d8917ffa4de263d064..958b1ebf86176c17327e0808659589beeb127547 100644 --- a/test/behavior/bugs/12786.zig +++ b/test/behavior/bugs/12786.zig @@ -8,7 +8,7 @@ fn NamespacedGlobals(comptime modules: anytype) type { .fields = &.{ .{ .name = "globals", - .field_type = modules.mach.globals, + .type = modules.mach.globals, .default_value = null, .is_comptime = false, .alignment = @alignOf(modules.mach.globals), diff --git a/test/behavior/bugs/12794.zig b/test/behavior/bugs/12794.zig index 530f81cff204ba45a975ef4fe2b802e7f59457e4..2d4f8bafd9e8bbe3c59491b213bd549e57a9b270 100644 --- a/test/behavior/bugs/12794.zig +++ b/test/behavior/bugs/12794.zig @@ -7,7 +7,7 @@ fn NamespacedComponents(comptime modules: anytype) type { .is_tuple = false, .fields = &.{.{ .name = "components", - .field_type = @TypeOf(modules.components), + .type = @TypeOf(modules.components), .default_value = null, .is_comptime = false, .alignment = @alignOf(@TypeOf(modules.components)), diff --git a/test/behavior/bugs/13435.zig b/test/behavior/bugs/13435.zig index a23735f2f47cb8a1260deb8413ebb4efcc24d58f..86a43afa0cdd11b94d4b03191e29b95b98e1e81a 100644 --- a/test/behavior/bugs/13435.zig +++ b/test/behavior/bugs/13435.zig @@ -8,7 +8,7 @@ fn CreateUnion(comptime T: type) type { .fields = &[_]std.builtin.Type.UnionField{ .{ .name = "field", - .field_type = T, + .type = T, .alignment = @alignOf(T), }, }, diff --git a/test/behavior/bugs/6456.zig b/test/behavior/bugs/6456.zig index a47f0c0d6ca860376227576b893754ddfa066fbf..03c687232f430fd660dfcf58452771fe44242af6 100644 --- a/test/behavior/bugs/6456.zig +++ b/test/behavior/bugs/6456.zig @@ -23,7 +23,7 @@ test "issue 6456" { fields = fields ++ &[_]StructField{StructField{ .alignment = 0, .name = name, - .field_type = usize, + .type = usize, .default_value = &@as(?usize, null), .is_comptime = false, }}; diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig index 9738d4e75b55359c4f3c5039e13f7f8aea84ac0b..da51127412883102e7fa262a552335da5cd08e72 100644 --- a/test/behavior/tuple.zig +++ b/test/behavior/tuple.zig @@ -136,14 +136,14 @@ test "array-like initializer for tuple types" { .fields = &.{ .{ .name = "0", - .field_type = i32, + .type = i32, .default_value = null, .is_comptime = false, .alignment = @alignOf(i32), }, .{ .name = "1", - .field_type = u8, + .type = u8, .default_value = null, .is_comptime = false, .alignment = @alignOf(i32), @@ -314,7 +314,7 @@ test "zero sized struct in tuple handled correctly" { .decls = &.{}, .fields = &.{.{ .name = "0", - .field_type = struct {}, + .type = struct {}, .default_value = null, .is_comptime = false, .alignment = 0, diff --git a/test/behavior/tuple_declarations.zig b/test/behavior/tuple_declarations.zig index 7beab1ca8faf9825a41c3e57122900089e320f5a..87d4997c8b142886f5fde3cdacf72e37e0deef0e 100644 --- a/test/behavior/tuple_declarations.zig +++ b/test/behavior/tuple_declarations.zig @@ -20,13 +20,13 @@ test "tuple declaration type info" { try expect(info.is_tuple); try expectEqualStrings(info.fields[0].name, "0"); - try expect(info.fields[0].field_type == u32); + try expect(info.fields[0].type == u32); try expect(@ptrCast(*const u32, @alignCast(@alignOf(u32), info.fields[0].default_value)).* == 1); try expect(info.fields[0].is_comptime); try expect(info.fields[0].alignment == 2); try expectEqualStrings(info.fields[1].name, "1"); - try expect(info.fields[1].field_type == []const u8); + try expect(info.fields[1].type == []const u8); try expect(info.fields[1].default_value == null); try expect(!info.fields[1].is_comptime); try expect(info.fields[1].alignment == @alignOf([]const u8)); @@ -44,13 +44,13 @@ test "tuple declaration type info" { try expect(info.is_tuple); try expectEqualStrings(info.fields[0].name, "0"); - try expect(info.fields[0].field_type == u1); + try expect(info.fields[0].type == u1); try expectEqualStrings(info.fields[1].name, "1"); - try expect(info.fields[1].field_type == u30); + try expect(info.fields[1].type == u30); try expectEqualStrings(info.fields[2].name, "2"); - try expect(info.fields[2].field_type == u1); + try expect(info.fields[2].type == u1); } } diff --git a/test/behavior/type.zig b/test/behavior/type.zig index 66ad7f55fd3fb11d4e2d3355aff3d2d976238acd..157eff81e8cfcf9ceb4dd71437eb5ccdb167e109 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -268,10 +268,10 @@ test "Type.Struct" { const infoA = @typeInfo(A).Struct; try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); - try testing.expectEqual(u8, infoA.fields[0].field_type); + try testing.expectEqual(u8, infoA.fields[0].type); try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); try testing.expectEqualSlices(u8, "y", infoA.fields[1].name); - try testing.expectEqual(u32, infoA.fields[1].field_type); + try testing.expectEqual(u32, infoA.fields[1].type); try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value); try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls); try testing.expectEqual(@as(bool, false), infoA.is_tuple); @@ -286,10 +286,10 @@ test "Type.Struct" { const infoB = @typeInfo(B).Struct; try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); - try testing.expectEqual(u8, infoB.fields[0].field_type); + try testing.expectEqual(u8, infoB.fields[0].type); try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); try testing.expectEqualSlices(u8, "y", infoB.fields[1].name); - try testing.expectEqual(u32, infoB.fields[1].field_type); + try testing.expectEqual(u32, infoB.fields[1].type); try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoB.fields[1].default_value.?).*); try testing.expectEqual(@as(usize, 0), infoB.decls.len); try testing.expectEqual(@as(bool, false), infoB.is_tuple); @@ -298,10 +298,10 @@ test "Type.Struct" { const infoC = @typeInfo(C).Struct; try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); - try testing.expectEqual(u8, infoC.fields[0].field_type); + try testing.expectEqual(u8, infoC.fields[0].type); try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*); try testing.expectEqualSlices(u8, "y", infoC.fields[1].name); - try testing.expectEqual(u32, infoC.fields[1].field_type); + try testing.expectEqual(u32, infoC.fields[1].type); try testing.expectEqual(@as(u32, 5), @ptrCast(*align(1) const u32, infoC.fields[1].default_value.?).*); try testing.expectEqual(@as(usize, 0), infoC.decls.len); try testing.expectEqual(@as(bool, false), infoC.is_tuple); @@ -311,10 +311,10 @@ test "Type.Struct" { const infoD = @typeInfo(D).Struct; try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); - try testing.expectEqual(comptime_int, infoD.fields[0].field_type); + try testing.expectEqual(comptime_int, infoD.fields[0].type); try testing.expectEqual(@as(comptime_int, 3), @ptrCast(*const comptime_int, infoD.fields[0].default_value.?).*); try testing.expectEqualSlices(u8, "y", infoD.fields[1].name); - try testing.expectEqual(comptime_int, infoD.fields[1].field_type); + try testing.expectEqual(comptime_int, infoD.fields[1].type); try testing.expectEqual(@as(comptime_int, 5), @ptrCast(*const comptime_int, infoD.fields[1].default_value.?).*); try testing.expectEqual(@as(usize, 0), infoD.decls.len); try testing.expectEqual(@as(bool, false), infoD.is_tuple); @@ -324,10 +324,10 @@ test "Type.Struct" { const infoE = @typeInfo(E).Struct; try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); - try testing.expectEqual(comptime_int, infoE.fields[0].field_type); + try testing.expectEqual(comptime_int, infoE.fields[0].type); try testing.expectEqual(@as(comptime_int, 1), @ptrCast(*const comptime_int, infoE.fields[0].default_value.?).*); try testing.expectEqualSlices(u8, "1", infoE.fields[1].name); - try testing.expectEqual(comptime_int, infoE.fields[1].field_type); + try testing.expectEqual(comptime_int, infoE.fields[1].type); try testing.expectEqual(@as(comptime_int, 2), @ptrCast(*const comptime_int, infoE.fields[1].default_value.?).*); try testing.expectEqual(@as(usize, 0), infoE.decls.len); try testing.expectEqual(@as(bool, true), infoE.is_tuple); @@ -396,8 +396,8 @@ test "Type.Union" { .layout = .Extern, .tag_type = null, .fields = &.{ - .{ .name = "int", .field_type = i32, .alignment = @alignOf(f32) }, - .{ .name = "float", .field_type = f32, .alignment = @alignOf(f32) }, + .{ .name = "int", .type = i32, .alignment = @alignOf(f32) }, + .{ .name = "float", .type = f32, .alignment = @alignOf(f32) }, }, .decls = &.{}, }, @@ -412,8 +412,8 @@ test "Type.Union" { .layout = .Packed, .tag_type = null, .fields = &.{ - .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, - .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, + .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, + .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, }, .decls = &.{}, }, @@ -439,8 +439,8 @@ test "Type.Union" { .layout = .Auto, .tag_type = Tag, .fields = &.{ - .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, - .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, + .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, + .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, }, .decls = &.{}, }, @@ -470,7 +470,7 @@ test "Type.Union from Type.Enum" { .layout = .Auto, .tag_type = Tag, .fields = &.{ - .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) }, + .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, }, .decls = &.{}, }, @@ -487,7 +487,7 @@ test "Type.Union from regular enum" { .layout = .Auto, .tag_type = E, .fields = &.{ - .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) }, + .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, }, .decls = &.{}, }, @@ -537,7 +537,7 @@ test "reified struct field name from optional payload" { .layout = .Auto, .fields = &.{.{ .name = name, - .field_type = u8, + .type = u8, .default_value = null, .is_comptime = false, .alignment = 1, diff --git a/test/behavior/type_info.zig b/test/behavior/type_info.zig index fa9f21f6eb0dfd47f8814c7d1c21d52baf2eaef0..04656a2034a2a72c0c0f9bbbc59870328f360066 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -257,7 +257,7 @@ fn testUnion() !void { try expect(typeinfo_info.Union.layout == .Auto); try expect(typeinfo_info.Union.tag_type.? == TypeId); try expect(typeinfo_info.Union.fields.len == 24); - try expect(typeinfo_info.Union.fields[4].field_type == @TypeOf(@typeInfo(u8).Int)); + try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int)); try expect(typeinfo_info.Union.decls.len == 22); const TestNoTagUnion = union { @@ -271,7 +271,7 @@ fn testUnion() !void { try expect(notag_union_info.Union.layout == .Auto); try expect(notag_union_info.Union.fields.len == 2); try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); - try expect(notag_union_info.Union.fields[1].field_type == u32); + try expect(notag_union_info.Union.fields[1].type == u32); try expect(notag_union_info.Union.fields[1].alignment == @alignOf(u32)); const TestExternUnion = extern union { @@ -281,7 +281,7 @@ fn testUnion() !void { const extern_union_info = @typeInfo(TestExternUnion); try expect(extern_union_info.Union.layout == .Extern); try expect(extern_union_info.Union.tag_type == null); - try expect(extern_union_info.Union.fields[0].field_type == *anyopaque); + try expect(extern_union_info.Union.fields[0].type == *anyopaque); } test "type info: struct info" { @@ -319,7 +319,7 @@ fn testPackedStruct() !void { try expect(struct_info.Struct.backing_integer == u128); try expect(struct_info.Struct.fields.len == 4); try expect(struct_info.Struct.fields[0].alignment == 0); - try expect(struct_info.Struct.fields[2].field_type == f32); + try expect(struct_info.Struct.fields[2].type == f32); try expect(struct_info.Struct.fields[2].default_value == null); try expect(@ptrCast(*align(1) const u32, struct_info.Struct.fields[3].default_value.?).* == 4); try expect(struct_info.Struct.fields[3].alignment == 0); diff --git a/test/behavior/union.zig b/test/behavior/union.zig index b6ec305eacda009b125a43e28b80dc0d501ee8f9..4200311e2cfca1d9b43f45581772bc3c19b4d06e 100644 --- a/test/behavior/union.zig +++ b/test/behavior/union.zig @@ -454,7 +454,7 @@ test "global union with single field is correctly initialized" { if (builtin.zig_backend == .stage2_sparc64) return error.SkipZigTest; // TODO glbl = Foo1{ - .f = @typeInfo(Foo1).Union.fields[0].field_type{ .x = 123 }, + .f = @typeInfo(Foo1).Union.fields[0].type{ .x = 123 }, }; try expect(glbl.f.x == 123); } diff --git a/test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig b/test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig index abaff066add9e5552e46efce683230de7f68f0cc..7951b4dec0abc961c6226086a2f06ca429305c74 100644 --- a/test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig +++ b/test/cases/compile_errors/comptime_store_in_comptime_switch_in_runtime_if.zig @@ -9,7 +9,7 @@ pub export fn entry() void { const info = @typeInfo(Widget).Union; inline for (info.fields) |field| { if (foo()) { - switch (field.field_type) { + switch (field.type) { u0 => a = 2, else => unreachable, } diff --git a/test/cases/compile_errors/dereference_anyopaque.zig b/test/cases/compile_errors/dereference_anyopaque.zig index df58a110854de980559b16c5f2766739e53bd981..6dbbdfe1e2016aaa96022362ffa7b1910ad6b34e 100644 --- a/test/cases/compile_errors/dereference_anyopaque.zig +++ b/test/cases/compile_errors/dereference_anyopaque.zig @@ -16,7 +16,7 @@ fn parseFree(comptime T: type, value: T, allocator: std.mem.Allocator) void { .Struct => |structInfo| { inline for (structInfo.fields) |field| { if (!field.is_comptime) - parseFree(field.field_type, undefined, allocator); + parseFree(field.type, undefined, allocator); } }, .Pointer => |ptrInfo| { diff --git a/test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig b/test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig index 8c17e9100b148bacb7ce97f6e375fc2dd0bb12d0..9f0fb6773d40600f2a22988df23a5d954de4da3c 100644 --- a/test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig +++ b/test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig @@ -1,6 +1,6 @@ export fn entry() void { _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ - .{ .name = "one", .field_type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, + .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, }, .decls = &.{}, .is_tuple = false } }); } diff --git a/test/cases/compile_errors/reify_struct.zig b/test/cases/compile_errors/reify_struct.zig index 1c6001ced6ab35c7160b6f33ea41a167dad8892c..42b8e42af5c792c629a5617e8a719ab94f88030b 100644 --- a/test/cases/compile_errors/reify_struct.zig +++ b/test/cases/compile_errors/reify_struct.zig @@ -3,7 +3,7 @@ comptime { .layout = .Auto, .fields = &.{.{ .name = "foo", - .field_type = u32, + .type = u32, .default_value = null, .is_comptime = false, .alignment = 4, @@ -17,7 +17,7 @@ comptime { .layout = .Auto, .fields = &.{.{ .name = "3", - .field_type = u32, + .type = u32, .default_value = null, .is_comptime = false, .alignment = 4, @@ -31,7 +31,7 @@ comptime { .layout = .Auto, .fields = &.{.{ .name = "0", - .field_type = u32, + .type = u32, .default_value = null, .is_comptime = true, .alignment = 4, @@ -45,7 +45,7 @@ comptime { .layout = .Extern, .fields = &.{.{ .name = "0", - .field_type = u32, + .type = u32, .default_value = null, .is_comptime = true, .alignment = 4, @@ -59,7 +59,7 @@ comptime { .layout = .Packed, .fields = &.{.{ .name = "0", - .field_type = u32, + .type = u32, .default_value = null, .is_comptime = true, .alignment = 4, diff --git a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig index ccd00004942cd995f9ad1eb19a1e9de5f6d6c24d..293e5c62e393bdb09886d8377df985302ab5c87d 100644 --- a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig +++ b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig @@ -16,8 +16,8 @@ const Tagged = @Type(.{ .layout = .Auto, .tag_type = Tag, .fields = &.{ - .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, - .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, + .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, + .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, }, .decls = &.{}, }, diff --git a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig index 9d6170b9d07c9be69eed5608db8f3969b88ee94e..bb26230f22675c6d3700a71828d421616f28282b 100644 --- a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig +++ b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig @@ -15,9 +15,9 @@ const Tagged = @Type(.{ .layout = .Auto, .tag_type = Tag, .fields = &.{ - .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) }, - .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) }, - .{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) }, + .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, + .{ .name = "unsigned", .type = u32, .alignment = @alignOf(u32) }, + .{ .name = "arst", .type = f32, .alignment = @alignOf(f32) }, }, .decls = &.{}, }, diff --git a/test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig b/test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig index aba11031a4b323fe3ac10ea08e012ed1ab1aeafa..df709348712b312369ec0132489195b7f83694f4 100644 --- a/test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig +++ b/test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig @@ -3,7 +3,7 @@ const Untagged = @Type(.{ .layout = .Auto, .tag_type = null, .fields = &.{ - .{ .name = "foo", .field_type = opaque {}, .alignment = 1 }, + .{ .name = "foo", .type = opaque {}, .alignment = 1 }, }, .decls = &.{}, }, @@ -17,4 +17,4 @@ export fn entry() usize { // target=native // // :1:18: error: opaque types have unknown size and therefore cannot be directly embedded in unions -// :6:45: note: opaque declared here +// :6:39: note: opaque declared here -- 2.54.0