diff --git a/lib/compiler/aro/aro/Attribute.zig b/lib/compiler/aro/aro/Attribute.zig index f9cccb0142..2f99f48c0d 100644 --- a/lib/compiler/aro/aro/Attribute.zig +++ b/lib/compiler/aro/aro/Attribute.zig @@ -653,7 +653,7 @@ pub const Arguments = blk: { break :blk @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = null, .fields = &union_fields, .decls = &.{}, diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 3339a5337e..6ebe955291 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -334,9 +334,9 @@ pub const Type = union(enum) { /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const ContainerLayout = enum(u2) { - Auto, - Extern, - Packed, + auto, + @"extern", + @"packed", }; /// This data structure is used by the Zig language code generation and @@ -353,7 +353,7 @@ pub const Type = union(enum) { /// therefore must be kept in sync with the compiler implementation. pub const Struct = struct { layout: ContainerLayout, - /// Only valid if layout is .Packed + /// Only valid if layout is .@"packed" backing_integer: ?type = null, fields: []const StructField, decls: []const Declaration, diff --git a/lib/std/enums.zig b/lib/std/enums.zig index 0da3fb1871..40a2566cbe 100644 --- a/lib/std/enums.zig +++ b/lib/std/enums.zig @@ -22,7 +22,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def }}; } return @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = fields, .decls = &.{}, .is_tuple = false, diff --git a/lib/std/io.zig b/lib/std/io.zig index 75693b8b1e..64560c6fe3 100644 --- a/lib/std/io.zig +++ b/lib/std/io.zig @@ -688,7 +688,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { }; } return @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &struct_fields, .decls = &.{}, .is_tuple = false, diff --git a/lib/std/io/Reader.zig b/lib/std/io/Reader.zig index 9569d8d565..a769fe4c04 100644 --- a/lib/std/io/Reader.zig +++ b/lib/std/io/Reader.zig @@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool { pub fn readStruct(self: Self, comptime T: type) anyerror!T { // Only extern and packed structs have defined in-memory layout. - comptime assert(@typeInfo(T).Struct.layout != .Auto); + comptime assert(@typeInfo(T).Struct.layout != .auto); var res: [1]T = undefined; try self.readNoEof(mem.sliceAsBytes(res[0..])); return res[0]; diff --git a/lib/std/io/Writer.zig b/lib/std/io/Writer.zig index 95a7bd5d6a..dfcae48b1e 100644 --- a/lib/std/io/Writer.zig +++ b/lib/std/io/Writer.zig @@ -55,7 +55,7 @@ pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.built pub fn writeStruct(self: Self, value: anytype) anyerror!void { // Only extern and packed structs have defined in-memory layout. - comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .Auto); + comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto); return self.writeAll(mem.asBytes(&value)); } diff --git a/lib/std/mem.zig b/lib/std/mem.zig index fc0c226894..b3e3cce593 100644 --- a/lib/std/mem.zig +++ b/lib/std/mem.zig @@ -238,7 +238,7 @@ pub fn zeroes(comptime T: type) T { }, .Struct => |struct_info| { if (@sizeOf(T) == 0) return undefined; - if (struct_info.layout == .Extern) { + if (struct_info.layout == .@"extern") { var item: T = undefined; @memset(asBytes(&item), 0); return item; @@ -284,7 +284,7 @@ pub fn zeroes(comptime T: type) T { return @splat(zeroes(info.child)); }, .Union => |info| { - if (info.layout == .Extern) { + if (info.layout == .@"extern") { var item: T = undefined; @memset(asBytes(&item), 0); return item; @@ -429,7 +429,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { } } - var value: T = if (struct_info.layout == .Extern) zeroes(T) else undefined; + var value: T = if (struct_info.layout == .@"extern") zeroes(T) else undefined; inline for (struct_info.fields, 0..) |field, i| { if (field.is_comptime) { diff --git a/lib/std/meta.zig b/lib/std/meta.zig index 66388aebf6..f7b418d71d 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -269,12 +269,12 @@ test containerLayout { a: u8, }; - try testing.expect(containerLayout(S1) == .Auto); - try testing.expect(containerLayout(S2) == .Packed); - try testing.expect(containerLayout(S3) == .Extern); - try testing.expect(containerLayout(U1) == .Auto); - try testing.expect(containerLayout(U2) == .Packed); - try testing.expect(containerLayout(U3) == .Extern); + try testing.expect(containerLayout(S1) == .auto); + try testing.expect(containerLayout(S2) == .@"packed"); + try testing.expect(containerLayout(S3) == .@"extern"); + try testing.expect(containerLayout(U1) == .auto); + try testing.expect(containerLayout(U2) == .@"packed"); + try testing.expect(containerLayout(U3) == .@"extern"); } /// Instead of this function, prefer to use e.g. `@typeInfo(foo).Struct.decls` @@ -1025,7 +1025,7 @@ fn CreateUniqueTuple(comptime N: comptime_int, comptime types: [N]type) type { return @Type(.{ .Struct = .{ .is_tuple = true, - .layout = .Auto, + .layout = .auto, .decls = &.{}, .fields = &tuple_fields, }, diff --git a/lib/std/meta/trailer_flags.zig b/lib/std/meta/trailer_flags.zig index ab046f9a40..396eaa8f71 100644 --- a/lib/std/meta/trailer_flags.zig +++ b/lib/std/meta/trailer_flags.zig @@ -32,7 +32,7 @@ pub fn TrailerFlags(comptime Fields: type) type { } break :blk @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &fields, .decls = &.{}, .is_tuple = false, diff --git a/lib/std/multi_array_list.zig b/lib/std/multi_array_list.zig index 8dfaca34ba..d7327f8bee 100644 --- a/lib/std/multi_array_list.zig +++ b/lib/std/multi_array_list.zig @@ -558,7 +558,7 @@ pub fn MultiArrayList(comptime T: type) type { .alignment = fields[i].alignment, }; break :entry @Type(.{ .Struct = .{ - .layout = .Extern, + .layout = .@"extern", .fields = &entry_fields, .decls = &.{}, .is_tuple = false, diff --git a/lib/std/zig/AstGen.zig b/lib/std/zig/AstGen.zig index 8535b16806..1e65453f25 100644 --- a/lib/std/zig/AstGen.zig +++ b/lib/std/zig/AstGen.zig @@ -175,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { &gen_scope.base, 0, tree.containerDeclRoot(), - .Auto, + .auto, 0, )) |struct_decl_ref| { assert(struct_decl_ref.toIndex().? == .main_struct_inst); @@ -4907,7 +4907,7 @@ fn structDeclInner( var backing_int_body_len: usize = 0; const backing_int_ref: Zir.Inst.Ref = blk: { if (backing_int_node != 0) { - if (layout != .Packed) { + if (layout != .@"packed") { return astgen.failNode(backing_int_node, "non-packed struct does not support backing integer type", .{}); } else { const backing_int_ref = try typeExpr(&block_scope, &namespace.base, backing_int_node); @@ -4958,9 +4958,9 @@ fn structDeclInner( } else false; if (is_tuple) switch (layout) { - .Auto => {}, - .Extern => return astgen.failNode(node, "extern tuples are not supported", .{}), - .Packed => return astgen.failNode(node, "packed tuples are not supported", .{}), + .auto => {}, + .@"extern" => return astgen.failNode(node, "extern tuples are not supported", .{}), + .@"packed" => return astgen.failNode(node, "packed tuples are not supported", .{}), }; if (is_tuple) for (container_decl.ast.members) |member_node| { @@ -5055,9 +5055,9 @@ fn structDeclInner( if (is_comptime) { switch (layout) { - .Packed => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}), - .Extern => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}), - .Auto => any_comptime_fields = true, + .@"packed" => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}), + .@"extern" => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}), + .auto => any_comptime_fields = true, } } else { known_non_opv = known_non_opv or @@ -5082,7 +5082,7 @@ fn structDeclInner( } if (have_align) { - if (layout == .Packed) { + if (layout == .@"packed") { try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{}); } any_aligned_fields = true; @@ -5229,12 +5229,11 @@ fn unionDeclInner( const decl_count = try astgen.scanDecls(&namespace, members); const field_count: u32 = @intCast(members.len - decl_count); - if (layout != .Auto and (auto_enum_tok != null or arg_node != 0)) { - const layout_str = if (layout == .Extern) "extern" else "packed"; + if (layout != .auto and (auto_enum_tok != null or arg_node != 0)) { if (arg_node != 0) { - return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{layout_str}); + return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{@tagName(layout)}); } else { - return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{layout_str}); + return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{@tagName(layout)}); } } @@ -5429,21 +5428,21 @@ fn containerDecl( switch (token_tags[container_decl.ast.main_token]) { .keyword_struct => { - const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { - .keyword_packed => std.builtin.Type.ContainerLayout.Packed, - .keyword_extern => std.builtin.Type.ContainerLayout.Extern, + const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) { + .keyword_packed => .@"packed", + .keyword_extern => .@"extern", else => unreachable, - } else std.builtin.Type.ContainerLayout.Auto; + } else .auto; const result = try structDeclInner(gz, scope, node, container_decl, layout, container_decl.ast.arg); return rvalue(gz, ri, result, node); }, .keyword_union => { - const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) { - .keyword_packed => std.builtin.Type.ContainerLayout.Packed, - .keyword_extern => std.builtin.Type.ContainerLayout.Extern, + const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) { + .keyword_packed => .@"packed", + .keyword_extern => .@"extern", else => unreachable, - } else std.builtin.Type.ContainerLayout.Auto; + } else .auto; const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, container_decl.ast.enum_token); return rvalue(gz, ri, result, node); diff --git a/lib/std/zig/Server.zig b/lib/std/zig/Server.zig index 915450c50a..d112adf45f 100644 --- a/lib/std/zig/Server.zig +++ b/lib/std/zig/Server.zig @@ -250,18 +250,18 @@ fn bswap(x: anytype) @TypeOf(x) { .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), .Int => return @byteSwap(x), .Struct => |info| switch (info.layout) { - .Extern => { + .@"extern" => { var result: T = undefined; inline for (info.fields) |field| { @field(result, field.name) = bswap(@field(x, field.name)); } return result; }, - .Packed => { + .@"packed" => { const I = info.backing_integer.?; return @as(T, @bitCast(@byteSwap(@as(I, @bitCast(x))))); }, - .Auto => @compileError("auto layout struct"), + .auto => @compileError("auto layout struct"), }, else => @compileError("bswap on type " ++ @typeName(T)), } diff --git a/src/InternPool.zig b/src/InternPool.zig index 6a82abedce..64da7fc043 100644 --- a/src/InternPool.zig +++ b/src/InternPool.zig @@ -2025,15 +2025,15 @@ pub const LoadedStructType = struct { /// complicated logic. pub fn knownNonOpv(s: @This(), ip: *InternPool) bool { return switch (s.layout) { - .Packed => false, - .Auto, .Extern => s.flagsPtr(ip).known_non_opv, + .@"packed" => false, + .auto, .@"extern" => s.flagsPtr(ip).known_non_opv, }; } /// The returned pointer expires with any addition to the `InternPool`. /// Asserts the struct is not packed. pub fn flagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStruct.Flags { - assert(self.layout != .Packed); + assert(self.layout != .@"packed"); const flags_field_index = std.meta.fieldIndex(Tag.TypeStruct, "flags").?; return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]); } @@ -2041,13 +2041,13 @@ pub const LoadedStructType = struct { /// The returned pointer expires with any addition to the `InternPool`. /// Asserts that the struct is packed. pub fn packedFlagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStructPacked.Flags { - assert(self.layout == .Packed); + assert(self.layout == .@"packed"); const flags_field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?; return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]); } pub fn assumeRuntimeBitsIfFieldTypesWip(s: @This(), ip: *InternPool) bool { - if (s.layout == .Packed) return false; + if (s.layout == .@"packed") return false; const flags_ptr = s.flagsPtr(ip); if (flags_ptr.field_types_wip) { flags_ptr.assumed_runtime_bits = true; @@ -2057,7 +2057,7 @@ pub const LoadedStructType = struct { } pub fn setTypesWip(s: @This(), ip: *InternPool) bool { - if (s.layout == .Packed) return false; + if (s.layout == .@"packed") return false; const flags_ptr = s.flagsPtr(ip); if (flags_ptr.field_types_wip) return true; flags_ptr.field_types_wip = true; @@ -2065,12 +2065,12 @@ pub const LoadedStructType = struct { } pub fn clearTypesWip(s: @This(), ip: *InternPool) void { - if (s.layout == .Packed) return; + if (s.layout == .@"packed") return; s.flagsPtr(ip).field_types_wip = false; } pub fn setLayoutWip(s: @This(), ip: *InternPool) bool { - if (s.layout == .Packed) return false; + if (s.layout == .@"packed") return false; const flags_ptr = s.flagsPtr(ip); if (flags_ptr.layout_wip) return true; flags_ptr.layout_wip = true; @@ -2078,12 +2078,12 @@ pub const LoadedStructType = struct { } pub fn clearLayoutWip(s: @This(), ip: *InternPool) void { - if (s.layout == .Packed) return; + if (s.layout == .@"packed") return; s.flagsPtr(ip).layout_wip = false; } pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool { - if (s.layout == .Packed) return false; + if (s.layout == .@"packed") return false; const flags_ptr = s.flagsPtr(ip); if (flags_ptr.alignment_wip) return true; flags_ptr.alignment_wip = true; @@ -2091,19 +2091,19 @@ pub const LoadedStructType = struct { } pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void { - if (s.layout == .Packed) return; + if (s.layout == .@"packed") return; s.flagsPtr(ip).alignment_wip = false; } pub fn setInitsWip(s: @This(), ip: *InternPool) bool { switch (s.layout) { - .Packed => { + .@"packed" => { const flag = &s.packedFlagsPtr(ip).field_inits_wip; if (flag.*) return true; flag.* = true; return false; }, - .Auto, .Extern => { + .auto, .@"extern" => { const flag = &s.flagsPtr(ip).field_inits_wip; if (flag.*) return true; flag.* = true; @@ -2114,13 +2114,13 @@ pub const LoadedStructType = struct { pub fn clearInitsWip(s: @This(), ip: *InternPool) void { switch (s.layout) { - .Packed => s.packedFlagsPtr(ip).field_inits_wip = false, - .Auto, .Extern => s.flagsPtr(ip).field_inits_wip = false, + .@"packed" => s.packedFlagsPtr(ip).field_inits_wip = false, + .auto, .@"extern" => s.flagsPtr(ip).field_inits_wip = false, } } pub fn setFullyResolved(s: @This(), ip: *InternPool) bool { - if (s.layout == .Packed) return true; + if (s.layout == .@"packed") return true; const flags_ptr = s.flagsPtr(ip); if (flags_ptr.fully_resolved) return true; flags_ptr.fully_resolved = true; @@ -2134,7 +2134,7 @@ pub const LoadedStructType = struct { /// The returned pointer expires with any addition to the `InternPool`. /// Asserts the struct is not packed. pub fn size(self: @This(), ip: *InternPool) *u32 { - assert(self.layout != .Packed); + assert(self.layout != .@"packed"); const size_field_index = std.meta.fieldIndex(Tag.TypeStruct, "size").?; return @ptrCast(&ip.extra.items[self.extra_index + size_field_index]); } @@ -2144,14 +2144,14 @@ pub const LoadedStructType = struct { /// set to `none` until the layout is resolved. /// Asserts the struct is packed. pub fn backingIntType(s: @This(), ip: *const InternPool) *Index { - assert(s.layout == .Packed); + assert(s.layout == .@"packed"); const field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "backing_int_ty").?; return @ptrCast(&ip.extra.items[s.extra_index + field_index]); } /// Asserts the struct is not packed. pub fn setZirIndex(s: @This(), ip: *InternPool, new_zir_index: TrackedInst.Index.Optional) void { - assert(s.layout != .Packed); + assert(s.layout != .@"packed"); const field_index = std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?; ip.extra.items[s.extra_index + field_index] = @intFromEnum(new_zir_index); } @@ -2163,31 +2163,31 @@ pub const LoadedStructType = struct { pub fn haveFieldInits(s: @This(), ip: *const InternPool) bool { return switch (s.layout) { - .Packed => s.packedFlagsPtr(ip).inits_resolved, - .Auto, .Extern => s.flagsPtr(ip).inits_resolved, + .@"packed" => s.packedFlagsPtr(ip).inits_resolved, + .auto, .@"extern" => s.flagsPtr(ip).inits_resolved, }; } pub fn setHaveFieldInits(s: @This(), ip: *InternPool) void { switch (s.layout) { - .Packed => s.packedFlagsPtr(ip).inits_resolved = true, - .Auto, .Extern => s.flagsPtr(ip).inits_resolved = true, + .@"packed" => s.packedFlagsPtr(ip).inits_resolved = true, + .auto, .@"extern" => s.flagsPtr(ip).inits_resolved = true, } } pub fn haveLayout(s: @This(), ip: *InternPool) bool { return switch (s.layout) { - .Packed => s.backingIntType(ip).* != .none, - .Auto, .Extern => s.flagsPtr(ip).layout_resolved, + .@"packed" => s.backingIntType(ip).* != .none, + .auto, .@"extern" => s.flagsPtr(ip).layout_resolved, }; } pub fn isTuple(s: @This(), ip: *InternPool) bool { - return s.layout != .Packed and s.flagsPtr(ip).is_tuple; + return s.layout != .@"packed" and s.flagsPtr(ip).is_tuple; } pub fn hasReorderedFields(s: @This()) bool { - return s.layout == .Auto; + return s.layout == .auto; } pub const RuntimeOrderIterator = struct { @@ -2221,7 +2221,7 @@ pub const LoadedStructType = struct { /// May or may not include zero-bit fields. /// Asserts the struct is not packed. pub fn iterateRuntimeOrder(s: @This(), ip: *InternPool) RuntimeOrderIterator { - assert(s.layout != .Packed); + assert(s.layout != .@"packed"); return .{ .ip = ip, .field_index = 0, @@ -2239,7 +2239,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { .decl = .none, .namespace = .none, .zir_index = .none, - .layout = .Auto, + .layout = .auto, .field_names = .{ .start = 0, .len = 0 }, .field_types = .{ .start = 0, .len = 0 }, .field_inits = .{ .start = 0, .len = 0 }, @@ -2314,7 +2314,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { .decl = extra.data.decl.toOptional(), .namespace = namespace, .zir_index = extra.data.zir_index.toOptional(), - .layout = if (extra.data.flags.is_extern) .Extern else .Auto, + .layout = if (extra.data.flags.is_extern) .@"extern" else .auto, .field_names = names, .field_types = field_types, .field_inits = inits, @@ -2367,7 +2367,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { .decl = extra.data.decl.toOptional(), .namespace = extra.data.namespace, .zir_index = extra.data.zir_index.toOptional(), - .layout = .Packed, + .layout = .@"packed", .field_names = field_names, .field_types = field_types, .field_inits = field_inits, @@ -4455,7 +4455,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { } else .{ .start = 0, .len = 0 } }, } }; } }, - .type_struct_anon => .{ .anon_struct_type = extraTypeStructAnon(ip, data) }, .type_tuple_anon => .{ .anon_struct_type = extraTypeTupleAnon(ip, data) }, .type_union => .{ .union_type = ns: { @@ -6009,9 +6008,9 @@ pub fn getStructType( }; const is_extern = switch (ini.layout) { - .Auto => false, - .Extern => true, - .Packed => { + .auto => false, + .@"extern" => true, + .@"packed" => { try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.TypeStructPacked).Struct.fields.len + // TODO: fmt bug // zig fmt: off @@ -6140,7 +6139,7 @@ pub fn getStructType( if (ini.any_comptime_fields) { ip.extra.appendNTimesAssumeCapacity(0, comptime_elements_len); } - if (ini.layout == .Auto) { + if (ini.layout == .auto) { ip.extra.appendNTimesAssumeCapacity(@intFromEnum(LoadedStructType.RuntimeOrder.unresolved), ini.fields_len); } ip.extra.appendNTimesAssumeCapacity(std.math.maxInt(u32), ini.fields_len); diff --git a/src/Module.zig b/src/Module.zig index 4ad760063b..01a4ed95b2 100644 --- a/src/Module.zig +++ b/src/Module.zig @@ -3310,7 +3310,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); assert(!small.has_captures_len); assert(!small.has_backing_int); - assert(small.layout == .Auto); + assert(small.layout == .auto); var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; const fields_len = if (small.has_fields_len) blk: { const fields_len = file.zir.extra[extra_index]; @@ -3327,7 +3327,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa const tracked_inst = try ip.trackZir(gpa, file, .main_struct_inst); const wip_ty = switch (try ip.getStructType(gpa, .{ - .layout = .Auto, + .layout = .auto, .fields_len = fields_len, .known_non_opv = small.known_non_opv, .requires_comptime = if (small.known_comptime_only) .yes else .unknown, @@ -5969,7 +5969,7 @@ pub fn typeToStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType { pub fn typeToPackedStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType { const s = mod.typeToStruct(ty) orelse return null; - if (s.layout != .Packed) return null; + if (s.layout != .@"packed") return null; return s; } @@ -6185,18 +6185,18 @@ pub fn structFieldAlignment( field_ty: Type, layout: std.builtin.Type.ContainerLayout, ) Alignment { - assert(layout != .Packed); + assert(layout != .@"packed"); if (explicit_alignment != .none) return explicit_alignment; switch (layout) { - .Packed => unreachable, - .Auto => { + .@"packed" => unreachable, + .auto => { if (mod.getTarget().ofmt == .c) { return structFieldAlignmentExtern(mod, field_ty); } else { return field_ty.abiAlignment(mod); } }, - .Extern => return structFieldAlignmentExtern(mod, field_ty), + .@"extern" => return structFieldAlignmentExtern(mod, field_ty), } } @@ -6224,7 +6224,7 @@ pub fn structPackedFieldBitOffset( field_index: u32, ) u16 { const ip = &mod.intern_pool; - assert(struct_type.layout == .Packed); + assert(struct_type.layout == .@"packed"); assert(struct_type.haveLayout(ip)); var bit_sum: u64 = 0; for (0..struct_type.field_types.len) |i| { diff --git a/src/Sema.zig b/src/Sema.zig index 1ac6d28bf0..91b40b8fed 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -3236,7 +3236,7 @@ fn zirUnionDecl( .status = .none, .runtime_tag = if (small.has_tag_type or small.auto_enum_tag) .tagged - else if (small.layout != .Auto) + else if (small.layout != .auto) .none else switch (block.wantSafety()) { true => .safety, @@ -10380,7 +10380,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air }; return sema.failWithOwnedErrorMsg(block, msg); }, - .Struct, .Union => if (dest_ty.containerLayout(mod) == .Auto) { + .Struct, .Union => if (dest_ty.containerLayout(mod) == .auto) { const container = switch (dest_ty.zigTypeTag(mod)) { .Struct => "struct", .Union => "union", @@ -10443,7 +10443,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air }; return sema.failWithOwnedErrorMsg(block, msg); }, - .Struct, .Union => if (operand_ty.containerLayout(mod) == .Auto) { + .Struct, .Union => if (operand_ty.containerLayout(mod) == .auto) { const container = switch (operand_ty.zigTypeTag(mod)) { .Struct => "struct", .Union => "union", @@ -18131,8 +18131,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai }; const alignment = switch (layout) { - .Auto, .Extern => try sema.unionFieldAlignment(union_obj, @intCast(i)), - .Packed => .none, + .auto, .@"extern" => try sema.unionFieldAlignment(union_obj, @intCast(i)), + .@"packed" => .none, }; const field_ty = union_obj.field_types.get(ip)[i]; @@ -18350,7 +18350,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const opt_default_val = if (field_init == .none) null else Value.fromInterned(field_init); const default_val_ptr = try sema.optRefValue(opt_default_val); const alignment = switch (struct_type.layout) { - .Packed => .none, + .@"packed" => .none, else => try sema.structFieldAlignment( struct_type.fieldAlign(ip, i), field_ty, @@ -19906,7 +19906,7 @@ fn zirStructInit( var field_i: u32 = 0; var extra_index = extra.end; - const is_packed = resolved_ty.containerLayout(mod) == .Packed; + const is_packed = resolved_ty.containerLayout(mod) == .@"packed"; while (field_i < extra.data.fields_len) : (field_i += 1) { const item = sema.code.extraData(Zir.Inst.StructInit.Item, extra_index); extra_index = item.end; @@ -21302,7 +21302,7 @@ fn zirReify( return sema.fail(block, src, "reified structs must have no decls", .{}); } - if (layout != .Packed and !backing_integer_val.isNull(mod)) { + if (layout != .@"packed" and !backing_integer_val.isNull(mod)) { return sema.fail(block, src, "non-packed struct does not support backing integer type", .{}); } @@ -21665,7 +21665,7 @@ fn reifyUnion( .status = .none, .runtime_tag = if (opt_tag_type_val.optionalValue(mod) != null) .tagged - else if (layout != .Auto) + else if (layout != .auto) .none else switch (block.wantSafety()) { true => .safety, @@ -21804,7 +21804,7 @@ fn reifyUnion( break :msg msg; }); } - if (layout == .Extern and !try sema.validateExternType(field_ty, .union_field)) { + if (layout == .@"extern" and !try sema.validateExternType(field_ty, .union_field)) { return sema.failWithOwnedErrorMsg(block, msg: { const msg = try sema.errMsg(block, src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)}); errdefer msg.destroy(gpa); @@ -21815,7 +21815,7 @@ fn reifyUnion( try sema.addDeclaredHereNote(msg, field_ty); break :msg msg; }); - } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { + } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { return sema.failWithOwnedErrorMsg(block, msg: { const msg = try sema.errMsg(block, src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)}); errdefer msg.destroy(gpa); @@ -21938,9 +21938,9 @@ fn reifyStruct( errdefer wip_ty.cancel(ip); if (is_tuple) switch (layout) { - .Extern => return sema.fail(block, src, "extern tuples are not supported", .{}), - .Packed => return sema.fail(block, src, "packed tuples are not supported", .{}), - .Auto => {}, + .@"extern" => return sema.fail(block, src, "extern tuples are not supported", .{}), + .@"packed" => return sema.fail(block, src, "packed tuples are not supported", .{}), + .auto => {}, }; const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ @@ -21990,11 +21990,11 @@ fn reifyStruct( const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema); if (byte_align == 0) { - if (layout != .Packed) { + if (layout != .@"packed") { struct_type.field_aligns.get(ip)[field_idx] = .none; } } else { - if (layout == .Packed) return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); + if (layout == .@"packed") return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{}); if (!math.isPowerOfTwo(byte_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); struct_type.field_aligns.get(ip)[field_idx] = Alignment.fromNonzeroByteUnits(byte_align); } @@ -22004,9 +22004,9 @@ fn reifyStruct( if (field_is_comptime) { assert(any_comptime_fields); switch (layout) { - .Extern => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}), - .Packed => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}), - .Auto => struct_type.setFieldComptime(ip, field_idx), + .@"extern" => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}), + .@"packed" => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}), + .auto => struct_type.setFieldComptime(ip, field_idx), } } @@ -22047,7 +22047,7 @@ fn reifyStruct( break :msg msg; }); } - if (layout == .Extern and !try sema.validateExternType(field_ty, .struct_field)) { + if (layout == .@"extern" and !try sema.validateExternType(field_ty, .struct_field)) { return sema.failWithOwnedErrorMsg(block, msg: { const msg = try sema.errMsg(block, src, "extern structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); errdefer msg.destroy(gpa); @@ -22058,7 +22058,7 @@ fn reifyStruct( try sema.addDeclaredHereNote(msg, field_ty); break :msg msg; }); - } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { + } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { return sema.failWithOwnedErrorMsg(block, msg: { const msg = try sema.errMsg(block, src, "packed structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); errdefer msg.destroy(gpa); @@ -22072,7 +22072,7 @@ fn reifyStruct( } } - if (layout == .Packed) { + if (layout == .@"packed") { var fields_bit_sum: u64 = 0; for (0..struct_type.field_types.len) |field_idx| { const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[field_idx]); @@ -23311,7 +23311,7 @@ fn bitOffsetOf(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!u6 } switch (ty.containerLayout(mod)) { - .Packed => { + .@"packed" => { var bit_sum: u64 = 0; const struct_type = ip.loadStructType(ty.toIntern()); for (0..struct_type.field_types.len) |i| { @@ -24710,7 +24710,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr }, }; - if (parent_ty.containerLayout(mod) == .Packed) { + if (parent_ty.containerLayout(mod) == .@"packed") { return sema.fail(block, src, "TODO handle packed structs/unions with @fieldParentPtr", .{}); } else { ptr_ty_data.flags.alignment = blk: { @@ -26328,15 +26328,15 @@ fn validateExternType( return sema.validateExternType(ty.intTagType(mod), position); }, .Struct, .Union => switch (ty.containerLayout(mod)) { - .Extern => return true, - .Packed => { + .@"extern" => return true, + .@"packed" => { const bit_size = try ty.bitSizeAdvanced(mod, sema); switch (bit_size) { 0, 8, 16, 32, 64, 128 => return true, else => return false, } }, - .Auto => return !(try sema.typeHasRuntimeBits(ty)), + .auto => return !(try sema.typeHasRuntimeBits(ty)), }, .Array => { if (position == .ret_ty or position == .param_ty) return false; @@ -26456,7 +26456,7 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool { .Enum, => return true, .Pointer => return !ty.isSlice(mod) and !try sema.typeRequiresComptime(ty), - .Struct, .Union => return ty.containerLayout(mod) == .Packed, + .Struct, .Union => return ty.containerLayout(mod) == .@"packed", } } @@ -27596,7 +27596,7 @@ fn structFieldPtrByIndex( else try sema.typeAbiAlignment(Type.fromInterned(struct_ptr_ty_info.child)); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { comptime assert(Type.packed_struct_layout_version == 2); var running_bits: u16 = 0; @@ -27641,7 +27641,7 @@ fn structFieldPtrByIndex( ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; } } - } else if (struct_type.layout == .Extern) { + } else if (struct_type.layout == .@"extern") { // For extern structs, field alignment might be bigger than type's // natural alignment. Eg, in `extern struct { x: u32, y: u16 }` the // second field is aligned as u32. @@ -27846,7 +27846,7 @@ fn unionFieldPtr( .is_const = union_ptr_info.flags.is_const, .is_volatile = union_ptr_info.flags.is_volatile, .address_space = union_ptr_info.flags.address_space, - .alignment = if (union_obj.getLayout(ip) == .Auto) blk: { + .alignment = if (union_obj.getLayout(ip) == .auto) blk: { const union_align = if (union_ptr_info.flags.alignment != .none) union_ptr_info.flags.alignment else @@ -27875,7 +27875,7 @@ fn unionFieldPtr( if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: { switch (union_obj.getLayout(ip)) { - .Auto => if (!initializing) { + .auto => if (!initializing) { const union_val = (try sema.pointerDeref(block, src, union_ptr_val, union_ptr_ty)) orelse break :ct; if (union_val.isUndef(mod)) { @@ -27899,7 +27899,7 @@ fn unionFieldPtr( return sema.failWithOwnedErrorMsg(block, msg); } }, - .Packed, .Extern => {}, + .@"packed", .@"extern" => {}, } return Air.internedToRef((try mod.intern(.{ .ptr = .{ .ty = ptr_field_ty.toIntern(), @@ -27911,7 +27911,7 @@ fn unionFieldPtr( } try sema.requireRuntimeBlock(block, src, null); - if (!initializing and union_obj.getLayout(ip) == .Auto and block.wantSafety() and + if (!initializing and union_obj.getLayout(ip) == .auto and block.wantSafety() and union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1) { const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); @@ -27954,7 +27954,7 @@ fn unionFieldVal( const field_tag = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); const tag_matches = un.tag == field_tag.toIntern(); switch (union_obj.getLayout(ip)) { - .Auto => { + .auto => { if (tag_matches) { return Air.internedToRef(un.val); } else { @@ -27971,7 +27971,7 @@ fn unionFieldVal( return sema.failWithOwnedErrorMsg(block, msg); } }, - .Packed, .Extern => |layout| { + .@"packed", .@"extern" => |layout| { if (tag_matches) { return Air.internedToRef(un.val); } else { @@ -27989,7 +27989,7 @@ fn unionFieldVal( } try sema.requireRuntimeBlock(block, src, null); - if (union_obj.getLayout(ip) == .Auto and block.wantSafety() and + if (union_obj.getLayout(ip) == .auto and block.wantSafety() and union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1) { const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); @@ -30961,7 +30961,7 @@ fn beginComptimePtrMutation( const tag_type = base_child_ty.unionTagTypeHypothetical(mod); const hypothetical_tag = try mod.enumValueFieldIndex(tag_type, field_index); - if (layout == .Auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) { + if (layout == .auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) { // We need to set the active field of the union. payload.tag = hypothetical_tag; @@ -30988,7 +30988,7 @@ fn beginComptimePtrMutation( .pointee = .{ .reinterpret = .{ .val_ptr = val_ptr, .byte_offset = 0, - .write_packed = layout == .Packed, + .write_packed = layout == .@"packed", } }, .ty = parent.ty, }; @@ -31395,7 +31395,7 @@ fn beginComptimePtrLoad( if (container_ty.hasWellDefinedLayout(mod)) { const struct_obj = mod.typeToStruct(container_ty); - if (struct_obj != null and struct_obj.?.layout == .Packed) { + if (struct_obj != null and struct_obj.?.layout == .@"packed") { // packed structs are not byte addressable deref.parent = null; } else if (deref.parent) |*parent| { @@ -31551,7 +31551,7 @@ fn bitCastUnionFieldVal( // Reading a larger value means we need to reinterpret from undefined bytes. const offset = switch (layout) { - .Extern => offset: { + .@"extern" => offset: { if (field_size > old_size) @memset(buffer[old_size..], 0xaa); val.writeToMemory(old_ty, mod, buffer) catch |err| switch (err) { error.OutOfMemory => return error.OutOfMemory, @@ -31561,7 +31561,7 @@ fn bitCastUnionFieldVal( }; break :offset 0; }, - .Packed => offset: { + .@"packed" => offset: { if (field_size > old_size) { const min_size = @max(old_size, 1); switch (endian) { @@ -31577,7 +31577,7 @@ fn bitCastUnionFieldVal( break :offset if (endian == .big) buffer.len - field_size else 0; }, - .Auto => unreachable, + .auto => unreachable, }; return Value.readFromMemory(field_ty, mod, buffer[offset..], sema.arena) catch |err| switch (err) { @@ -35608,7 +35608,7 @@ pub fn resolveStructAlignment( const target = mod.getTarget(); assert(struct_type.flagsPtr(ip).alignment == .none); - assert(struct_type.layout != .Packed); + assert(struct_type.layout != .@"packed"); if (struct_type.flagsPtr(ip).field_types_wip) { // We'll guess "pointer-aligned", if the struct has an @@ -35661,7 +35661,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { try sema.resolveTypeFields(ty); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { try semaBackingIntType(mod, struct_type); return; } @@ -36625,11 +36625,11 @@ fn semaStructFields( const fields_len, const small, var extra_index = structZirInfo(zir, zir_index); if (fields_len == 0) switch (struct_type.layout) { - .Packed => { + .@"packed" => { try semaBackingIntType(mod, struct_type); return; }, - .Auto, .Extern => { + .auto, .@"extern" => { struct_type.size(ip).* = 0; struct_type.flagsPtr(ip).layout_resolved = true; return; @@ -36810,7 +36810,7 @@ fn semaStructFields( return sema.failWithOwnedErrorMsg(&block_scope, msg); } switch (struct_type.layout) { - .Extern => if (!try sema.validateExternType(field_ty, .struct_field)) { + .@"extern" => if (!try sema.validateExternType(field_ty, .struct_field)) { const msg = msg: { const ty_src = mod.fieldSrcLoc(decl_index, .{ .index = field_i, @@ -36826,7 +36826,7 @@ fn semaStructFields( }; return sema.failWithOwnedErrorMsg(&block_scope, msg); }, - .Packed => if (!try sema.validatePackedType(field_ty)) { + .@"packed" => if (!try sema.validatePackedType(field_ty)) { const msg = msg: { const ty_src = mod.fieldSrcLoc(decl_index, .{ .index = field_i, @@ -37350,7 +37350,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded return sema.failWithOwnedErrorMsg(&block_scope, msg); } const layout = union_type.getLayout(ip); - if (layout == .Extern and + if (layout == .@"extern" and !try sema.validateExternType(field_ty, .union_field)) { const msg = msg: { @@ -37367,7 +37367,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded break :msg msg; }; return sema.failWithOwnedErrorMsg(&block_scope, msg); - } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { + } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { const msg = msg: { const ty_src = mod.fieldSrcLoc(union_type.decl, .{ .index = field_i, @@ -38286,9 +38286,9 @@ fn structFieldAlignment( return explicit_alignment; const mod = sema.mod; switch (layout) { - .Packed => return .none, - .Auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty), - .Extern => {}, + .@"packed" => return .none, + .auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty), + .@"extern" => {}, } // extern const ty_abi_align = try sema.typeAbiAlignment(field_ty); diff --git a/src/Value.zig b/src/Value.zig index 3468ae4f10..a9f80635c7 100644 --- a/src/Value.zig +++ b/src/Value.zig @@ -676,8 +676,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ .Struct => { const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout; switch (struct_type.layout) { - .Auto => return error.IllDefinedMemoryLayout, - .Extern => for (0..struct_type.field_types.len) |i| { + .auto => return error.IllDefinedMemoryLayout, + .@"extern" => for (0..struct_type.field_types.len) |i| { const off: usize = @intCast(ty.structFieldOffset(i, mod)); const field_val = switch (val.ip_index) { .none => switch (val.tag()) { @@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); try writeToMemory(field_val, field_ty, mod, buffer[off..]); }, - .Packed => { + .@"packed" => { const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); }, @@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ bigint.writeTwosComplement(buffer[0..byte_count], endian); }, .Union => switch (ty.containerLayout(mod)) { - .Auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already - .Extern => { + .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already + .@"extern" => { if (val.unionTag(mod)) |union_tag| { const union_obj = mod.typeToUnion(ty).?; const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; @@ -739,7 +739,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]); } }, - .Packed => { + .@"packed" => { const backing_ty = try ty.unionBackingType(mod); const byte_count: usize = @intCast(backing_ty.abiSize(mod)); return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); @@ -841,7 +841,7 @@ pub fn writeToPackedMemory( const struct_type = ip.loadStructType(ty.toIntern()); // Sema is supposed to have emitted a compile error already in the case of Auto, // and Extern is handled in non-packed writeToMemory. - assert(struct_type.layout == .Packed); + assert(struct_type.layout == .@"packed"); var bits: u16 = 0; for (0..struct_type.field_types.len) |i| { const field_val = switch (val.ip_index) { @@ -866,8 +866,8 @@ pub fn writeToPackedMemory( .Union => { const union_obj = mod.typeToUnion(ty).?; switch (union_obj.getLayout(ip)) { - .Auto, .Extern => unreachable, // Handled in non-packed writeToMemory - .Packed => { + .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory + .@"packed" => { if (val.unionTag(mod)) |union_tag| { const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); @@ -991,8 +991,8 @@ pub fn readFromMemory( .Struct => { const struct_type = mod.typeToStruct(ty).?; switch (struct_type.layout) { - .Auto => unreachable, // Sema is supposed to have emitted a compile error already - .Extern => { + .auto => unreachable, // Sema is supposed to have emitted a compile error already + .@"extern" => { const field_types = struct_type.field_types; const field_vals = try arena.alloc(InternPool.Index, field_types.len); for (field_vals, 0..) |*field_val, i| { @@ -1006,7 +1006,7 @@ pub fn readFromMemory( .storage = .{ .elems = field_vals }, } }))); }, - .Packed => { + .@"packed" => { const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); }, @@ -1025,8 +1025,8 @@ pub fn readFromMemory( } }))); }, .Union => switch (ty.containerLayout(mod)) { - .Auto => return error.IllDefinedMemoryLayout, - .Extern => { + .auto => return error.IllDefinedMemoryLayout, + .@"extern" => { const union_size = ty.abiSize(mod); const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type }); const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod); @@ -1036,7 +1036,7 @@ pub fn readFromMemory( .val = val, } }))); }, - .Packed => { + .@"packed" => { const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); }, @@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory( } }))); }, .Union => switch (ty.containerLayout(mod)) { - .Auto, .Extern => unreachable, // Handled by non-packed readFromMemory - .Packed => { + .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory + .@"packed" => { const backing_ty = try ty.unionBackingType(mod); const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern(); return Value.fromInterned((try mod.intern(.{ .un = .{ @@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: { .alignment = 0, }; break :map @Type(.{ .Struct = .{ - .layout = .Extern, + .layout = .@"extern", .fields = &fields, .decls = &.{}, .is_tuple = false, diff --git a/src/arch/aarch64/abi.zig b/src/arch/aarch64/abi.zig index d85f67aaa9..5bc452a493 100644 --- a/src/arch/aarch64/abi.zig +++ b/src/arch/aarch64/abi.zig @@ -21,7 +21,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { var maybe_float_bits: ?u16 = null; switch (ty.zigTypeTag(mod)) { .Struct => { - if (ty.containerLayout(mod) == .Packed) return .byval; + if (ty.containerLayout(mod) == .@"packed") return .byval; const float_count = countFloats(ty, mod, &maybe_float_bits); if (float_count <= sret_float_count) return .{ .float_array = float_count }; @@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { return .integer; }, .Union => { - if (ty.containerLayout(mod) == .Packed) return .byval; + if (ty.containerLayout(mod) == .@"packed") return .byval; const float_count = countFloats(ty, mod, &maybe_float_bits); if (float_count <= sret_float_count) return .{ .float_array = float_count }; diff --git a/src/arch/arm/abi.zig b/src/arch/arm/abi.zig index ffb5c7ae3a..a6581c8dd8 100644 --- a/src/arch/arm/abi.zig +++ b/src/arch/arm/abi.zig @@ -33,7 +33,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class { switch (ty.zigTypeTag(mod)) { .Struct => { const bit_size = ty.bitSize(mod); - if (ty.containerLayout(mod) == .Packed) { + if (ty.containerLayout(mod) == .@"packed") { if (bit_size > 64) return .memory; return .byval; } @@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class { .Union => { const bit_size = ty.bitSize(mod); const union_obj = mod.typeToUnion(ty).?; - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { if (bit_size > 64) return .memory; return .byval; } diff --git a/src/arch/riscv64/abi.zig b/src/arch/riscv64/abi.zig index da74734de4..be3ac590a2 100644 --- a/src/arch/riscv64/abi.zig +++ b/src/arch/riscv64/abi.zig @@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { switch (ty.zigTypeTag(mod)) { .Struct => { const bit_size = ty.bitSize(mod); - if (ty.containerLayout(mod) == .Packed) { + if (ty.containerLayout(mod) == .@"packed") { if (bit_size > max_byval_size) return .memory; return .byval; } @@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { }, .Union => { const bit_size = ty.bitSize(mod); - if (ty.containerLayout(mod) == .Packed) { + if (ty.containerLayout(mod) == .@"packed") { if (bit_size > max_byval_size) return .memory; return .byval; } diff --git a/src/arch/wasm/CodeGen.zig b/src/arch/wasm/CodeGen.zig index e940e37619..a2bcb1cf6a 100644 --- a/src/arch/wasm/CodeGen.zig +++ b/src/arch/wasm/CodeGen.zig @@ -1018,7 +1018,7 @@ fn typeToValtype(ty: Type, mod: *Module) wasm.Valtype { .unrolled => wasm.Valtype.i32, }, .Union => switch (ty.containerLayout(mod)) { - .Packed => { + .@"packed" => { const int_ty = mod.intType(.unsigned, @as(u16, @intCast(ty.bitSize(mod)))) catch @panic("out of memory"); return typeToValtype(int_ty, mod); }, @@ -1737,7 +1737,7 @@ fn isByRef(ty: Type, mod: *Module) bool { => return ty.hasRuntimeBitsIgnoreComptime(mod), .Union => { if (mod.typeToUnion(ty)) |union_obj| { - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { return ty.abiSize(mod) > 8; } } @@ -3097,7 +3097,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue break :blk parent_ty.structFieldOffset(field_index, mod); }, .Union => switch (parent_ty.containerLayout(mod)) { - .Packed => 0, + .@"packed" => 0, else => blk: { const layout: Module.UnionLayout = parent_ty.unionGetLayout(mod); if (layout.payload_size == 0) break :blk 0; @@ -3358,7 +3358,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue { const struct_type = ip.loadStructType(ty.toIntern()); // non-packed structs are not handled in this function because they // are by-ref types. - assert(struct_type.layout == .Packed); + assert(struct_type.layout == .@"packed"); var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer val.writeToPackedMemory(ty, mod, &buf, 0) catch unreachable; const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*); @@ -3890,7 +3890,7 @@ fn structFieldPtr( const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); const offset = switch (struct_ty.containerLayout(mod)) { - .Packed => switch (struct_ty.zigTypeTag(mod)) { + .@"packed" => switch (struct_ty.zigTypeTag(mod)) { .Struct => offset: { if (result_ty.ptrInfo(mod).packed_offset.host_size != 0) { break :offset @as(u32, 0); @@ -3928,7 +3928,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{struct_field.struct_operand}); const result = switch (struct_ty.containerLayout(mod)) { - .Packed => switch (struct_ty.zigTypeTag(mod)) { + .@"packed" => switch (struct_ty.zigTypeTag(mod)) { .Struct => result: { const packed_struct = mod.typeToPackedStruct(struct_ty).?; const offset = mod.structPackedFieldBitOffset(packed_struct, field_index); @@ -5321,7 +5321,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { break :result_value result; }, .Struct => switch (result_ty.containerLayout(mod)) { - .Packed => { + .@"packed" => { if (isByRef(result_ty, mod)) { return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{}); } diff --git a/src/arch/wasm/abi.zig b/src/arch/wasm/abi.zig index 9c3fd8260d..7ca0f9f245 100644 --- a/src/arch/wasm/abi.zig +++ b/src/arch/wasm/abi.zig @@ -29,7 +29,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { switch (ty.zigTypeTag(mod)) { .Struct => { const struct_type = mod.typeToStruct(ty).?; - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { if (ty.bitSize(mod) <= 64) return direct; return .{ .direct, .direct }; } @@ -70,7 +70,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { }, .Union => { const union_obj = mod.typeToUnion(ty).?; - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { if (ty.bitSize(mod) <= 64) return direct; return .{ .direct, .direct }; } @@ -113,7 +113,7 @@ pub fn scalarType(ty: Type, mod: *Module) Type { }, .Union => { const union_obj = mod.typeToUnion(ty).?; - if (union_obj.getLayout(ip) != .Packed) { + if (union_obj.getLayout(ip) != .@"packed") { const layout = mod.getUnionLayout(union_obj); if (layout.payload_size == 0 and layout.tag_size != 0) { return scalarType(ty.unionTagTypeSafety(mod).?, mod); diff --git a/src/arch/x86_64/CodeGen.zig b/src/arch/x86_64/CodeGen.zig index 397dd3ab5f..2d66daf83f 100644 --- a/src/arch/x86_64/CodeGen.zig +++ b/src/arch/x86_64/CodeGen.zig @@ -7962,8 +7962,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void { const src_mcv = try self.resolveInst(operand); const field_off: u32 = switch (container_ty.containerLayout(mod)) { - .Auto, .Extern => @intCast(container_ty.structFieldOffset(index, mod) * 8), - .Packed => if (mod.typeToStruct(container_ty)) |struct_type| + .auto, .@"extern" => @intCast(container_ty.structFieldOffset(index, mod) * 8), + .@"packed" => if (mod.typeToStruct(container_ty)) |struct_type| mod.structPackedFieldBitOffset(struct_type, index) else 0, @@ -17979,7 +17979,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { switch (result_ty.zigTypeTag(mod)) { .Struct => { const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, mod)); - if (result_ty.containerLayout(mod) == .Packed) { + if (result_ty.containerLayout(mod) == .@"packed") { const struct_type = mod.typeToStruct(result_ty).?; try self.genInlineMemset( .{ .lea_frame = .{ .index = frame_index } }, diff --git a/src/arch/x86_64/abi.zig b/src/arch/x86_64/abi.zig index 601fc1933e..f54a98e08f 100644 --- a/src/arch/x86_64/abi.zig +++ b/src/arch/x86_64/abi.zig @@ -42,7 +42,7 @@ pub fn classifyWindows(ty: Type, mod: *Module) Class { 1, 2, 4, 8 => return .integer, else => switch (ty.zigTypeTag(mod)) { .Int => return .win_i128, - .Struct, .Union => if (ty.containerLayout(mod) == .Packed) { + .Struct, .Union => if (ty.containerLayout(mod) == .@"packed") { return .win_i128; } else { return .memory; @@ -238,7 +238,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class { // separately.". const struct_type = mod.typeToStruct(ty).?; const ty_size = ty.abiSize(mod); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { assert(ty_size <= 16); result[0] = .integer; if (ty_size > 8) result[1] = .integer; @@ -356,7 +356,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class { // separately.". const union_obj = mod.typeToUnion(ty).?; const ty_size = mod.unionAbiSize(union_obj); - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { assert(ty_size <= 16); result[0] = .integer; if (ty_size > 8) result[1] = .integer; diff --git a/src/codegen.zig b/src/codegen.zig index 2412b50cc1..c18bdca433 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -513,7 +513,7 @@ pub fn generateSymbol( .struct_type => { const struct_type = ip.loadStructType(typed_value.ty.toIntern()); switch (struct_type.layout) { - .Packed => { + .@"packed" => { const abi_size = math.cast(usize, typed_value.ty.abiSize(mod)) orelse return error.Overflow; const current_pos = code.items.len; @@ -550,7 +550,7 @@ pub fn generateSymbol( bits += @as(u16, @intCast(Type.fromInterned(field_ty).bitSize(mod))); } }, - .Auto, .Extern => { + .auto, .@"extern" => { const struct_begin = code.items.len; const field_types = struct_type.field_types.get(ip); const offsets = struct_type.offsets.get(ip); @@ -736,11 +736,11 @@ fn lowerParentPtr( .anon_struct_type, .union_type, => switch (Type.fromInterned(base_ty).containerLayout(mod)) { - .Auto, .Extern => @intCast(Type.fromInterned(base_ty).structFieldOffset( + .auto, .@"extern" => @intCast(Type.fromInterned(base_ty).structFieldOffset( @intCast(field.index), mod, )), - .Packed => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj| + .@"packed" => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj| if (Type.fromInterned(ptr.ty).ptrInfo(mod).packed_offset.host_size == 0) @divExact(Type.fromInterned(base_ptr_ty).ptrInfo(mod) .packed_offset.bit_offset + mod.structPackedFieldBitOffset( diff --git a/src/codegen/c.zig b/src/codegen/c.zig index abbf7501fc..3da58a48af 100644 --- a/src/codegen/c.zig +++ b/src/codegen/c.zig @@ -890,7 +890,7 @@ pub const DeclGen = struct { return writer.writeAll(" }"); }, .Struct => switch (ty.containerLayout(mod)) { - .Auto, .Extern => { + .auto, .@"extern" => { if (!location.isInitializer()) { try writer.writeByte('('); try dg.renderType(writer, ty); @@ -912,7 +912,7 @@ pub const DeclGen = struct { return writer.writeByte('}'); }, - .Packed => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}), + .@"packed" => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}), }, .Union => { if (!location.isInitializer()) { @@ -1379,7 +1379,7 @@ pub const DeclGen = struct { .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); switch (struct_type.layout) { - .Auto, .Extern => { + .auto, .@"extern" => { if (!location.isInitializer()) { try writer.writeByte('('); try dg.renderType(writer, ty); @@ -1408,7 +1408,7 @@ pub const DeclGen = struct { } try writer.writeByte('}'); }, - .Packed => { + .@"packed" => { const int_info = ty.intInfo(mod); const bits = Type.smallestUnsignedBits(int_info.bits - 1); @@ -1517,7 +1517,7 @@ pub const DeclGen = struct { if (un.tag == .none) { const backing_ty = try ty.unionBackingType(mod); switch (union_obj.getLayout(ip)) { - .Packed => { + .@"packed" => { if (!location.isInitializer()) { try writer.writeByte('('); try dg.renderType(writer, backing_ty); @@ -1525,7 +1525,7 @@ pub const DeclGen = struct { } try dg.renderValue(writer, backing_ty, Value.fromInterned(un.val), initializer_type); }, - .Extern => { + .@"extern" => { if (location == .StaticInitializer) { return dg.fail("TODO: C backend: implement extern union backing type rendering in static initializers", .{}); } @@ -1551,7 +1551,7 @@ pub const DeclGen = struct { const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?; const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index]; - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { if (field_ty.hasRuntimeBits(mod)) { if (field_ty.isPtrAtRuntime(mod)) { try writer.writeByte('('); @@ -5497,7 +5497,7 @@ fn fieldLocation( .Union => { const union_obj = mod.typeToUnion(container_ty).?; return switch (union_obj.getLayout(ip)) { - .Auto, .Extern => { + .auto, .@"extern" => { const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return if (container_ty.unionTagTypeSafety(mod) != null and @@ -5511,7 +5511,7 @@ fn fieldLocation( else .{ .identifier = ip.stringToSlice(field_name) } }; }, - .Packed => .begin, + .@"packed" => .begin, }; }, .Pointer => switch (container_ty.ptrSize(mod)) { @@ -5671,11 +5671,11 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { const field_name: CValue = switch (mod.intern_pool.indexToKey(struct_ty.ip_index)) { .struct_type => switch (struct_ty.containerLayout(mod)) { - .Auto, .Extern => if (struct_ty.isSimpleTuple(mod)) + .auto, .@"extern" => if (struct_ty.isSimpleTuple(mod)) .{ .field = extra.field_index } else .{ .identifier = ip.stringToSlice(struct_ty.legacyStructFieldName(extra.field_index, mod)) }, - .Packed => { + .@"packed" => { const struct_type = mod.typeToStruct(struct_ty).?; const int_info = struct_ty.intInfo(mod); @@ -5740,7 +5740,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { .union_type => field_name: { const union_obj = ip.loadUnionType(struct_ty.toIntern()); - if (union_obj.flagsPtr(ip).layout == .Packed) { + if (union_obj.flagsPtr(ip).layout == .@"packed") { const operand_lval = if (struct_byval == .constant) blk: { const operand_local = try f.allocLocal(inst, struct_ty); try f.writeCValue(writer, operand_local, .Other); @@ -7081,7 +7081,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { } }, .Struct => switch (inst_ty.containerLayout(mod)) { - .Auto, .Extern => for (resolved_elements, 0..) |element, field_index| { + .auto, .@"extern" => for (resolved_elements, 0..) |element, field_index| { if (inst_ty.structFieldIsComptime(field_index, mod)) continue; const field_ty = inst_ty.structFieldType(field_index, mod); if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; @@ -7095,7 +7095,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { try f.writeCValue(writer, element, .Other); try a.end(f, writer); }, - .Packed => { + .@"packed" => { try f.writeCValue(writer, local, .Other); try writer.writeAll(" = "); const int_info = inst_ty.intInfo(mod); @@ -7181,7 +7181,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { const writer = f.object.writer(); const local = try f.allocLocal(inst, union_ty); - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { try f.writeCValue(writer, local, .Other); try writer.writeAll(" = "); try f.writeCValue(writer, payload, .Initializer); diff --git a/src/codegen/c/type.zig b/src/codegen/c/type.zig index b85daddbda..66f92c930d 100644 --- a/src/codegen/c/type.zig +++ b/src/codegen/c/type.zig @@ -1495,7 +1495,7 @@ pub const CType = extern union { } }, - .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .Packed) { + .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .@"packed") { if (mod.typeToPackedStruct(ty)) |packed_struct| { try self.initType(Type.fromInterned(packed_struct.backingIntType(ip).*), kind, lookup); } else { diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 8f69dbc7e9..1e8c2a90dd 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -3327,7 +3327,7 @@ pub const Object = struct { const struct_type = ip.loadStructType(t.toIntern()); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*)); try o.type_map.put(o.gpa, t.toIntern(), int_ty); return int_ty; @@ -3477,7 +3477,7 @@ pub const Object = struct { const union_obj = ip.loadUnionType(t.toIntern()); const layout = mod.getUnionLayout(union_obj); - if (union_obj.flagsPtr(ip).layout == .Packed) { + if (union_obj.flagsPtr(ip).layout == .@"packed") { const int_ty = try o.builder.intType(@intCast(t.bitSize(mod))); try o.type_map.put(o.gpa, t.toIntern(), int_ty); return int_ty; @@ -4038,7 +4038,7 @@ pub const Object = struct { const struct_type = ip.loadStructType(ty.toIntern()); assert(struct_type.haveLayout(ip)); const struct_ty = try o.lowerType(ty); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { comptime assert(Type.packed_struct_layout_version == 2); var running_int = try o.builder.intConst(struct_ty, 0); var running_bits: u16 = 0; @@ -4154,7 +4154,7 @@ pub const Object = struct { const payload = if (un.tag != .none) p: { const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?; const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); - if (container_layout == .Packed) { + if (container_layout == .@"packed") { if (!field_ty.hasRuntimeBits(mod)) return o.builder.intConst(union_ty, 0); const small_int_val = try o.builder.castConst( if (field_ty.isPtrAtRuntime(mod)) .ptrtoint else .bitcast, @@ -4190,7 +4190,7 @@ pub const Object = struct { } else p: { assert(layout.tag_size == 0); const union_val = try o.lowerValue(un.val); - if (container_layout == .Packed) { + if (container_layout == .@"packed") { const bitcast_val = try o.builder.castConst( .bitcast, union_val, @@ -4324,7 +4324,7 @@ pub const Object = struct { const field_index: u32 = @intCast(field_ptr.index); switch (parent_ty.zigTypeTag(mod)) { .Union => { - if (parent_ty.containerLayout(mod) == .Packed) { + if (parent_ty.containerLayout(mod) == .@"packed") { return parent_ptr; } @@ -6531,7 +6531,7 @@ pub const FuncGen = struct { assert(!isByRef(field_ty, mod)); switch (struct_ty.zigTypeTag(mod)) { .Struct => switch (struct_ty.containerLayout(mod)) { - .Packed => { + .@"packed" => { const struct_type = mod.typeToStruct(struct_ty).?; const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index); const containing_int = struct_llvm_val; @@ -6558,7 +6558,7 @@ pub const FuncGen = struct { }, }, .Union => { - assert(struct_ty.containerLayout(mod) == .Packed); + assert(struct_ty.containerLayout(mod) == .@"packed"); const containing_int = struct_llvm_val; const elem_llvm_ty = try o.lowerType(field_ty); if (field_ty.zigTypeTag(mod) == .Float or field_ty.zigTypeTag(mod) == .Vector) { @@ -6581,7 +6581,7 @@ pub const FuncGen = struct { switch (struct_ty.zigTypeTag(mod)) { .Struct => { const layout = struct_ty.containerLayout(mod); - assert(layout != .Packed); + assert(layout != .@"packed"); const struct_llvm_ty = try o.lowerType(struct_ty); const llvm_field_index = o.llvmFieldIndex(struct_ty, field_index).?; const field_ptr = @@ -9995,7 +9995,7 @@ pub const FuncGen = struct { return running_int; } - assert(result_ty.containerLayout(mod) != .Packed); + assert(result_ty.containerLayout(mod) != .@"packed"); if (isByRef(result_ty, mod)) { // TODO in debug builds init to undef so that the padding will be 0xaa @@ -10080,7 +10080,7 @@ pub const FuncGen = struct { const layout = union_ty.unionGetLayout(mod); const union_obj = mod.typeToUnion(union_ty).?; - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { const big_bits = union_ty.bitSize(mod); const int_llvm_ty = try o.builder.intType(@intCast(big_bits)); const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]); @@ -10420,7 +10420,7 @@ pub const FuncGen = struct { const struct_ty = struct_ptr_ty.childType(mod); switch (struct_ty.zigTypeTag(mod)) { .Struct => switch (struct_ty.containerLayout(mod)) { - .Packed => { + .@"packed" => { const result_ty = self.typeOfIndex(inst); const result_ty_info = result_ty.ptrInfo(mod); const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); @@ -10462,7 +10462,7 @@ pub const FuncGen = struct { }, .Union => { const layout = struct_ty.unionGetLayout(mod); - if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .Packed) return struct_ptr; + if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .@"packed") return struct_ptr; const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align)); const union_llvm_ty = try o.lowerType(struct_ty); return self.wip.gepStruct(union_llvm_ty, struct_ptr, payload_index, ""); @@ -11572,7 +11572,7 @@ fn isByRef(ty: Type, mod: *Module) bool { }; // Packed structs are represented to LLVM as integers. - if (struct_type.layout == .Packed) return false; + if (struct_type.layout == .@"packed") return false; const field_types = struct_type.field_types.get(ip); var it = struct_type.iterateRuntimeOrder(ip); @@ -11586,7 +11586,7 @@ fn isByRef(ty: Type, mod: *Module) bool { return false; }, .Union => switch (ty.containerLayout(mod)) { - .Packed => return false, + .@"packed" => return false, else => return ty.hasRuntimeBits(mod), }, .ErrorUnion => { @@ -11624,8 +11624,8 @@ fn isScalar(mod: *Module, ty: Type) bool { .Vector, => true, - .Struct => ty.containerLayout(mod) == .Packed, - .Union => ty.containerLayout(mod) == .Packed, + .Struct => ty.containerLayout(mod) == .@"packed", + .Union => ty.containerLayout(mod) == .@"packed", else => false, }; } diff --git a/src/codegen/spirv.zig b/src/codegen/spirv.zig index e95ffee5c1..0b6951ab4f 100644 --- a/src/codegen/spirv.zig +++ b/src/codegen/spirv.zig @@ -979,7 +979,7 @@ const DeclGen = struct { }, .struct_type => { const struct_type = mod.typeToStruct(ty).?; - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { return self.todo("packed struct constants", .{}); } @@ -1275,7 +1275,7 @@ const DeclGen = struct { const ip = &mod.intern_pool; const union_obj = mod.typeToUnion(ty).?; - if (union_obj.getLayout(ip) == .Packed) { + if (union_obj.getLayout(ip) == .@"packed") { return self.todo("packed union types", .{}); } @@ -1532,7 +1532,7 @@ const DeclGen = struct { else => unreachable, }; - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct); } @@ -3904,7 +3904,7 @@ const DeclGen = struct { const union_ty = mod.typeToUnion(ty).?; const tag_ty = Type.fromInterned(union_ty.enum_tag_ty); - if (union_ty.getLayout(ip) == .Packed) { + if (union_ty.getLayout(ip) == .@"packed") { unreachable; // TODO } @@ -3984,11 +3984,11 @@ const DeclGen = struct { switch (object_ty.zigTypeTag(mod)) { .Struct => switch (object_ty.containerLayout(mod)) { - .Packed => unreachable, // TODO + .@"packed" => unreachable, // TODO else => return try self.extractField(field_ty, object_id, field_index), }, .Union => switch (object_ty.containerLayout(mod)) { - .Packed => unreachable, // TODO + .@"packed" => unreachable, // TODO else => { // Store, ptr-elem-ptr, pointer-cast, load const layout = self.unionLayout(object_ty); @@ -4058,13 +4058,13 @@ const DeclGen = struct { const object_ty = object_ptr_ty.childType(mod); switch (object_ty.zigTypeTag(mod)) { .Struct => switch (object_ty.containerLayout(mod)) { - .Packed => unreachable, // TODO + .@"packed" => unreachable, // TODO else => { return try self.accessChain(result_ty_ref, object_ptr, &.{field_index}); }, }, .Union => switch (object_ty.containerLayout(mod)) { - .Packed => unreachable, // TODO + .@"packed" => unreachable, // TODO else => { const layout = self.unionLayout(object_ty); if (!layout.has_payload) { diff --git a/src/codegen/spirv/Section.zig b/src/codegen/spirv/Section.zig index 2ce11111a7..002dad2510 100644 --- a/src/codegen/spirv/Section.zig +++ b/src/codegen/spirv/Section.zig @@ -154,7 +154,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand) } }, .Struct => |info| { - if (info.layout == .Packed) { + if (info.layout == .@"packed") { section.writeWord(@as(Word, @bitCast(operand))); } else { section.writeExtendedMask(Operand, operand); @@ -288,7 +288,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { } break :blk total; }, - .Struct => |info| if (info.layout == .Packed) 1 else extendedMaskSize(Operand, operand), + .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), .Union => extendedUnionSize(Operand, operand), else => unreachable, }, diff --git a/src/link/Dwarf.zig b/src/link/Dwarf.zig index ae14d16be2..9b6ff5d243 100644 --- a/src/link/Dwarf.zig +++ b/src/link/Dwarf.zig @@ -317,7 +317,7 @@ pub const DeclState = struct { try ty.print(dbg_info_buffer.writer(), mod); try dbg_info_buffer.append(0); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { log.debug("TODO implement .debug_info for packed structs", .{}); break :blk; } diff --git a/src/print_zir.zig b/src/print_zir.zig index d96fe4f6c9..8c858591eb 100644 --- a/src/print_zir.zig +++ b/src/print_zir.zig @@ -1440,7 +1440,7 @@ const Writer = struct { if (small.has_backing_int) { const backing_int_body_len = self.code.extra[extra_index]; extra_index += 1; - try stream.writeAll("Packed("); + try stream.writeAll("packed("); if (backing_int_body_len == 0) { const backing_int_ref: Zir.Inst.Ref = @enumFromInt(self.code.extra[extra_index]); extra_index += 1; diff --git a/src/type.zig b/src/type.zig index 8b2c6f2a1e..664498e353 100644 --- a/src/type.zig +++ b/src/type.zig @@ -741,12 +741,12 @@ pub const Type = struct { .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); // Struct with no fields have a well-defined layout of no bits. - return struct_type.layout != .Auto or struct_type.field_types.len == 0; + return struct_type.layout != .auto or struct_type.field_types.len == 0; }, .union_type => { const union_type = ip.loadUnionType(ty.toIntern()); return switch (union_type.flagsPtr(ip).runtime_tag) { - .none, .safety => union_type.flagsPtr(ip).layout != .Auto, + .none, .safety => union_type.flagsPtr(ip).layout != .auto, .tagged => false, }; }, @@ -1027,7 +1027,7 @@ pub const Type = struct { }, .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); - if (struct_type.layout == .Packed) { + if (struct_type.layout == .@"packed") { switch (strat) { .sema => |sema| try sema.resolveTypeLayout(ty), .lazy => if (struct_type.backingIntType(ip).* == .none) return .{ @@ -1407,7 +1407,7 @@ pub const Type = struct { switch (strat) { .sema => |sema| try sema.resolveTypeLayout(ty), .lazy => switch (struct_type.layout) { - .Packed => { + .@"packed" => { if (struct_type.backingIntType(ip).* == .none) return .{ .val = Value.fromInterned((try mod.intern(.{ .int = .{ .ty = .comptime_int_type, @@ -1415,7 +1415,7 @@ pub const Type = struct { } }))), }; }, - .Auto, .Extern => { + .auto, .@"extern" => { if (!struct_type.haveLayout(ip)) return .{ .val = Value.fromInterned((try mod.intern(.{ .int = .{ .ty = .comptime_int_type, @@ -1427,10 +1427,10 @@ pub const Type = struct { .eager => {}, } switch (struct_type.layout) { - .Packed => return .{ + .@"packed" => return .{ .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(mod), }, - .Auto, .Extern => { + .auto, .@"extern" => { assert(struct_type.haveLayout(ip)); return .{ .scalar = struct_type.size(ip).* }; }, @@ -1656,7 +1656,7 @@ pub const Type = struct { }, .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); - const is_packed = struct_type.layout == .Packed; + const is_packed = struct_type.layout == .@"packed"; if (opt_sema) |sema| { try sema.resolveTypeFields(ty); if (is_packed) try sema.resolveTypeLayout(ty); @@ -1674,7 +1674,7 @@ pub const Type = struct { .union_type => { const union_type = ip.loadUnionType(ty.toIntern()); - const is_packed = ty.containerLayout(mod) == .Packed; + const is_packed = ty.containerLayout(mod) == .@"packed"; if (opt_sema) |sema| { try sema.resolveTypeFields(ty); if (is_packed) try sema.resolveTypeLayout(ty); @@ -1987,9 +1987,9 @@ pub const Type = struct { /// Asserts the type is either an extern or packed union. pub fn unionBackingType(ty: Type, mod: *Module) !Type { return switch (ty.containerLayout(mod)) { - .Extern => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }), - .Packed => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))), - .Auto => unreachable, + .@"extern" => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }), + .@"packed" => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))), + .auto => unreachable, }; } @@ -2003,7 +2003,7 @@ pub const Type = struct { const ip = &mod.intern_pool; return switch (ip.indexToKey(ty.toIntern())) { .struct_type => ip.loadStructType(ty.toIntern()).layout, - .anon_struct_type => .Auto, + .anon_struct_type => .auto, .union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout, else => unreachable, }; @@ -2177,7 +2177,7 @@ pub const Type = struct { pub fn isAbiInt(ty: Type, mod: *Module) bool { return switch (ty.zigTypeTag(mod)) { .Int, .Enum, .ErrorSet => true, - .Struct => ty.containerLayout(mod) == .Packed, + .Struct => ty.containerLayout(mod) == .@"packed", else => false, }; } @@ -2690,7 +2690,7 @@ pub const Type = struct { const struct_type = ip.loadStructType(ty.toIntern()); // packed structs cannot be comptime-only because they have a well-defined // memory layout and every field has a well-defined bit pattern. - if (struct_type.layout == .Packed) + if (struct_type.layout == .@"packed") return false; // A struct with no fields is not comptime-only. @@ -3051,7 +3051,7 @@ pub const Type = struct { switch (ip.indexToKey(ty.toIntern())) { .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); - assert(struct_type.layout != .Packed); + assert(struct_type.layout != .@"packed"); const explicit_align = struct_type.fieldAlign(ip, index); const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[index]); return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout); @@ -3132,7 +3132,7 @@ pub const Type = struct { .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); assert(struct_type.haveLayout(ip)); - assert(struct_type.layout != .Packed); + assert(struct_type.layout != .@"packed"); return struct_type.offsets.get(ip)[index]; }, @@ -3208,7 +3208,7 @@ pub const Type = struct { return switch (ip.indexToKey(ty.toIntern())) { .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); - if (struct_type.layout == .Packed) return false; + if (struct_type.layout == .@"packed") return false; if (struct_type.decl == .none) return false; return struct_type.flagsPtr(ip).is_tuple; }, @@ -3230,7 +3230,7 @@ pub const Type = struct { return switch (ip.indexToKey(ty.toIntern())) { .struct_type => { const struct_type = ip.loadStructType(ty.toIntern()); - if (struct_type.layout == .Packed) return false; + if (struct_type.layout == .@"packed") return false; if (struct_type.decl == .none) return false; return struct_type.flagsPtr(ip).is_tuple; }, diff --git a/test/behavior/tuple.zig b/test/behavior/tuple.zig index 3d5b132c0f..bfd913774f 100644 --- a/test/behavior/tuple.zig +++ b/test/behavior/tuple.zig @@ -135,7 +135,7 @@ test "array-like initializer for tuple types" { const T = @Type(.{ .Struct = .{ .is_tuple = true, - .layout = .Auto, + .layout = .auto, .decls = &.{}, .fields = &.{ .{ @@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" { data: @Type(.{ .Struct = .{ .is_tuple = true, - .layout = .Auto, + .layout = .auto, .decls = &.{}, .fields = &.{.{ .name = "0", @@ -471,7 +471,7 @@ test "coerce anon tuple to tuple" { test "empty tuple type" { const S = @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &.{}, .decls = &.{}, .is_tuple = true, diff --git a/test/behavior/tuple_declarations.zig b/test/behavior/tuple_declarations.zig index e3730b3995..e6d5d76fc8 100644 --- a/test/behavior/tuple_declarations.zig +++ b/test/behavior/tuple_declarations.zig @@ -12,7 +12,7 @@ test "tuple declaration type info" { const T = struct { comptime u32 align(2) = 1, []const u8 }; const info = @typeInfo(T).Struct; - try expect(info.layout == .Auto); + try expect(info.layout == .auto); try expect(info.backing_integer == null); try expect(info.fields.len == 2); try expect(info.decls.len == 0); diff --git a/test/behavior/type.zig b/test/behavior/type.zig index d1310a2167..da42672be6 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -263,7 +263,7 @@ test "Type.Struct" { const A = @Type(@typeInfo(struct { x: u8, y: u32 })); const infoA = @typeInfo(A).Struct; - try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); + try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout); try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); try testing.expectEqual(u8, infoA.fields[0].type); try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); @@ -281,7 +281,7 @@ test "Type.Struct" { const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 })); const infoB = @typeInfo(B).Struct; - try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); + try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout); try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); try testing.expectEqual(u8, infoB.fields[0].type); try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); @@ -293,7 +293,7 @@ test "Type.Struct" { const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 })); const infoC = @typeInfo(C).Struct; - try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); + try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout); try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); try testing.expectEqual(u8, infoC.fields[0].type); try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*); @@ -306,7 +306,7 @@ test "Type.Struct" { // anon structs const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 }))); const infoD = @typeInfo(D).Struct; - try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); + 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].type); try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*); @@ -319,7 +319,7 @@ test "Type.Struct" { // tuples const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 }))); const infoE = @typeInfo(E).Struct; - try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); + 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].type); try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*); @@ -332,14 +332,14 @@ test "Type.Struct" { // empty struct const F = @Type(@typeInfo(struct {})); const infoF = @typeInfo(F).Struct; - try testing.expectEqual(Type.ContainerLayout.Auto, infoF.layout); + try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout); try testing.expect(infoF.fields.len == 0); try testing.expectEqual(@as(bool, false), infoF.is_tuple); // empty tuple const G = @Type(@typeInfo(@TypeOf(.{}))); const infoG = @typeInfo(G).Struct; - try testing.expectEqual(Type.ContainerLayout.Auto, infoG.layout); + try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout); try testing.expect(infoG.fields.len == 0); try testing.expectEqual(@as(bool, true), infoG.is_tuple); } @@ -386,7 +386,7 @@ test "Type.Union" { const Untagged = @Type(.{ .Union = .{ - .layout = .Extern, + .layout = .@"extern", .tag_type = null, .fields = &.{ .{ .name = "int", .type = i32, .alignment = @alignOf(f32) }, @@ -402,7 +402,7 @@ test "Type.Union" { const PackedUntagged = @Type(.{ .Union = .{ - .layout = .Packed, + .layout = .@"packed", .tag_type = null, .fields = &.{ .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, @@ -429,7 +429,7 @@ test "Type.Union" { }); const Tagged = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = Tag, .fields = &.{ .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, @@ -457,7 +457,7 @@ test "Type.Union from Type.Enum" { }); const T = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = Tag, .fields = &.{ .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, @@ -472,7 +472,7 @@ test "Type.Union from regular enum" { const E = enum { working_as_expected }; const T = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = E, .fields = &.{ .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, @@ -487,7 +487,7 @@ test "Type.Union from empty regular enum" { const E = enum {}; const U = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = E, .fields = &.{}, .decls = &.{}, @@ -507,7 +507,7 @@ test "Type.Union from empty Type.Enum" { }); const U = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = E, .fields = &.{}, .decls = &.{}, @@ -553,7 +553,7 @@ test "reified struct field name from optional payload" { const m_name: ?[1:0]u8 = "a".*; if (m_name) |*name| { const T = @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &.{.{ .name = name, .type = u8, @@ -575,7 +575,7 @@ test "reified union uses @alignOf" { fn CreateUnion(comptime T: type) type { return @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = null, .fields = &[_]std.builtin.Type.UnionField{ .{ @@ -597,7 +597,7 @@ test "reified struct uses @alignOf" { fn NamespacedGlobals(comptime modules: anytype) type { return @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .is_tuple = false, .fields = &.{ .{ @@ -659,7 +659,7 @@ test "empty struct assigned to reified struct field" { fn NamespacedComponents(comptime modules: anytype) type { return @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .is_tuple = false, .fields = &.{.{ .name = "components", @@ -721,7 +721,7 @@ test "struct field names sliced at comptime from larger string" { const T = @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .is_tuple = false, .fields = fields, .decls = &.{}, diff --git a/test/behavior/type_info.zig b/test/behavior/type_info.zig index 8b4674d346..d4e3eb3b83 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -250,7 +250,7 @@ test "type info: union info" { fn testUnion() !void { const typeinfo_info = @typeInfo(Type); try expect(typeinfo_info == .Union); - try expect(typeinfo_info.Union.layout == .Auto); + 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].type == @TypeOf(@typeInfo(u8).Int)); @@ -264,7 +264,7 @@ fn testUnion() !void { const notag_union_info = @typeInfo(TestNoTagUnion); try expect(notag_union_info == .Union); try expect(notag_union_info.Union.tag_type == null); - try expect(notag_union_info.Union.layout == .Auto); + 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].type == u32); @@ -275,7 +275,7 @@ fn testUnion() !void { }; const extern_union_info = @typeInfo(TestExternUnion); - try expect(extern_union_info.Union.layout == .Extern); + 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].type == *anyopaque); } @@ -310,7 +310,7 @@ fn testPackedStruct() !void { const struct_info = @typeInfo(TestPackedStruct); try expect(struct_info == .Struct); try expect(struct_info.Struct.is_tuple == false); - try expect(struct_info.Struct.layout == .Packed); + try expect(struct_info.Struct.layout == .@"packed"); 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); 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 9f0fb6773d..fe0a42b74a 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,5 +1,5 @@ export fn entry() void { - _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ + _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{ .{ .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 3d11d42996..df00a47b53 100644 --- a/test/cases/compile_errors/reify_struct.zig +++ b/test/cases/compile_errors/reify_struct.zig @@ -1,6 +1,6 @@ comptime { @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &.{.{ .name = "foo", .type = u32, @@ -14,7 +14,7 @@ comptime { } comptime { @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &.{.{ .name = "3", .type = u32, @@ -28,7 +28,7 @@ comptime { } comptime { @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &.{.{ .name = "0", .type = u32, @@ -42,7 +42,7 @@ comptime { } comptime { @Type(.{ .Struct = .{ - .layout = .Extern, + .layout = .@"extern", .fields = &.{.{ .name = "0", .type = u32, @@ -56,7 +56,7 @@ comptime { } comptime { @Type(.{ .Struct = .{ - .layout = .Packed, + .layout = .@"packed", .fields = &.{.{ .name = "0", .type = u32, 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 b32100ab73..0ea0b019b9 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 @@ -12,7 +12,7 @@ const Tag = @Type(.{ }); const Tagged = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = Tag, .fields = &.{ .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, 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 559eb81fcd..ed6f2245d4 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 @@ -11,7 +11,7 @@ const Tag = @Type(.{ }); const Tagged = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = Tag, .fields = &.{ .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, diff --git a/test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig b/test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig index 17f7e91870..91c5354c0c 100644 --- a/test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig +++ b/test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig @@ -8,7 +8,7 @@ const Tag = @Type(.{ }); const Tagged = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = Tag, .fields = &.{ .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, diff --git a/test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig b/test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig index 4023ebd74f..2dc9832470 100644 --- a/test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig +++ b/test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig @@ -11,7 +11,7 @@ const Tag = @Type(.{ }); const Tagged = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = Tag, .fields = &.{}, .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 df70934871..568b229104 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 @@ -1,6 +1,6 @@ const Untagged = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = null, .fields = &.{ .{ .name = "foo", .type = opaque {}, .alignment = 1 }, diff --git a/test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig b/test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig index dc57ded029..10792cad04 100644 --- a/test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig +++ b/test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig @@ -1,7 +1,7 @@ comptime { _ = @Type(.{ .Union = .{ - .layout = .Auto, + .layout = .auto, .tag_type = null, .fields = &.{ .{ .name = "foo", .type = usize, .alignment = 3 }, @@ -13,7 +13,7 @@ comptime { comptime { _ = @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &.{.{ .name = "0", .type = u32, diff --git a/test/cases/compile_errors/reify_type_with_undefined.zig b/test/cases/compile_errors/reify_type_with_undefined.zig index 59c0314773..e3daa316e3 100644 --- a/test/cases/compile_errors/reify_type_with_undefined.zig +++ b/test/cases/compile_errors/reify_type_with_undefined.zig @@ -7,7 +7,7 @@ comptime { .fields = undefined, .decls = undefined, .is_tuple = false, - .layout = .Auto, + .layout = .auto, }, }); } @@ -16,7 +16,7 @@ comptime { const fields: [1]std.builtin.Type.StructField = undefined; _ = @Type(.{ .Struct = .{ - .layout = .Auto, + .layout = .auto, .fields = &fields, .decls = &.{}, .is_tuple = false,