authorgravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-02-18 18:28:39-08:00
committergravatar for tristan.ross@midstall.comTristan Ross <tristan.ross@midstall.com> 2024-03-11 07:09:07-07:00
log099f3c4039d5702b073639ef8b55881973b71c80
tree2be1bb7abc86fb4c9148b82314718eac6a01e895
parentd0c06ca7127110a8afeb0ef524a197049892db21
signaturelock-open Commit is signed but in an unrecognized format.

std.builtin: make container layout fields lowercase


45 files changed, 291 insertions(+), 293 deletions(-)

lib/compiler/aro/aro/Attribute.zig+1-1
......@@ -653,7 +653,7 @@ pub const Arguments = blk: {
653653
654654 break :blk @Type(.{
655655 .Union = .{
656 .layout = .Auto,
656 .layout = .auto,
657657 .tag_type = null,
658658 .fields = &union_fields,
659659 .decls = &.{},
lib/std/builtin.zig+4-4
......@@ -334,9 +334,9 @@ pub const Type = union(enum) {
334334 /// This data structure is used by the Zig language code generation and
335335 /// therefore must be kept in sync with the compiler implementation.
336336 pub const ContainerLayout = enum(u2) {
337 Auto,
338 Extern,
339 Packed,
337 auto,
338 @"extern",
339 @"packed",
340340 };
341341
342342 /// This data structure is used by the Zig language code generation and
......@@ -353,7 +353,7 @@ pub const Type = union(enum) {
353353 /// therefore must be kept in sync with the compiler implementation.
354354 pub const Struct = struct {
355355 layout: ContainerLayout,
356 /// Only valid if layout is .Packed
356 /// Only valid if layout is .@"packed"
357357 backing_integer: ?type = null,
358358 fields: []const StructField,
359359 decls: []const Declaration,
lib/std/enums.zig+1-1
......@@ -22,7 +22,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
2222 }};
2323 }
2424 return @Type(.{ .Struct = .{
25 .layout = .Auto,
25 .layout = .auto,
2626 .fields = fields,
2727 .decls = &.{},
2828 .is_tuple = false,
lib/std/io.zig+1-1
......@@ -688,7 +688,7 @@ pub fn PollFiles(comptime StreamEnum: type) type {
688688 };
689689 }
690690 return @Type(.{ .Struct = .{
691 .layout = .Auto,
691 .layout = .auto,
692692 .fields = &struct_fields,
693693 .decls = &.{},
694694 .is_tuple = false,
lib/std/io/Reader.zig+1-1
......@@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool {
326326
327327pub fn readStruct(self: Self, comptime T: type) anyerror!T {
328328 // Only extern and packed structs have defined in-memory layout.
329 comptime assert(@typeInfo(T).Struct.layout != .Auto);
329 comptime assert(@typeInfo(T).Struct.layout != .auto);
330330 var res: [1]T = undefined;
331331 try self.readNoEof(mem.sliceAsBytes(res[0..]));
332332 return res[0];
lib/std/io/Writer.zig+1-1
......@@ -55,7 +55,7 @@ pub inline fn writeInt(self: Self, comptime T: type, value: T, endian: std.built
5555
5656pub fn writeStruct(self: Self, value: anytype) anyerror!void {
5757 // Only extern and packed structs have defined in-memory layout.
58 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .Auto);
58 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .auto);
5959 return self.writeAll(mem.asBytes(&value));
6060}
6161
lib/std/mem.zig+3-3
......@@ -238,7 +238,7 @@ pub fn zeroes(comptime T: type) T {
238238 },
239239 .Struct => |struct_info| {
240240 if (@sizeOf(T) == 0) return undefined;
241 if (struct_info.layout == .Extern) {
241 if (struct_info.layout == .@"extern") {
242242 var item: T = undefined;
243243 @memset(asBytes(&item), 0);
244244 return item;
......@@ -284,7 +284,7 @@ pub fn zeroes(comptime T: type) T {
284284 return @splat(zeroes(info.child));
285285 },
286286 .Union => |info| {
287 if (info.layout == .Extern) {
287 if (info.layout == .@"extern") {
288288 var item: T = undefined;
289289 @memset(asBytes(&item), 0);
290290 return item;
......@@ -429,7 +429,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T {
429429 }
430430 }
431431
432 var value: T = if (struct_info.layout == .Extern) zeroes(T) else undefined;
432 var value: T = if (struct_info.layout == .@"extern") zeroes(T) else undefined;
433433
434434 inline for (struct_info.fields, 0..) |field, i| {
435435 if (field.is_comptime) {
lib/std/meta.zig+7-7
......@@ -269,12 +269,12 @@ test containerLayout {
269269 a: u8,
270270 };
271271
272 try testing.expect(containerLayout(S1) == .Auto);
273 try testing.expect(containerLayout(S2) == .Packed);
274 try testing.expect(containerLayout(S3) == .Extern);
275 try testing.expect(containerLayout(U1) == .Auto);
276 try testing.expect(containerLayout(U2) == .Packed);
277 try testing.expect(containerLayout(U3) == .Extern);
272 try testing.expect(containerLayout(S1) == .auto);
273 try testing.expect(containerLayout(S2) == .@"packed");
274 try testing.expect(containerLayout(S3) == .@"extern");
275 try testing.expect(containerLayout(U1) == .auto);
276 try testing.expect(containerLayout(U2) == .@"packed");
277 try testing.expect(containerLayout(U3) == .@"extern");
278278}
279279
280280/// 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 {
10251025 return @Type(.{
10261026 .Struct = .{
10271027 .is_tuple = true,
1028 .layout = .Auto,
1028 .layout = .auto,
10291029 .decls = &.{},
10301030 .fields = &tuple_fields,
10311031 },
lib/std/meta/trailer_flags.zig+1-1
......@@ -32,7 +32,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
3232 }
3333 break :blk @Type(.{
3434 .Struct = .{
35 .layout = .Auto,
35 .layout = .auto,
3636 .fields = &fields,
3737 .decls = &.{},
3838 .is_tuple = false,
lib/std/multi_array_list.zig+1-1
......@@ -558,7 +558,7 @@ pub fn MultiArrayList(comptime T: type) type {
558558 .alignment = fields[i].alignment,
559559 };
560560 break :entry @Type(.{ .Struct = .{
561 .layout = .Extern,
561 .layout = .@"extern",
562562 .fields = &entry_fields,
563563 .decls = &.{},
564564 .is_tuple = false,
lib/std/zig/AstGen.zig+20-21
......@@ -175,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir {
175175 &gen_scope.base,
176176 0,
177177 tree.containerDeclRoot(),
178 .Auto,
178 .auto,
179179 0,
180180 )) |struct_decl_ref| {
181181 assert(struct_decl_ref.toIndex().? == .main_struct_inst);
......@@ -4907,7 +4907,7 @@ fn structDeclInner(
49074907 var backing_int_body_len: usize = 0;
49084908 const backing_int_ref: Zir.Inst.Ref = blk: {
49094909 if (backing_int_node != 0) {
4910 if (layout != .Packed) {
4910 if (layout != .@"packed") {
49114911 return astgen.failNode(backing_int_node, "non-packed struct does not support backing integer type", .{});
49124912 } else {
49134913 const backing_int_ref = try typeExpr(&block_scope, &namespace.base, backing_int_node);
......@@ -4958,9 +4958,9 @@ fn structDeclInner(
49584958 } else false;
49594959
49604960 if (is_tuple) switch (layout) {
4961 .Auto => {},
4962 .Extern => return astgen.failNode(node, "extern tuples are not supported", .{}),
4963 .Packed => return astgen.failNode(node, "packed tuples are not supported", .{}),
4961 .auto => {},
4962 .@"extern" => return astgen.failNode(node, "extern tuples are not supported", .{}),
4963 .@"packed" => return astgen.failNode(node, "packed tuples are not supported", .{}),
49644964 };
49654965
49664966 if (is_tuple) for (container_decl.ast.members) |member_node| {
......@@ -5055,9 +5055,9 @@ fn structDeclInner(
50555055
50565056 if (is_comptime) {
50575057 switch (layout) {
5058 .Packed => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}),
5059 .Extern => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}),
5060 .Auto => any_comptime_fields = true,
5058 .@"packed" => return astgen.failTok(member.comptime_token.?, "packed struct fields cannot be marked comptime", .{}),
5059 .@"extern" => return astgen.failTok(member.comptime_token.?, "extern struct fields cannot be marked comptime", .{}),
5060 .auto => any_comptime_fields = true,
50615061 }
50625062 } else {
50635063 known_non_opv = known_non_opv or
......@@ -5082,7 +5082,7 @@ fn structDeclInner(
50825082 }
50835083
50845084 if (have_align) {
5085 if (layout == .Packed) {
5085 if (layout == .@"packed") {
50865086 try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{});
50875087 }
50885088 any_aligned_fields = true;
......@@ -5229,12 +5229,11 @@ fn unionDeclInner(
52295229 const decl_count = try astgen.scanDecls(&namespace, members);
52305230 const field_count: u32 = @intCast(members.len - decl_count);
52315231
5232 if (layout != .Auto and (auto_enum_tok != null or arg_node != 0)) {
5233 const layout_str = if (layout == .Extern) "extern" else "packed";
5232 if (layout != .auto and (auto_enum_tok != null or arg_node != 0)) {
52345233 if (arg_node != 0) {
5235 return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{layout_str});
5234 return astgen.failNode(arg_node, "{s} union does not support enum tag type", .{@tagName(layout)});
52365235 } else {
5237 return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{layout_str});
5236 return astgen.failTok(auto_enum_tok.?, "{s} union does not support enum tag type", .{@tagName(layout)});
52385237 }
52395238 }
52405239
......@@ -5429,21 +5428,21 @@ fn containerDecl(
54295428
54305429 switch (token_tags[container_decl.ast.main_token]) {
54315430 .keyword_struct => {
5432 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
5433 .keyword_packed => std.builtin.Type.ContainerLayout.Packed,
5434 .keyword_extern => std.builtin.Type.ContainerLayout.Extern,
5431 const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
5432 .keyword_packed => .@"packed",
5433 .keyword_extern => .@"extern",
54355434 else => unreachable,
5436 } else std.builtin.Type.ContainerLayout.Auto;
5435 } else .auto;
54375436
54385437 const result = try structDeclInner(gz, scope, node, container_decl, layout, container_decl.ast.arg);
54395438 return rvalue(gz, ri, result, node);
54405439 },
54415440 .keyword_union => {
5442 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
5443 .keyword_packed => std.builtin.Type.ContainerLayout.Packed,
5444 .keyword_extern => std.builtin.Type.ContainerLayout.Extern,
5441 const layout: std.builtin.Type.ContainerLayout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
5442 .keyword_packed => .@"packed",
5443 .keyword_extern => .@"extern",
54455444 else => unreachable,
5446 } else std.builtin.Type.ContainerLayout.Auto;
5445 } else .auto;
54475446
54485447 const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, container_decl.ast.enum_token);
54495448 return rvalue(gz, ri, result, node);
lib/std/zig/Server.zig+3-3
......@@ -250,18 +250,18 @@ fn bswap(x: anytype) @TypeOf(x) {
250250 .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))),
251251 .Int => return @byteSwap(x),
252252 .Struct => |info| switch (info.layout) {
253 .Extern => {
253 .@"extern" => {
254254 var result: T = undefined;
255255 inline for (info.fields) |field| {
256256 @field(result, field.name) = bswap(@field(x, field.name));
257257 }
258258 return result;
259259 },
260 .Packed => {
260 .@"packed" => {
261261 const I = info.backing_integer.?;
262262 return @as(T, @bitCast(@byteSwap(@as(I, @bitCast(x)))));
263263 },
264 .Auto => @compileError("auto layout struct"),
264 .auto => @compileError("auto layout struct"),
265265 },
266266 else => @compileError("bswap on type " ++ @typeName(T)),
267267 }
src/InternPool.zig+35-36
......@@ -2025,15 +2025,15 @@ pub const LoadedStructType = struct {
20252025 /// complicated logic.
20262026 pub fn knownNonOpv(s: @This(), ip: *InternPool) bool {
20272027 return switch (s.layout) {
2028 .Packed => false,
2029 .Auto, .Extern => s.flagsPtr(ip).known_non_opv,
2028 .@"packed" => false,
2029 .auto, .@"extern" => s.flagsPtr(ip).known_non_opv,
20302030 };
20312031 }
20322032
20332033 /// The returned pointer expires with any addition to the `InternPool`.
20342034 /// Asserts the struct is not packed.
20352035 pub fn flagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStruct.Flags {
2036 assert(self.layout != .Packed);
2036 assert(self.layout != .@"packed");
20372037 const flags_field_index = std.meta.fieldIndex(Tag.TypeStruct, "flags").?;
20382038 return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]);
20392039 }
......@@ -2041,13 +2041,13 @@ pub const LoadedStructType = struct {
20412041 /// The returned pointer expires with any addition to the `InternPool`.
20422042 /// Asserts that the struct is packed.
20432043 pub fn packedFlagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStructPacked.Flags {
2044 assert(self.layout == .Packed);
2044 assert(self.layout == .@"packed");
20452045 const flags_field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?;
20462046 return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]);
20472047 }
20482048
20492049 pub fn assumeRuntimeBitsIfFieldTypesWip(s: @This(), ip: *InternPool) bool {
2050 if (s.layout == .Packed) return false;
2050 if (s.layout == .@"packed") return false;
20512051 const flags_ptr = s.flagsPtr(ip);
20522052 if (flags_ptr.field_types_wip) {
20532053 flags_ptr.assumed_runtime_bits = true;
......@@ -2057,7 +2057,7 @@ pub const LoadedStructType = struct {
20572057 }
20582058
20592059 pub fn setTypesWip(s: @This(), ip: *InternPool) bool {
2060 if (s.layout == .Packed) return false;
2060 if (s.layout == .@"packed") return false;
20612061 const flags_ptr = s.flagsPtr(ip);
20622062 if (flags_ptr.field_types_wip) return true;
20632063 flags_ptr.field_types_wip = true;
......@@ -2065,12 +2065,12 @@ pub const LoadedStructType = struct {
20652065 }
20662066
20672067 pub fn clearTypesWip(s: @This(), ip: *InternPool) void {
2068 if (s.layout == .Packed) return;
2068 if (s.layout == .@"packed") return;
20692069 s.flagsPtr(ip).field_types_wip = false;
20702070 }
20712071
20722072 pub fn setLayoutWip(s: @This(), ip: *InternPool) bool {
2073 if (s.layout == .Packed) return false;
2073 if (s.layout == .@"packed") return false;
20742074 const flags_ptr = s.flagsPtr(ip);
20752075 if (flags_ptr.layout_wip) return true;
20762076 flags_ptr.layout_wip = true;
......@@ -2078,12 +2078,12 @@ pub const LoadedStructType = struct {
20782078 }
20792079
20802080 pub fn clearLayoutWip(s: @This(), ip: *InternPool) void {
2081 if (s.layout == .Packed) return;
2081 if (s.layout == .@"packed") return;
20822082 s.flagsPtr(ip).layout_wip = false;
20832083 }
20842084
20852085 pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool {
2086 if (s.layout == .Packed) return false;
2086 if (s.layout == .@"packed") return false;
20872087 const flags_ptr = s.flagsPtr(ip);
20882088 if (flags_ptr.alignment_wip) return true;
20892089 flags_ptr.alignment_wip = true;
......@@ -2091,19 +2091,19 @@ pub const LoadedStructType = struct {
20912091 }
20922092
20932093 pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void {
2094 if (s.layout == .Packed) return;
2094 if (s.layout == .@"packed") return;
20952095 s.flagsPtr(ip).alignment_wip = false;
20962096 }
20972097
20982098 pub fn setInitsWip(s: @This(), ip: *InternPool) bool {
20992099 switch (s.layout) {
2100 .Packed => {
2100 .@"packed" => {
21012101 const flag = &s.packedFlagsPtr(ip).field_inits_wip;
21022102 if (flag.*) return true;
21032103 flag.* = true;
21042104 return false;
21052105 },
2106 .Auto, .Extern => {
2106 .auto, .@"extern" => {
21072107 const flag = &s.flagsPtr(ip).field_inits_wip;
21082108 if (flag.*) return true;
21092109 flag.* = true;
......@@ -2114,13 +2114,13 @@ pub const LoadedStructType = struct {
21142114
21152115 pub fn clearInitsWip(s: @This(), ip: *InternPool) void {
21162116 switch (s.layout) {
2117 .Packed => s.packedFlagsPtr(ip).field_inits_wip = false,
2118 .Auto, .Extern => s.flagsPtr(ip).field_inits_wip = false,
2117 .@"packed" => s.packedFlagsPtr(ip).field_inits_wip = false,
2118 .auto, .@"extern" => s.flagsPtr(ip).field_inits_wip = false,
21192119 }
21202120 }
21212121
21222122 pub fn setFullyResolved(s: @This(), ip: *InternPool) bool {
2123 if (s.layout == .Packed) return true;
2123 if (s.layout == .@"packed") return true;
21242124 const flags_ptr = s.flagsPtr(ip);
21252125 if (flags_ptr.fully_resolved) return true;
21262126 flags_ptr.fully_resolved = true;
......@@ -2134,7 +2134,7 @@ pub const LoadedStructType = struct {
21342134 /// The returned pointer expires with any addition to the `InternPool`.
21352135 /// Asserts the struct is not packed.
21362136 pub fn size(self: @This(), ip: *InternPool) *u32 {
2137 assert(self.layout != .Packed);
2137 assert(self.layout != .@"packed");
21382138 const size_field_index = std.meta.fieldIndex(Tag.TypeStruct, "size").?;
21392139 return @ptrCast(&ip.extra.items[self.extra_index + size_field_index]);
21402140 }
......@@ -2144,14 +2144,14 @@ pub const LoadedStructType = struct {
21442144 /// set to `none` until the layout is resolved.
21452145 /// Asserts the struct is packed.
21462146 pub fn backingIntType(s: @This(), ip: *const InternPool) *Index {
2147 assert(s.layout == .Packed);
2147 assert(s.layout == .@"packed");
21482148 const field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "backing_int_ty").?;
21492149 return @ptrCast(&ip.extra.items[s.extra_index + field_index]);
21502150 }
21512151
21522152 /// Asserts the struct is not packed.
21532153 pub fn setZirIndex(s: @This(), ip: *InternPool, new_zir_index: TrackedInst.Index.Optional) void {
2154 assert(s.layout != .Packed);
2154 assert(s.layout != .@"packed");
21552155 const field_index = std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?;
21562156 ip.extra.items[s.extra_index + field_index] = @intFromEnum(new_zir_index);
21572157 }
......@@ -2163,31 +2163,31 @@ pub const LoadedStructType = struct {
21632163
21642164 pub fn haveFieldInits(s: @This(), ip: *const InternPool) bool {
21652165 return switch (s.layout) {
2166 .Packed => s.packedFlagsPtr(ip).inits_resolved,
2167 .Auto, .Extern => s.flagsPtr(ip).inits_resolved,
2166 .@"packed" => s.packedFlagsPtr(ip).inits_resolved,
2167 .auto, .@"extern" => s.flagsPtr(ip).inits_resolved,
21682168 };
21692169 }
21702170
21712171 pub fn setHaveFieldInits(s: @This(), ip: *InternPool) void {
21722172 switch (s.layout) {
2173 .Packed => s.packedFlagsPtr(ip).inits_resolved = true,
2174 .Auto, .Extern => s.flagsPtr(ip).inits_resolved = true,
2173 .@"packed" => s.packedFlagsPtr(ip).inits_resolved = true,
2174 .auto, .@"extern" => s.flagsPtr(ip).inits_resolved = true,
21752175 }
21762176 }
21772177
21782178 pub fn haveLayout(s: @This(), ip: *InternPool) bool {
21792179 return switch (s.layout) {
2180 .Packed => s.backingIntType(ip).* != .none,
2181 .Auto, .Extern => s.flagsPtr(ip).layout_resolved,
2180 .@"packed" => s.backingIntType(ip).* != .none,
2181 .auto, .@"extern" => s.flagsPtr(ip).layout_resolved,
21822182 };
21832183 }
21842184
21852185 pub fn isTuple(s: @This(), ip: *InternPool) bool {
2186 return s.layout != .Packed and s.flagsPtr(ip).is_tuple;
2186 return s.layout != .@"packed" and s.flagsPtr(ip).is_tuple;
21872187 }
21882188
21892189 pub fn hasReorderedFields(s: @This()) bool {
2190 return s.layout == .Auto;
2190 return s.layout == .auto;
21912191 }
21922192
21932193 pub const RuntimeOrderIterator = struct {
......@@ -2221,7 +2221,7 @@ pub const LoadedStructType = struct {
22212221 /// May or may not include zero-bit fields.
22222222 /// Asserts the struct is not packed.
22232223 pub fn iterateRuntimeOrder(s: @This(), ip: *InternPool) RuntimeOrderIterator {
2224 assert(s.layout != .Packed);
2224 assert(s.layout != .@"packed");
22252225 return .{
22262226 .ip = ip,
22272227 .field_index = 0,
......@@ -2239,7 +2239,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
22392239 .decl = .none,
22402240 .namespace = .none,
22412241 .zir_index = .none,
2242 .layout = .Auto,
2242 .layout = .auto,
22432243 .field_names = .{ .start = 0, .len = 0 },
22442244 .field_types = .{ .start = 0, .len = 0 },
22452245 .field_inits = .{ .start = 0, .len = 0 },
......@@ -2314,7 +2314,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
23142314 .decl = extra.data.decl.toOptional(),
23152315 .namespace = namespace,
23162316 .zir_index = extra.data.zir_index.toOptional(),
2317 .layout = if (extra.data.flags.is_extern) .Extern else .Auto,
2317 .layout = if (extra.data.flags.is_extern) .@"extern" else .auto,
23182318 .field_names = names,
23192319 .field_types = field_types,
23202320 .field_inits = inits,
......@@ -2367,7 +2367,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType {
23672367 .decl = extra.data.decl.toOptional(),
23682368 .namespace = extra.data.namespace,
23692369 .zir_index = extra.data.zir_index.toOptional(),
2370 .layout = .Packed,
2370 .layout = .@"packed",
23712371 .field_names = field_names,
23722372 .field_types = field_types,
23732373 .field_inits = field_inits,
......@@ -4455,7 +4455,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key {
44554455 } else .{ .start = 0, .len = 0 } },
44564456 } };
44574457 } },
4458
44594458 .type_struct_anon => .{ .anon_struct_type = extraTypeStructAnon(ip, data) },
44604459 .type_tuple_anon => .{ .anon_struct_type = extraTypeTupleAnon(ip, data) },
44614460 .type_union => .{ .union_type = ns: {
......@@ -6009,9 +6008,9 @@ pub fn getStructType(
60096008 };
60106009
60116010 const is_extern = switch (ini.layout) {
6012 .Auto => false,
6013 .Extern => true,
6014 .Packed => {
6011 .auto => false,
6012 .@"extern" => true,
6013 .@"packed" => {
60156014 try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.TypeStructPacked).Struct.fields.len +
60166015 // TODO: fmt bug
60176016 // zig fmt: off
......@@ -6140,7 +6139,7 @@ pub fn getStructType(
61406139 if (ini.any_comptime_fields) {
61416140 ip.extra.appendNTimesAssumeCapacity(0, comptime_elements_len);
61426141 }
6143 if (ini.layout == .Auto) {
6142 if (ini.layout == .auto) {
61446143 ip.extra.appendNTimesAssumeCapacity(@intFromEnum(LoadedStructType.RuntimeOrder.unresolved), ini.fields_len);
61456144 }
61466145 ip.extra.appendNTimesAssumeCapacity(std.math.maxInt(u32), ini.fields_len);
src/Module.zig+8-8
......@@ -3310,7 +3310,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa
33103310 const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small);
33113311 assert(!small.has_captures_len);
33123312 assert(!small.has_backing_int);
3313 assert(small.layout == .Auto);
3313 assert(small.layout == .auto);
33143314 var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len;
33153315 const fields_len = if (small.has_fields_len) blk: {
33163316 const fields_len = file.zir.extra[extra_index];
......@@ -3327,7 +3327,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa
33273327
33283328 const tracked_inst = try ip.trackZir(gpa, file, .main_struct_inst);
33293329 const wip_ty = switch (try ip.getStructType(gpa, .{
3330 .layout = .Auto,
3330 .layout = .auto,
33313331 .fields_len = fields_len,
33323332 .known_non_opv = small.known_non_opv,
33333333 .requires_comptime = if (small.known_comptime_only) .yes else .unknown,
......@@ -5969,7 +5969,7 @@ pub fn typeToStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType {
59695969
59705970pub fn typeToPackedStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType {
59715971 const s = mod.typeToStruct(ty) orelse return null;
5972 if (s.layout != .Packed) return null;
5972 if (s.layout != .@"packed") return null;
59735973 return s;
59745974}
59755975
......@@ -6185,18 +6185,18 @@ pub fn structFieldAlignment(
61856185 field_ty: Type,
61866186 layout: std.builtin.Type.ContainerLayout,
61876187) Alignment {
6188 assert(layout != .Packed);
6188 assert(layout != .@"packed");
61896189 if (explicit_alignment != .none) return explicit_alignment;
61906190 switch (layout) {
6191 .Packed => unreachable,
6192 .Auto => {
6191 .@"packed" => unreachable,
6192 .auto => {
61936193 if (mod.getTarget().ofmt == .c) {
61946194 return structFieldAlignmentExtern(mod, field_ty);
61956195 } else {
61966196 return field_ty.abiAlignment(mod);
61976197 }
61986198 },
6199 .Extern => return structFieldAlignmentExtern(mod, field_ty),
6199 .@"extern" => return structFieldAlignmentExtern(mod, field_ty),
62006200 }
62016201}
62026202
......@@ -6224,7 +6224,7 @@ pub fn structPackedFieldBitOffset(
62246224 field_index: u32,
62256225) u16 {
62266226 const ip = &mod.intern_pool;
6227 assert(struct_type.layout == .Packed);
6227 assert(struct_type.layout == .@"packed");
62286228 assert(struct_type.haveLayout(ip));
62296229 var bit_sum: u64 = 0;
62306230 for (0..struct_type.field_types.len) |i| {
src/Sema.zig+54-54
......@@ -3236,7 +3236,7 @@ fn zirUnionDecl(
32363236 .status = .none,
32373237 .runtime_tag = if (small.has_tag_type or small.auto_enum_tag)
32383238 .tagged
3239 else if (small.layout != .Auto)
3239 else if (small.layout != .auto)
32403240 .none
32413241 else switch (block.wantSafety()) {
32423242 true => .safety,
......@@ -10380,7 +10380,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1038010380 };
1038110381 return sema.failWithOwnedErrorMsg(block, msg);
1038210382 },
10383 .Struct, .Union => if (dest_ty.containerLayout(mod) == .Auto) {
10383 .Struct, .Union => if (dest_ty.containerLayout(mod) == .auto) {
1038410384 const container = switch (dest_ty.zigTypeTag(mod)) {
1038510385 .Struct => "struct",
1038610386 .Union => "union",
......@@ -10443,7 +10443,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1044310443 };
1044410444 return sema.failWithOwnedErrorMsg(block, msg);
1044510445 },
10446 .Struct, .Union => if (operand_ty.containerLayout(mod) == .Auto) {
10446 .Struct, .Union => if (operand_ty.containerLayout(mod) == .auto) {
1044710447 const container = switch (operand_ty.zigTypeTag(mod)) {
1044810448 .Struct => "struct",
1044910449 .Union => "union",
......@@ -18131,8 +18131,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1813118131 };
1813218132
1813318133 const alignment = switch (layout) {
18134 .Auto, .Extern => try sema.unionFieldAlignment(union_obj, @intCast(i)),
18135 .Packed => .none,
18134 .auto, .@"extern" => try sema.unionFieldAlignment(union_obj, @intCast(i)),
18135 .@"packed" => .none,
1813618136 };
1813718137
1813818138 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
1835018350 const opt_default_val = if (field_init == .none) null else Value.fromInterned(field_init);
1835118351 const default_val_ptr = try sema.optRefValue(opt_default_val);
1835218352 const alignment = switch (struct_type.layout) {
18353 .Packed => .none,
18353 .@"packed" => .none,
1835418354 else => try sema.structFieldAlignment(
1835518355 struct_type.fieldAlign(ip, i),
1835618356 field_ty,
......@@ -19906,7 +19906,7 @@ fn zirStructInit(
1990619906 var field_i: u32 = 0;
1990719907 var extra_index = extra.end;
1990819908
19909 const is_packed = resolved_ty.containerLayout(mod) == .Packed;
19909 const is_packed = resolved_ty.containerLayout(mod) == .@"packed";
1991019910 while (field_i < extra.data.fields_len) : (field_i += 1) {
1991119911 const item = sema.code.extraData(Zir.Inst.StructInit.Item, extra_index);
1991219912 extra_index = item.end;
......@@ -21302,7 +21302,7 @@ fn zirReify(
2130221302 return sema.fail(block, src, "reified structs must have no decls", .{});
2130321303 }
2130421304
21305 if (layout != .Packed and !backing_integer_val.isNull(mod)) {
21305 if (layout != .@"packed" and !backing_integer_val.isNull(mod)) {
2130621306 return sema.fail(block, src, "non-packed struct does not support backing integer type", .{});
2130721307 }
2130821308
......@@ -21665,7 +21665,7 @@ fn reifyUnion(
2166521665 .status = .none,
2166621666 .runtime_tag = if (opt_tag_type_val.optionalValue(mod) != null)
2166721667 .tagged
21668 else if (layout != .Auto)
21668 else if (layout != .auto)
2166921669 .none
2167021670 else switch (block.wantSafety()) {
2167121671 true => .safety,
......@@ -21804,7 +21804,7 @@ fn reifyUnion(
2180421804 break :msg msg;
2180521805 });
2180621806 }
21807 if (layout == .Extern and !try sema.validateExternType(field_ty, .union_field)) {
21807 if (layout == .@"extern" and !try sema.validateExternType(field_ty, .union_field)) {
2180821808 return sema.failWithOwnedErrorMsg(block, msg: {
2180921809 const msg = try sema.errMsg(block, src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)});
2181021810 errdefer msg.destroy(gpa);
......@@ -21815,7 +21815,7 @@ fn reifyUnion(
2181521815 try sema.addDeclaredHereNote(msg, field_ty);
2181621816 break :msg msg;
2181721817 });
21818 } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) {
21818 } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) {
2181921819 return sema.failWithOwnedErrorMsg(block, msg: {
2182021820 const msg = try sema.errMsg(block, src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)});
2182121821 errdefer msg.destroy(gpa);
......@@ -21938,9 +21938,9 @@ fn reifyStruct(
2193821938 errdefer wip_ty.cancel(ip);
2193921939
2194021940 if (is_tuple) switch (layout) {
21941 .Extern => return sema.fail(block, src, "extern tuples are not supported", .{}),
21942 .Packed => return sema.fail(block, src, "packed tuples are not supported", .{}),
21943 .Auto => {},
21941 .@"extern" => return sema.fail(block, src, "extern tuples are not supported", .{}),
21942 .@"packed" => return sema.fail(block, src, "packed tuples are not supported", .{}),
21943 .auto => {},
2194421944 };
2194521945
2194621946 const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{
......@@ -21990,11 +21990,11 @@ fn reifyStruct(
2199021990
2199121991 const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema);
2199221992 if (byte_align == 0) {
21993 if (layout != .Packed) {
21993 if (layout != .@"packed") {
2199421994 struct_type.field_aligns.get(ip)[field_idx] = .none;
2199521995 }
2199621996 } else {
21997 if (layout == .Packed) return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{});
21997 if (layout == .@"packed") return sema.fail(block, src, "alignment in a packed struct field must be set to 0", .{});
2199821998 if (!math.isPowerOfTwo(byte_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align});
2199921999 struct_type.field_aligns.get(ip)[field_idx] = Alignment.fromNonzeroByteUnits(byte_align);
2200022000 }
......@@ -22004,9 +22004,9 @@ fn reifyStruct(
2200422004 if (field_is_comptime) {
2200522005 assert(any_comptime_fields);
2200622006 switch (layout) {
22007 .Extern => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}),
22008 .Packed => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}),
22009 .Auto => struct_type.setFieldComptime(ip, field_idx),
22007 .@"extern" => return sema.fail(block, src, "extern struct fields cannot be marked comptime", .{}),
22008 .@"packed" => return sema.fail(block, src, "packed struct fields cannot be marked comptime", .{}),
22009 .auto => struct_type.setFieldComptime(ip, field_idx),
2201022010 }
2201122011 }
2201222012
......@@ -22047,7 +22047,7 @@ fn reifyStruct(
2204722047 break :msg msg;
2204822048 });
2204922049 }
22050 if (layout == .Extern and !try sema.validateExternType(field_ty, .struct_field)) {
22050 if (layout == .@"extern" and !try sema.validateExternType(field_ty, .struct_field)) {
2205122051 return sema.failWithOwnedErrorMsg(block, msg: {
2205222052 const msg = try sema.errMsg(block, src, "extern structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
2205322053 errdefer msg.destroy(gpa);
......@@ -22058,7 +22058,7 @@ fn reifyStruct(
2205822058 try sema.addDeclaredHereNote(msg, field_ty);
2205922059 break :msg msg;
2206022060 });
22061 } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) {
22061 } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) {
2206222062 return sema.failWithOwnedErrorMsg(block, msg: {
2206322063 const msg = try sema.errMsg(block, src, "packed structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)});
2206422064 errdefer msg.destroy(gpa);
......@@ -22072,7 +22072,7 @@ fn reifyStruct(
2207222072 }
2207322073 }
2207422074
22075 if (layout == .Packed) {
22075 if (layout == .@"packed") {
2207622076 var fields_bit_sum: u64 = 0;
2207722077 for (0..struct_type.field_types.len) |field_idx| {
2207822078 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
2331123311 }
2331223312
2331323313 switch (ty.containerLayout(mod)) {
23314 .Packed => {
23314 .@"packed" => {
2331523315 var bit_sum: u64 = 0;
2331623316 const struct_type = ip.loadStructType(ty.toIntern());
2331723317 for (0..struct_type.field_types.len) |i| {
......@@ -24710,7 +24710,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr
2471024710 },
2471124711 };
2471224712
24713 if (parent_ty.containerLayout(mod) == .Packed) {
24713 if (parent_ty.containerLayout(mod) == .@"packed") {
2471424714 return sema.fail(block, src, "TODO handle packed structs/unions with @fieldParentPtr", .{});
2471524715 } else {
2471624716 ptr_ty_data.flags.alignment = blk: {
......@@ -26328,15 +26328,15 @@ fn validateExternType(
2632826328 return sema.validateExternType(ty.intTagType(mod), position);
2632926329 },
2633026330 .Struct, .Union => switch (ty.containerLayout(mod)) {
26331 .Extern => return true,
26332 .Packed => {
26331 .@"extern" => return true,
26332 .@"packed" => {
2633326333 const bit_size = try ty.bitSizeAdvanced(mod, sema);
2633426334 switch (bit_size) {
2633526335 0, 8, 16, 32, 64, 128 => return true,
2633626336 else => return false,
2633726337 }
2633826338 },
26339 .Auto => return !(try sema.typeHasRuntimeBits(ty)),
26339 .auto => return !(try sema.typeHasRuntimeBits(ty)),
2634026340 },
2634126341 .Array => {
2634226342 if (position == .ret_ty or position == .param_ty) return false;
......@@ -26456,7 +26456,7 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool {
2645626456 .Enum,
2645726457 => return true,
2645826458 .Pointer => return !ty.isSlice(mod) and !try sema.typeRequiresComptime(ty),
26459 .Struct, .Union => return ty.containerLayout(mod) == .Packed,
26459 .Struct, .Union => return ty.containerLayout(mod) == .@"packed",
2646026460 }
2646126461}
2646226462
......@@ -27596,7 +27596,7 @@ fn structFieldPtrByIndex(
2759627596 else
2759727597 try sema.typeAbiAlignment(Type.fromInterned(struct_ptr_ty_info.child));
2759827598
27599 if (struct_type.layout == .Packed) {
27599 if (struct_type.layout == .@"packed") {
2760027600 comptime assert(Type.packed_struct_layout_version == 2);
2760127601
2760227602 var running_bits: u16 = 0;
......@@ -27641,7 +27641,7 @@ fn structFieldPtrByIndex(
2764127641 ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 };
2764227642 }
2764327643 }
27644 } else if (struct_type.layout == .Extern) {
27644 } else if (struct_type.layout == .@"extern") {
2764527645 // For extern structs, field alignment might be bigger than type's
2764627646 // natural alignment. Eg, in `extern struct { x: u32, y: u16 }` the
2764727647 // second field is aligned as u32.
......@@ -27846,7 +27846,7 @@ fn unionFieldPtr(
2784627846 .is_const = union_ptr_info.flags.is_const,
2784727847 .is_volatile = union_ptr_info.flags.is_volatile,
2784827848 .address_space = union_ptr_info.flags.address_space,
27849 .alignment = if (union_obj.getLayout(ip) == .Auto) blk: {
27849 .alignment = if (union_obj.getLayout(ip) == .auto) blk: {
2785027850 const union_align = if (union_ptr_info.flags.alignment != .none)
2785127851 union_ptr_info.flags.alignment
2785227852 else
......@@ -27875,7 +27875,7 @@ fn unionFieldPtr(
2787527875
2787627876 if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: {
2787727877 switch (union_obj.getLayout(ip)) {
27878 .Auto => if (!initializing) {
27878 .auto => if (!initializing) {
2787927879 const union_val = (try sema.pointerDeref(block, src, union_ptr_val, union_ptr_ty)) orelse
2788027880 break :ct;
2788127881 if (union_val.isUndef(mod)) {
......@@ -27899,7 +27899,7 @@ fn unionFieldPtr(
2789927899 return sema.failWithOwnedErrorMsg(block, msg);
2790027900 }
2790127901 },
27902 .Packed, .Extern => {},
27902 .@"packed", .@"extern" => {},
2790327903 }
2790427904 return Air.internedToRef((try mod.intern(.{ .ptr = .{
2790527905 .ty = ptr_field_ty.toIntern(),
......@@ -27911,7 +27911,7 @@ fn unionFieldPtr(
2791127911 }
2791227912
2791327913 try sema.requireRuntimeBlock(block, src, null);
27914 if (!initializing and union_obj.getLayout(ip) == .Auto and block.wantSafety() and
27914 if (!initializing and union_obj.getLayout(ip) == .auto and block.wantSafety() and
2791527915 union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)
2791627916 {
2791727917 const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
......@@ -27954,7 +27954,7 @@ fn unionFieldVal(
2795427954 const field_tag = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
2795527955 const tag_matches = un.tag == field_tag.toIntern();
2795627956 switch (union_obj.getLayout(ip)) {
27957 .Auto => {
27957 .auto => {
2795827958 if (tag_matches) {
2795927959 return Air.internedToRef(un.val);
2796027960 } else {
......@@ -27971,7 +27971,7 @@ fn unionFieldVal(
2797127971 return sema.failWithOwnedErrorMsg(block, msg);
2797227972 }
2797327973 },
27974 .Packed, .Extern => |layout| {
27974 .@"packed", .@"extern" => |layout| {
2797527975 if (tag_matches) {
2797627976 return Air.internedToRef(un.val);
2797727977 } else {
......@@ -27989,7 +27989,7 @@ fn unionFieldVal(
2798927989 }
2799027990
2799127991 try sema.requireRuntimeBlock(block, src, null);
27992 if (union_obj.getLayout(ip) == .Auto and block.wantSafety() and
27992 if (union_obj.getLayout(ip) == .auto and block.wantSafety() and
2799327993 union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1)
2799427994 {
2799527995 const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index);
......@@ -30961,7 +30961,7 @@ fn beginComptimePtrMutation(
3096130961
3096230962 const tag_type = base_child_ty.unionTagTypeHypothetical(mod);
3096330963 const hypothetical_tag = try mod.enumValueFieldIndex(tag_type, field_index);
30964 if (layout == .Auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) {
30964 if (layout == .auto or (payload.tag != null and hypothetical_tag.eql(payload.tag.?, tag_type, mod))) {
3096530965 // We need to set the active field of the union.
3096630966 payload.tag = hypothetical_tag;
3096730967
......@@ -30988,7 +30988,7 @@ fn beginComptimePtrMutation(
3098830988 .pointee = .{ .reinterpret = .{
3098930989 .val_ptr = val_ptr,
3099030990 .byte_offset = 0,
30991 .write_packed = layout == .Packed,
30991 .write_packed = layout == .@"packed",
3099230992 } },
3099330993 .ty = parent.ty,
3099430994 };
......@@ -31395,7 +31395,7 @@ fn beginComptimePtrLoad(
3139531395
3139631396 if (container_ty.hasWellDefinedLayout(mod)) {
3139731397 const struct_obj = mod.typeToStruct(container_ty);
31398 if (struct_obj != null and struct_obj.?.layout == .Packed) {
31398 if (struct_obj != null and struct_obj.?.layout == .@"packed") {
3139931399 // packed structs are not byte addressable
3140031400 deref.parent = null;
3140131401 } else if (deref.parent) |*parent| {
......@@ -31551,7 +31551,7 @@ fn bitCastUnionFieldVal(
3155131551
3155231552 // Reading a larger value means we need to reinterpret from undefined bytes.
3155331553 const offset = switch (layout) {
31554 .Extern => offset: {
31554 .@"extern" => offset: {
3155531555 if (field_size > old_size) @memset(buffer[old_size..], 0xaa);
3155631556 val.writeToMemory(old_ty, mod, buffer) catch |err| switch (err) {
3155731557 error.OutOfMemory => return error.OutOfMemory,
......@@ -31561,7 +31561,7 @@ fn bitCastUnionFieldVal(
3156131561 };
3156231562 break :offset 0;
3156331563 },
31564 .Packed => offset: {
31564 .@"packed" => offset: {
3156531565 if (field_size > old_size) {
3156631566 const min_size = @max(old_size, 1);
3156731567 switch (endian) {
......@@ -31577,7 +31577,7 @@ fn bitCastUnionFieldVal(
3157731577
3157831578 break :offset if (endian == .big) buffer.len - field_size else 0;
3157931579 },
31580 .Auto => unreachable,
31580 .auto => unreachable,
3158131581 };
3158231582
3158331583 return Value.readFromMemory(field_ty, mod, buffer[offset..], sema.arena) catch |err| switch (err) {
......@@ -35608,7 +35608,7 @@ pub fn resolveStructAlignment(
3560835608 const target = mod.getTarget();
3560935609
3561035610 assert(struct_type.flagsPtr(ip).alignment == .none);
35611 assert(struct_type.layout != .Packed);
35611 assert(struct_type.layout != .@"packed");
3561235612
3561335613 if (struct_type.flagsPtr(ip).field_types_wip) {
3561435614 // We'll guess "pointer-aligned", if the struct has an
......@@ -35661,7 +35661,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void {
3566135661
3566235662 try sema.resolveTypeFields(ty);
3566335663
35664 if (struct_type.layout == .Packed) {
35664 if (struct_type.layout == .@"packed") {
3566535665 try semaBackingIntType(mod, struct_type);
3566635666 return;
3566735667 }
......@@ -36625,11 +36625,11 @@ fn semaStructFields(
3662536625 const fields_len, const small, var extra_index = structZirInfo(zir, zir_index);
3662636626
3662736627 if (fields_len == 0) switch (struct_type.layout) {
36628 .Packed => {
36628 .@"packed" => {
3662936629 try semaBackingIntType(mod, struct_type);
3663036630 return;
3663136631 },
36632 .Auto, .Extern => {
36632 .auto, .@"extern" => {
3663336633 struct_type.size(ip).* = 0;
3663436634 struct_type.flagsPtr(ip).layout_resolved = true;
3663536635 return;
......@@ -36810,7 +36810,7 @@ fn semaStructFields(
3681036810 return sema.failWithOwnedErrorMsg(&block_scope, msg);
3681136811 }
3681236812 switch (struct_type.layout) {
36813 .Extern => if (!try sema.validateExternType(field_ty, .struct_field)) {
36813 .@"extern" => if (!try sema.validateExternType(field_ty, .struct_field)) {
3681436814 const msg = msg: {
3681536815 const ty_src = mod.fieldSrcLoc(decl_index, .{
3681636816 .index = field_i,
......@@ -36826,7 +36826,7 @@ fn semaStructFields(
3682636826 };
3682736827 return sema.failWithOwnedErrorMsg(&block_scope, msg);
3682836828 },
36829 .Packed => if (!try sema.validatePackedType(field_ty)) {
36829 .@"packed" => if (!try sema.validatePackedType(field_ty)) {
3683036830 const msg = msg: {
3683136831 const ty_src = mod.fieldSrcLoc(decl_index, .{
3683236832 .index = field_i,
......@@ -37350,7 +37350,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded
3735037350 return sema.failWithOwnedErrorMsg(&block_scope, msg);
3735137351 }
3735237352 const layout = union_type.getLayout(ip);
37353 if (layout == .Extern and
37353 if (layout == .@"extern" and
3735437354 !try sema.validateExternType(field_ty, .union_field))
3735537355 {
3735637356 const msg = msg: {
......@@ -37367,7 +37367,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded
3736737367 break :msg msg;
3736837368 };
3736937369 return sema.failWithOwnedErrorMsg(&block_scope, msg);
37370 } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) {
37370 } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) {
3737137371 const msg = msg: {
3737237372 const ty_src = mod.fieldSrcLoc(union_type.decl, .{
3737337373 .index = field_i,
......@@ -38286,9 +38286,9 @@ fn structFieldAlignment(
3828638286 return explicit_alignment;
3828738287 const mod = sema.mod;
3828838288 switch (layout) {
38289 .Packed => return .none,
38290 .Auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty),
38291 .Extern => {},
38289 .@"packed" => return .none,
38290 .auto => if (mod.getTarget().ofmt != .c) return sema.typeAbiAlignment(field_ty),
38291 .@"extern" => {},
3829238292 }
3829338293 // extern
3829438294 const ty_abi_align = try sema.typeAbiAlignment(field_ty);
src/Value.zig+18-18
......@@ -676,8 +676,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
676676 .Struct => {
677677 const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout;
678678 switch (struct_type.layout) {
679 .Auto => return error.IllDefinedMemoryLayout,
680 .Extern => for (0..struct_type.field_types.len) |i| {
679 .auto => return error.IllDefinedMemoryLayout,
680 .@"extern" => for (0..struct_type.field_types.len) |i| {
681681 const off: usize = @intCast(ty.structFieldOffset(i, mod));
682682 const field_val = switch (val.ip_index) {
683683 .none => switch (val.tag()) {
......@@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
701701 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]);
702702 try writeToMemory(field_val, field_ty, mod, buffer[off..]);
703703 },
704 .Packed => {
704 .@"packed" => {
705705 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;
706706 return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0);
707707 },
......@@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{
724724 bigint.writeTwosComplement(buffer[0..byte_count], endian);
725725 },
726726 .Union => switch (ty.containerLayout(mod)) {
727 .Auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already
728 .Extern => {
727 .auto => return error.IllDefinedMemoryLayout, // Sema is supposed to have emitted a compile error already
728 .@"extern" => {
729729 if (val.unionTag(mod)) |union_tag| {
730730 const union_obj = mod.typeToUnion(ty).?;
731731 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{
739739 return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]);
740740 }
741741 },
742 .Packed => {
742 .@"packed" => {
743743 const backing_ty = try ty.unionBackingType(mod);
744744 const byte_count: usize = @intCast(backing_ty.abiSize(mod));
745745 return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0);
......@@ -841,7 +841,7 @@ pub fn writeToPackedMemory(
841841 const struct_type = ip.loadStructType(ty.toIntern());
842842 // Sema is supposed to have emitted a compile error already in the case of Auto,
843843 // and Extern is handled in non-packed writeToMemory.
844 assert(struct_type.layout == .Packed);
844 assert(struct_type.layout == .@"packed");
845845 var bits: u16 = 0;
846846 for (0..struct_type.field_types.len) |i| {
847847 const field_val = switch (val.ip_index) {
......@@ -866,8 +866,8 @@ pub fn writeToPackedMemory(
866866 .Union => {
867867 const union_obj = mod.typeToUnion(ty).?;
868868 switch (union_obj.getLayout(ip)) {
869 .Auto, .Extern => unreachable, // Handled in non-packed writeToMemory
870 .Packed => {
869 .auto, .@"extern" => unreachable, // Handled in non-packed writeToMemory
870 .@"packed" => {
871871 if (val.unionTag(mod)) |union_tag| {
872872 const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?;
873873 const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
......@@ -991,8 +991,8 @@ pub fn readFromMemory(
991991 .Struct => {
992992 const struct_type = mod.typeToStruct(ty).?;
993993 switch (struct_type.layout) {
994 .Auto => unreachable, // Sema is supposed to have emitted a compile error already
995 .Extern => {
994 .auto => unreachable, // Sema is supposed to have emitted a compile error already
995 .@"extern" => {
996996 const field_types = struct_type.field_types;
997997 const field_vals = try arena.alloc(InternPool.Index, field_types.len);
998998 for (field_vals, 0..) |*field_val, i| {
......@@ -1006,7 +1006,7 @@ pub fn readFromMemory(
10061006 .storage = .{ .elems = field_vals },
10071007 } })));
10081008 },
1009 .Packed => {
1009 .@"packed" => {
10101010 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;
10111011 return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena);
10121012 },
......@@ -1025,8 +1025,8 @@ pub fn readFromMemory(
10251025 } })));
10261026 },
10271027 .Union => switch (ty.containerLayout(mod)) {
1028 .Auto => return error.IllDefinedMemoryLayout,
1029 .Extern => {
1028 .auto => return error.IllDefinedMemoryLayout,
1029 .@"extern" => {
10301030 const union_size = ty.abiSize(mod);
10311031 const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type });
10321032 const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod);
......@@ -1036,7 +1036,7 @@ pub fn readFromMemory(
10361036 .val = val,
10371037 } })));
10381038 },
1039 .Packed => {
1039 .@"packed" => {
10401040 const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8;
10411041 return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena);
10421042 },
......@@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory(
11771177 } })));
11781178 },
11791179 .Union => switch (ty.containerLayout(mod)) {
1180 .Auto, .Extern => unreachable, // Handled by non-packed readFromMemory
1181 .Packed => {
1180 .auto, .@"extern" => unreachable, // Handled by non-packed readFromMemory
1181 .@"packed" => {
11821182 const backing_ty = try ty.unionBackingType(mod);
11831183 const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern();
11841184 return Value.fromInterned((try mod.intern(.{ .un = .{
......@@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: {
40644064 .alignment = 0,
40654065 };
40664066 break :map @Type(.{ .Struct = .{
4067 .layout = .Extern,
4067 .layout = .@"extern",
40684068 .fields = &fields,
40694069 .decls = &.{},
40704070 .is_tuple = false,
src/arch/aarch64/abi.zig+2-2
......@@ -21,7 +21,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
2121 var maybe_float_bits: ?u16 = null;
2222 switch (ty.zigTypeTag(mod)) {
2323 .Struct => {
24 if (ty.containerLayout(mod) == .Packed) return .byval;
24 if (ty.containerLayout(mod) == .@"packed") return .byval;
2525 const float_count = countFloats(ty, mod, &maybe_float_bits);
2626 if (float_count <= sret_float_count) return .{ .float_array = float_count };
2727
......@@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
3131 return .integer;
3232 },
3333 .Union => {
34 if (ty.containerLayout(mod) == .Packed) return .byval;
34 if (ty.containerLayout(mod) == .@"packed") return .byval;
3535 const float_count = countFloats(ty, mod, &maybe_float_bits);
3636 if (float_count <= sret_float_count) return .{ .float_array = float_count };
3737
src/arch/arm/abi.zig+2-2
......@@ -33,7 +33,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class {
3333 switch (ty.zigTypeTag(mod)) {
3434 .Struct => {
3535 const bit_size = ty.bitSize(mod);
36 if (ty.containerLayout(mod) == .Packed) {
36 if (ty.containerLayout(mod) == .@"packed") {
3737 if (bit_size > 64) return .memory;
3838 return .byval;
3939 }
......@@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class {
5656 .Union => {
5757 const bit_size = ty.bitSize(mod);
5858 const union_obj = mod.typeToUnion(ty).?;
59 if (union_obj.getLayout(ip) == .Packed) {
59 if (union_obj.getLayout(ip) == .@"packed") {
6060 if (bit_size > 64) return .memory;
6161 return .byval;
6262 }
src/arch/riscv64/abi.zig+2-2
......@@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
1515 switch (ty.zigTypeTag(mod)) {
1616 .Struct => {
1717 const bit_size = ty.bitSize(mod);
18 if (ty.containerLayout(mod) == .Packed) {
18 if (ty.containerLayout(mod) == .@"packed") {
1919 if (bit_size > max_byval_size) return .memory;
2020 return .byval;
2121 }
......@@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class {
4444 },
4545 .Union => {
4646 const bit_size = ty.bitSize(mod);
47 if (ty.containerLayout(mod) == .Packed) {
47 if (ty.containerLayout(mod) == .@"packed") {
4848 if (bit_size > max_byval_size) return .memory;
4949 return .byval;
5050 }
src/arch/wasm/CodeGen.zig+7-7
......@@ -1018,7 +1018,7 @@ fn typeToValtype(ty: Type, mod: *Module) wasm.Valtype {
10181018 .unrolled => wasm.Valtype.i32,
10191019 },
10201020 .Union => switch (ty.containerLayout(mod)) {
1021 .Packed => {
1021 .@"packed" => {
10221022 const int_ty = mod.intType(.unsigned, @as(u16, @intCast(ty.bitSize(mod)))) catch @panic("out of memory");
10231023 return typeToValtype(int_ty, mod);
10241024 },
......@@ -1737,7 +1737,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
17371737 => return ty.hasRuntimeBitsIgnoreComptime(mod),
17381738 .Union => {
17391739 if (mod.typeToUnion(ty)) |union_obj| {
1740 if (union_obj.getLayout(ip) == .Packed) {
1740 if (union_obj.getLayout(ip) == .@"packed") {
17411741 return ty.abiSize(mod) > 8;
17421742 }
17431743 }
......@@ -3097,7 +3097,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue
30973097 break :blk parent_ty.structFieldOffset(field_index, mod);
30983098 },
30993099 .Union => switch (parent_ty.containerLayout(mod)) {
3100 .Packed => 0,
3100 .@"packed" => 0,
31013101 else => blk: {
31023102 const layout: Module.UnionLayout = parent_ty.unionGetLayout(mod);
31033103 if (layout.payload_size == 0) break :blk 0;
......@@ -3358,7 +3358,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue {
33583358 const struct_type = ip.loadStructType(ty.toIntern());
33593359 // non-packed structs are not handled in this function because they
33603360 // are by-ref types.
3361 assert(struct_type.layout == .Packed);
3361 assert(struct_type.layout == .@"packed");
33623362 var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer
33633363 val.writeToPackedMemory(ty, mod, &buf, 0) catch unreachable;
33643364 const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*);
......@@ -3890,7 +3890,7 @@ fn structFieldPtr(
38903890 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);
38913891
38923892 const offset = switch (struct_ty.containerLayout(mod)) {
3893 .Packed => switch (struct_ty.zigTypeTag(mod)) {
3893 .@"packed" => switch (struct_ty.zigTypeTag(mod)) {
38943894 .Struct => offset: {
38953895 if (result_ty.ptrInfo(mod).packed_offset.host_size != 0) {
38963896 break :offset @as(u32, 0);
......@@ -3928,7 +3928,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
39283928 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{struct_field.struct_operand});
39293929
39303930 const result = switch (struct_ty.containerLayout(mod)) {
3931 .Packed => switch (struct_ty.zigTypeTag(mod)) {
3931 .@"packed" => switch (struct_ty.zigTypeTag(mod)) {
39323932 .Struct => result: {
39333933 const packed_struct = mod.typeToPackedStruct(struct_ty).?;
39343934 const offset = mod.structPackedFieldBitOffset(packed_struct, field_index);
......@@ -5321,7 +5321,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void {
53215321 break :result_value result;
53225322 },
53235323 .Struct => switch (result_ty.containerLayout(mod)) {
5324 .Packed => {
5324 .@"packed" => {
53255325 if (isByRef(result_ty, mod)) {
53265326 return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{});
53275327 }
src/arch/wasm/abi.zig+3-3
......@@ -29,7 +29,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class {
2929 switch (ty.zigTypeTag(mod)) {
3030 .Struct => {
3131 const struct_type = mod.typeToStruct(ty).?;
32 if (struct_type.layout == .Packed) {
32 if (struct_type.layout == .@"packed") {
3333 if (ty.bitSize(mod) <= 64) return direct;
3434 return .{ .direct, .direct };
3535 }
......@@ -70,7 +70,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class {
7070 },
7171 .Union => {
7272 const union_obj = mod.typeToUnion(ty).?;
73 if (union_obj.getLayout(ip) == .Packed) {
73 if (union_obj.getLayout(ip) == .@"packed") {
7474 if (ty.bitSize(mod) <= 64) return direct;
7575 return .{ .direct, .direct };
7676 }
......@@ -113,7 +113,7 @@ pub fn scalarType(ty: Type, mod: *Module) Type {
113113 },
114114 .Union => {
115115 const union_obj = mod.typeToUnion(ty).?;
116 if (union_obj.getLayout(ip) != .Packed) {
116 if (union_obj.getLayout(ip) != .@"packed") {
117117 const layout = mod.getUnionLayout(union_obj);
118118 if (layout.payload_size == 0 and layout.tag_size != 0) {
119119 return scalarType(ty.unionTagTypeSafety(mod).?, mod);
src/arch/x86_64/CodeGen.zig+3-3
......@@ -7962,8 +7962,8 @@ fn airStructFieldVal(self: *Self, inst: Air.Inst.Index) !void {
79627962
79637963 const src_mcv = try self.resolveInst(operand);
79647964 const field_off: u32 = switch (container_ty.containerLayout(mod)) {
7965 .Auto, .Extern => @intCast(container_ty.structFieldOffset(index, mod) * 8),
7966 .Packed => if (mod.typeToStruct(container_ty)) |struct_type|
7965 .auto, .@"extern" => @intCast(container_ty.structFieldOffset(index, mod) * 8),
7966 .@"packed" => if (mod.typeToStruct(container_ty)) |struct_type|
79677967 mod.structPackedFieldBitOffset(struct_type, index)
79687968 else
79697969 0,
......@@ -17979,7 +17979,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void {
1797917979 switch (result_ty.zigTypeTag(mod)) {
1798017980 .Struct => {
1798117981 const frame_index = try self.allocFrameIndex(FrameAlloc.initSpill(result_ty, mod));
17982 if (result_ty.containerLayout(mod) == .Packed) {
17982 if (result_ty.containerLayout(mod) == .@"packed") {
1798317983 const struct_type = mod.typeToStruct(result_ty).?;
1798417984 try self.genInlineMemset(
1798517985 .{ .lea_frame = .{ .index = frame_index } },
src/arch/x86_64/abi.zig+3-3
......@@ -42,7 +42,7 @@ pub fn classifyWindows(ty: Type, mod: *Module) Class {
4242 1, 2, 4, 8 => return .integer,
4343 else => switch (ty.zigTypeTag(mod)) {
4444 .Int => return .win_i128,
45 .Struct, .Union => if (ty.containerLayout(mod) == .Packed) {
45 .Struct, .Union => if (ty.containerLayout(mod) == .@"packed") {
4646 return .win_i128;
4747 } else {
4848 return .memory;
......@@ -238,7 +238,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class {
238238 // separately.".
239239 const struct_type = mod.typeToStruct(ty).?;
240240 const ty_size = ty.abiSize(mod);
241 if (struct_type.layout == .Packed) {
241 if (struct_type.layout == .@"packed") {
242242 assert(ty_size <= 16);
243243 result[0] = .integer;
244244 if (ty_size > 8) result[1] = .integer;
......@@ -356,7 +356,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class {
356356 // separately.".
357357 const union_obj = mod.typeToUnion(ty).?;
358358 const ty_size = mod.unionAbiSize(union_obj);
359 if (union_obj.getLayout(ip) == .Packed) {
359 if (union_obj.getLayout(ip) == .@"packed") {
360360 assert(ty_size <= 16);
361361 result[0] = .integer;
362362 if (ty_size > 8) result[1] = .integer;
src/codegen.zig+4-4
......@@ -513,7 +513,7 @@ pub fn generateSymbol(
513513 .struct_type => {
514514 const struct_type = ip.loadStructType(typed_value.ty.toIntern());
515515 switch (struct_type.layout) {
516 .Packed => {
516 .@"packed" => {
517517 const abi_size = math.cast(usize, typed_value.ty.abiSize(mod)) orelse
518518 return error.Overflow;
519519 const current_pos = code.items.len;
......@@ -550,7 +550,7 @@ pub fn generateSymbol(
550550 bits += @as(u16, @intCast(Type.fromInterned(field_ty).bitSize(mod)));
551551 }
552552 },
553 .Auto, .Extern => {
553 .auto, .@"extern" => {
554554 const struct_begin = code.items.len;
555555 const field_types = struct_type.field_types.get(ip);
556556 const offsets = struct_type.offsets.get(ip);
......@@ -736,11 +736,11 @@ fn lowerParentPtr(
736736 .anon_struct_type,
737737 .union_type,
738738 => switch (Type.fromInterned(base_ty).containerLayout(mod)) {
739 .Auto, .Extern => @intCast(Type.fromInterned(base_ty).structFieldOffset(
739 .auto, .@"extern" => @intCast(Type.fromInterned(base_ty).structFieldOffset(
740740 @intCast(field.index),
741741 mod,
742742 )),
743 .Packed => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj|
743 .@"packed" => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj|
744744 if (Type.fromInterned(ptr.ty).ptrInfo(mod).packed_offset.host_size == 0)
745745 @divExact(Type.fromInterned(base_ptr_ty).ptrInfo(mod)
746746 .packed_offset.bit_offset + mod.structPackedFieldBitOffset(
src/codegen/c.zig+15-15
......@@ -890,7 +890,7 @@ pub const DeclGen = struct {
890890 return writer.writeAll(" }");
891891 },
892892 .Struct => switch (ty.containerLayout(mod)) {
893 .Auto, .Extern => {
893 .auto, .@"extern" => {
894894 if (!location.isInitializer()) {
895895 try writer.writeByte('(');
896896 try dg.renderType(writer, ty);
......@@ -912,7 +912,7 @@ pub const DeclGen = struct {
912912
913913 return writer.writeByte('}');
914914 },
915 .Packed => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}),
915 .@"packed" => return writer.print("{x}", .{try dg.fmtIntLiteral(ty, Value.undef, .Other)}),
916916 },
917917 .Union => {
918918 if (!location.isInitializer()) {
......@@ -1379,7 +1379,7 @@ pub const DeclGen = struct {
13791379 .struct_type => {
13801380 const struct_type = ip.loadStructType(ty.toIntern());
13811381 switch (struct_type.layout) {
1382 .Auto, .Extern => {
1382 .auto, .@"extern" => {
13831383 if (!location.isInitializer()) {
13841384 try writer.writeByte('(');
13851385 try dg.renderType(writer, ty);
......@@ -1408,7 +1408,7 @@ pub const DeclGen = struct {
14081408 }
14091409 try writer.writeByte('}');
14101410 },
1411 .Packed => {
1411 .@"packed" => {
14121412 const int_info = ty.intInfo(mod);
14131413
14141414 const bits = Type.smallestUnsignedBits(int_info.bits - 1);
......@@ -1517,7 +1517,7 @@ pub const DeclGen = struct {
15171517 if (un.tag == .none) {
15181518 const backing_ty = try ty.unionBackingType(mod);
15191519 switch (union_obj.getLayout(ip)) {
1520 .Packed => {
1520 .@"packed" => {
15211521 if (!location.isInitializer()) {
15221522 try writer.writeByte('(');
15231523 try dg.renderType(writer, backing_ty);
......@@ -1525,7 +1525,7 @@ pub const DeclGen = struct {
15251525 }
15261526 try dg.renderValue(writer, backing_ty, Value.fromInterned(un.val), initializer_type);
15271527 },
1528 .Extern => {
1528 .@"extern" => {
15291529 if (location == .StaticInitializer) {
15301530 return dg.fail("TODO: C backend: implement extern union backing type rendering in static initializers", .{});
15311531 }
......@@ -1551,7 +1551,7 @@ pub const DeclGen = struct {
15511551 const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?;
15521552 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
15531553 const field_name = union_obj.loadTagType(ip).names.get(ip)[field_index];
1554 if (union_obj.getLayout(ip) == .Packed) {
1554 if (union_obj.getLayout(ip) == .@"packed") {
15551555 if (field_ty.hasRuntimeBits(mod)) {
15561556 if (field_ty.isPtrAtRuntime(mod)) {
15571557 try writer.writeByte('(');
......@@ -5497,7 +5497,7 @@ fn fieldLocation(
54975497 .Union => {
54985498 const union_obj = mod.typeToUnion(container_ty).?;
54995499 return switch (union_obj.getLayout(ip)) {
5500 .Auto, .Extern => {
5500 .auto, .@"extern" => {
55015501 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
55025502 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod))
55035503 return if (container_ty.unionTagTypeSafety(mod) != null and
......@@ -5511,7 +5511,7 @@ fn fieldLocation(
55115511 else
55125512 .{ .identifier = ip.stringToSlice(field_name) } };
55135513 },
5514 .Packed => .begin,
5514 .@"packed" => .begin,
55155515 };
55165516 },
55175517 .Pointer => switch (container_ty.ptrSize(mod)) {
......@@ -5671,11 +5671,11 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
56715671
56725672 const field_name: CValue = switch (mod.intern_pool.indexToKey(struct_ty.ip_index)) {
56735673 .struct_type => switch (struct_ty.containerLayout(mod)) {
5674 .Auto, .Extern => if (struct_ty.isSimpleTuple(mod))
5674 .auto, .@"extern" => if (struct_ty.isSimpleTuple(mod))
56755675 .{ .field = extra.field_index }
56765676 else
56775677 .{ .identifier = ip.stringToSlice(struct_ty.legacyStructFieldName(extra.field_index, mod)) },
5678 .Packed => {
5678 .@"packed" => {
56795679 const struct_type = mod.typeToStruct(struct_ty).?;
56805680 const int_info = struct_ty.intInfo(mod);
56815681
......@@ -5740,7 +5740,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue {
57405740
57415741 .union_type => field_name: {
57425742 const union_obj = ip.loadUnionType(struct_ty.toIntern());
5743 if (union_obj.flagsPtr(ip).layout == .Packed) {
5743 if (union_obj.flagsPtr(ip).layout == .@"packed") {
57445744 const operand_lval = if (struct_byval == .constant) blk: {
57455745 const operand_local = try f.allocLocal(inst, struct_ty);
57465746 try f.writeCValue(writer, operand_local, .Other);
......@@ -7081,7 +7081,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
70817081 }
70827082 },
70837083 .Struct => switch (inst_ty.containerLayout(mod)) {
7084 .Auto, .Extern => for (resolved_elements, 0..) |element, field_index| {
7084 .auto, .@"extern" => for (resolved_elements, 0..) |element, field_index| {
70857085 if (inst_ty.structFieldIsComptime(field_index, mod)) continue;
70867086 const field_ty = inst_ty.structFieldType(field_index, mod);
70877087 if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue;
......@@ -7095,7 +7095,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue {
70957095 try f.writeCValue(writer, element, .Other);
70967096 try a.end(f, writer);
70977097 },
7098 .Packed => {
7098 .@"packed" => {
70997099 try f.writeCValue(writer, local, .Other);
71007100 try writer.writeAll(" = ");
71017101 const int_info = inst_ty.intInfo(mod);
......@@ -7181,7 +7181,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue {
71817181
71827182 const writer = f.object.writer();
71837183 const local = try f.allocLocal(inst, union_ty);
7184 if (union_obj.getLayout(ip) == .Packed) {
7184 if (union_obj.getLayout(ip) == .@"packed") {
71857185 try f.writeCValue(writer, local, .Other);
71867186 try writer.writeAll(" = ");
71877187 try f.writeCValue(writer, payload, .Initializer);
src/codegen/c/type.zig+1-1
......@@ -1495,7 +1495,7 @@ pub const CType = extern union {
14951495 }
14961496 },
14971497
1498 .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .Packed) {
1498 .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .@"packed") {
14991499 if (mod.typeToPackedStruct(ty)) |packed_struct| {
15001500 try self.initType(Type.fromInterned(packed_struct.backingIntType(ip).*), kind, lookup);
15011501 } else {
src/codegen/llvm.zig+17-17
......@@ -3327,7 +3327,7 @@ pub const Object = struct {
33273327
33283328 const struct_type = ip.loadStructType(t.toIntern());
33293329
3330 if (struct_type.layout == .Packed) {
3330 if (struct_type.layout == .@"packed") {
33313331 const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*));
33323332 try o.type_map.put(o.gpa, t.toIntern(), int_ty);
33333333 return int_ty;
......@@ -3477,7 +3477,7 @@ pub const Object = struct {
34773477 const union_obj = ip.loadUnionType(t.toIntern());
34783478 const layout = mod.getUnionLayout(union_obj);
34793479
3480 if (union_obj.flagsPtr(ip).layout == .Packed) {
3480 if (union_obj.flagsPtr(ip).layout == .@"packed") {
34813481 const int_ty = try o.builder.intType(@intCast(t.bitSize(mod)));
34823482 try o.type_map.put(o.gpa, t.toIntern(), int_ty);
34833483 return int_ty;
......@@ -4038,7 +4038,7 @@ pub const Object = struct {
40384038 const struct_type = ip.loadStructType(ty.toIntern());
40394039 assert(struct_type.haveLayout(ip));
40404040 const struct_ty = try o.lowerType(ty);
4041 if (struct_type.layout == .Packed) {
4041 if (struct_type.layout == .@"packed") {
40424042 comptime assert(Type.packed_struct_layout_version == 2);
40434043 var running_int = try o.builder.intConst(struct_ty, 0);
40444044 var running_bits: u16 = 0;
......@@ -4154,7 +4154,7 @@ pub const Object = struct {
41544154 const payload = if (un.tag != .none) p: {
41554155 const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?;
41564156 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]);
4157 if (container_layout == .Packed) {
4157 if (container_layout == .@"packed") {
41584158 if (!field_ty.hasRuntimeBits(mod)) return o.builder.intConst(union_ty, 0);
41594159 const small_int_val = try o.builder.castConst(
41604160 if (field_ty.isPtrAtRuntime(mod)) .ptrtoint else .bitcast,
......@@ -4190,7 +4190,7 @@ pub const Object = struct {
41904190 } else p: {
41914191 assert(layout.tag_size == 0);
41924192 const union_val = try o.lowerValue(un.val);
4193 if (container_layout == .Packed) {
4193 if (container_layout == .@"packed") {
41944194 const bitcast_val = try o.builder.castConst(
41954195 .bitcast,
41964196 union_val,
......@@ -4324,7 +4324,7 @@ pub const Object = struct {
43244324 const field_index: u32 = @intCast(field_ptr.index);
43254325 switch (parent_ty.zigTypeTag(mod)) {
43264326 .Union => {
4327 if (parent_ty.containerLayout(mod) == .Packed) {
4327 if (parent_ty.containerLayout(mod) == .@"packed") {
43284328 return parent_ptr;
43294329 }
43304330
......@@ -6531,7 +6531,7 @@ pub const FuncGen = struct {
65316531 assert(!isByRef(field_ty, mod));
65326532 switch (struct_ty.zigTypeTag(mod)) {
65336533 .Struct => switch (struct_ty.containerLayout(mod)) {
6534 .Packed => {
6534 .@"packed" => {
65356535 const struct_type = mod.typeToStruct(struct_ty).?;
65366536 const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index);
65376537 const containing_int = struct_llvm_val;
......@@ -6558,7 +6558,7 @@ pub const FuncGen = struct {
65586558 },
65596559 },
65606560 .Union => {
6561 assert(struct_ty.containerLayout(mod) == .Packed);
6561 assert(struct_ty.containerLayout(mod) == .@"packed");
65626562 const containing_int = struct_llvm_val;
65636563 const elem_llvm_ty = try o.lowerType(field_ty);
65646564 if (field_ty.zigTypeTag(mod) == .Float or field_ty.zigTypeTag(mod) == .Vector) {
......@@ -6581,7 +6581,7 @@ pub const FuncGen = struct {
65816581 switch (struct_ty.zigTypeTag(mod)) {
65826582 .Struct => {
65836583 const layout = struct_ty.containerLayout(mod);
6584 assert(layout != .Packed);
6584 assert(layout != .@"packed");
65856585 const struct_llvm_ty = try o.lowerType(struct_ty);
65866586 const llvm_field_index = o.llvmFieldIndex(struct_ty, field_index).?;
65876587 const field_ptr =
......@@ -9995,7 +9995,7 @@ pub const FuncGen = struct {
99959995 return running_int;
99969996 }
99979997
9998 assert(result_ty.containerLayout(mod) != .Packed);
9998 assert(result_ty.containerLayout(mod) != .@"packed");
99999999
1000010000 if (isByRef(result_ty, mod)) {
1000110001 // TODO in debug builds init to undef so that the padding will be 0xaa
......@@ -10080,7 +10080,7 @@ pub const FuncGen = struct {
1008010080 const layout = union_ty.unionGetLayout(mod);
1008110081 const union_obj = mod.typeToUnion(union_ty).?;
1008210082
10083 if (union_obj.getLayout(ip) == .Packed) {
10083 if (union_obj.getLayout(ip) == .@"packed") {
1008410084 const big_bits = union_ty.bitSize(mod);
1008510085 const int_llvm_ty = try o.builder.intType(@intCast(big_bits));
1008610086 const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]);
......@@ -10420,7 +10420,7 @@ pub const FuncGen = struct {
1042010420 const struct_ty = struct_ptr_ty.childType(mod);
1042110421 switch (struct_ty.zigTypeTag(mod)) {
1042210422 .Struct => switch (struct_ty.containerLayout(mod)) {
10423 .Packed => {
10423 .@"packed" => {
1042410424 const result_ty = self.typeOfIndex(inst);
1042510425 const result_ty_info = result_ty.ptrInfo(mod);
1042610426 const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod);
......@@ -10462,7 +10462,7 @@ pub const FuncGen = struct {
1046210462 },
1046310463 .Union => {
1046410464 const layout = struct_ty.unionGetLayout(mod);
10465 if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .Packed) return struct_ptr;
10465 if (layout.payload_size == 0 or struct_ty.containerLayout(mod) == .@"packed") return struct_ptr;
1046610466 const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align));
1046710467 const union_llvm_ty = try o.lowerType(struct_ty);
1046810468 return self.wip.gepStruct(union_llvm_ty, struct_ptr, payload_index, "");
......@@ -11572,7 +11572,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
1157211572 };
1157311573
1157411574 // Packed structs are represented to LLVM as integers.
11575 if (struct_type.layout == .Packed) return false;
11575 if (struct_type.layout == .@"packed") return false;
1157611576
1157711577 const field_types = struct_type.field_types.get(ip);
1157811578 var it = struct_type.iterateRuntimeOrder(ip);
......@@ -11586,7 +11586,7 @@ fn isByRef(ty: Type, mod: *Module) bool {
1158611586 return false;
1158711587 },
1158811588 .Union => switch (ty.containerLayout(mod)) {
11589 .Packed => return false,
11589 .@"packed" => return false,
1159011590 else => return ty.hasRuntimeBits(mod),
1159111591 },
1159211592 .ErrorUnion => {
......@@ -11624,8 +11624,8 @@ fn isScalar(mod: *Module, ty: Type) bool {
1162411624 .Vector,
1162511625 => true,
1162611626
11627 .Struct => ty.containerLayout(mod) == .Packed,
11628 .Union => ty.containerLayout(mod) == .Packed,
11627 .Struct => ty.containerLayout(mod) == .@"packed",
11628 .Union => ty.containerLayout(mod) == .@"packed",
1162911629 else => false,
1163011630 };
1163111631}
src/codegen/spirv.zig+8-8
......@@ -979,7 +979,7 @@ const DeclGen = struct {
979979 },
980980 .struct_type => {
981981 const struct_type = mod.typeToStruct(ty).?;
982 if (struct_type.layout == .Packed) {
982 if (struct_type.layout == .@"packed") {
983983 return self.todo("packed struct constants", .{});
984984 }
985985
......@@ -1275,7 +1275,7 @@ const DeclGen = struct {
12751275 const ip = &mod.intern_pool;
12761276 const union_obj = mod.typeToUnion(ty).?;
12771277
1278 if (union_obj.getLayout(ip) == .Packed) {
1278 if (union_obj.getLayout(ip) == .@"packed") {
12791279 return self.todo("packed union types", .{});
12801280 }
12811281
......@@ -1532,7 +1532,7 @@ const DeclGen = struct {
15321532 else => unreachable,
15331533 };
15341534
1535 if (struct_type.layout == .Packed) {
1535 if (struct_type.layout == .@"packed") {
15361536 return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct);
15371537 }
15381538
......@@ -3904,7 +3904,7 @@ const DeclGen = struct {
39043904 const union_ty = mod.typeToUnion(ty).?;
39053905 const tag_ty = Type.fromInterned(union_ty.enum_tag_ty);
39063906
3907 if (union_ty.getLayout(ip) == .Packed) {
3907 if (union_ty.getLayout(ip) == .@"packed") {
39083908 unreachable; // TODO
39093909 }
39103910
......@@ -3984,11 +3984,11 @@ const DeclGen = struct {
39843984
39853985 switch (object_ty.zigTypeTag(mod)) {
39863986 .Struct => switch (object_ty.containerLayout(mod)) {
3987 .Packed => unreachable, // TODO
3987 .@"packed" => unreachable, // TODO
39883988 else => return try self.extractField(field_ty, object_id, field_index),
39893989 },
39903990 .Union => switch (object_ty.containerLayout(mod)) {
3991 .Packed => unreachable, // TODO
3991 .@"packed" => unreachable, // TODO
39923992 else => {
39933993 // Store, ptr-elem-ptr, pointer-cast, load
39943994 const layout = self.unionLayout(object_ty);
......@@ -4058,13 +4058,13 @@ const DeclGen = struct {
40584058 const object_ty = object_ptr_ty.childType(mod);
40594059 switch (object_ty.zigTypeTag(mod)) {
40604060 .Struct => switch (object_ty.containerLayout(mod)) {
4061 .Packed => unreachable, // TODO
4061 .@"packed" => unreachable, // TODO
40624062 else => {
40634063 return try self.accessChain(result_ty_ref, object_ptr, &.{field_index});
40644064 },
40654065 },
40664066 .Union => switch (object_ty.containerLayout(mod)) {
4067 .Packed => unreachable, // TODO
4067 .@"packed" => unreachable, // TODO
40684068 else => {
40694069 const layout = self.unionLayout(object_ty);
40704070 if (!layout.has_payload) {
src/codegen/spirv/Section.zig+2-2
......@@ -154,7 +154,7 @@ pub fn writeOperand(section: *Section, comptime Operand: type, operand: Operand)
154154 }
155155 },
156156 .Struct => |info| {
157 if (info.layout == .Packed) {
157 if (info.layout == .@"packed") {
158158 section.writeWord(@as(Word, @bitCast(operand)));
159159 } else {
160160 section.writeExtendedMask(Operand, operand);
......@@ -288,7 +288,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize {
288288 }
289289 break :blk total;
290290 },
291 .Struct => |info| if (info.layout == .Packed) 1 else extendedMaskSize(Operand, operand),
291 .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand),
292292 .Union => extendedUnionSize(Operand, operand),
293293 else => unreachable,
294294 },
src/link/Dwarf.zig+1-1
......@@ -317,7 +317,7 @@ pub const DeclState = struct {
317317 try ty.print(dbg_info_buffer.writer(), mod);
318318 try dbg_info_buffer.append(0);
319319
320 if (struct_type.layout == .Packed) {
320 if (struct_type.layout == .@"packed") {
321321 log.debug("TODO implement .debug_info for packed structs", .{});
322322 break :blk;
323323 }
src/print_zir.zig+1-1
......@@ -1440,7 +1440,7 @@ const Writer = struct {
14401440 if (small.has_backing_int) {
14411441 const backing_int_body_len = self.code.extra[extra_index];
14421442 extra_index += 1;
1443 try stream.writeAll("Packed(");
1443 try stream.writeAll("packed(");
14441444 if (backing_int_body_len == 0) {
14451445 const backing_int_ref: Zir.Inst.Ref = @enumFromInt(self.code.extra[extra_index]);
14461446 extra_index += 1;
src/type.zig+19-19
......@@ -741,12 +741,12 @@ pub const Type = struct {
741741 .struct_type => {
742742 const struct_type = ip.loadStructType(ty.toIntern());
743743 // Struct with no fields have a well-defined layout of no bits.
744 return struct_type.layout != .Auto or struct_type.field_types.len == 0;
744 return struct_type.layout != .auto or struct_type.field_types.len == 0;
745745 },
746746 .union_type => {
747747 const union_type = ip.loadUnionType(ty.toIntern());
748748 return switch (union_type.flagsPtr(ip).runtime_tag) {
749 .none, .safety => union_type.flagsPtr(ip).layout != .Auto,
749 .none, .safety => union_type.flagsPtr(ip).layout != .auto,
750750 .tagged => false,
751751 };
752752 },
......@@ -1027,7 +1027,7 @@ pub const Type = struct {
10271027 },
10281028 .struct_type => {
10291029 const struct_type = ip.loadStructType(ty.toIntern());
1030 if (struct_type.layout == .Packed) {
1030 if (struct_type.layout == .@"packed") {
10311031 switch (strat) {
10321032 .sema => |sema| try sema.resolveTypeLayout(ty),
10331033 .lazy => if (struct_type.backingIntType(ip).* == .none) return .{
......@@ -1407,7 +1407,7 @@ pub const Type = struct {
14071407 switch (strat) {
14081408 .sema => |sema| try sema.resolveTypeLayout(ty),
14091409 .lazy => switch (struct_type.layout) {
1410 .Packed => {
1410 .@"packed" => {
14111411 if (struct_type.backingIntType(ip).* == .none) return .{
14121412 .val = Value.fromInterned((try mod.intern(.{ .int = .{
14131413 .ty = .comptime_int_type,
......@@ -1415,7 +1415,7 @@ pub const Type = struct {
14151415 } }))),
14161416 };
14171417 },
1418 .Auto, .Extern => {
1418 .auto, .@"extern" => {
14191419 if (!struct_type.haveLayout(ip)) return .{
14201420 .val = Value.fromInterned((try mod.intern(.{ .int = .{
14211421 .ty = .comptime_int_type,
......@@ -1427,10 +1427,10 @@ pub const Type = struct {
14271427 .eager => {},
14281428 }
14291429 switch (struct_type.layout) {
1430 .Packed => return .{
1430 .@"packed" => return .{
14311431 .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(mod),
14321432 },
1433 .Auto, .Extern => {
1433 .auto, .@"extern" => {
14341434 assert(struct_type.haveLayout(ip));
14351435 return .{ .scalar = struct_type.size(ip).* };
14361436 },
......@@ -1656,7 +1656,7 @@ pub const Type = struct {
16561656 },
16571657 .struct_type => {
16581658 const struct_type = ip.loadStructType(ty.toIntern());
1659 const is_packed = struct_type.layout == .Packed;
1659 const is_packed = struct_type.layout == .@"packed";
16601660 if (opt_sema) |sema| {
16611661 try sema.resolveTypeFields(ty);
16621662 if (is_packed) try sema.resolveTypeLayout(ty);
......@@ -1674,7 +1674,7 @@ pub const Type = struct {
16741674
16751675 .union_type => {
16761676 const union_type = ip.loadUnionType(ty.toIntern());
1677 const is_packed = ty.containerLayout(mod) == .Packed;
1677 const is_packed = ty.containerLayout(mod) == .@"packed";
16781678 if (opt_sema) |sema| {
16791679 try sema.resolveTypeFields(ty);
16801680 if (is_packed) try sema.resolveTypeLayout(ty);
......@@ -1987,9 +1987,9 @@ pub const Type = struct {
19871987 /// Asserts the type is either an extern or packed union.
19881988 pub fn unionBackingType(ty: Type, mod: *Module) !Type {
19891989 return switch (ty.containerLayout(mod)) {
1990 .Extern => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }),
1991 .Packed => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))),
1992 .Auto => unreachable,
1990 .@"extern" => try mod.arrayType(.{ .len = ty.abiSize(mod), .child = .u8_type }),
1991 .@"packed" => try mod.intType(.unsigned, @intCast(ty.bitSize(mod))),
1992 .auto => unreachable,
19931993 };
19941994 }
19951995
......@@ -2003,7 +2003,7 @@ pub const Type = struct {
20032003 const ip = &mod.intern_pool;
20042004 return switch (ip.indexToKey(ty.toIntern())) {
20052005 .struct_type => ip.loadStructType(ty.toIntern()).layout,
2006 .anon_struct_type => .Auto,
2006 .anon_struct_type => .auto,
20072007 .union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout,
20082008 else => unreachable,
20092009 };
......@@ -2177,7 +2177,7 @@ pub const Type = struct {
21772177 pub fn isAbiInt(ty: Type, mod: *Module) bool {
21782178 return switch (ty.zigTypeTag(mod)) {
21792179 .Int, .Enum, .ErrorSet => true,
2180 .Struct => ty.containerLayout(mod) == .Packed,
2180 .Struct => ty.containerLayout(mod) == .@"packed",
21812181 else => false,
21822182 };
21832183 }
......@@ -2690,7 +2690,7 @@ pub const Type = struct {
26902690 const struct_type = ip.loadStructType(ty.toIntern());
26912691 // packed structs cannot be comptime-only because they have a well-defined
26922692 // memory layout and every field has a well-defined bit pattern.
2693 if (struct_type.layout == .Packed)
2693 if (struct_type.layout == .@"packed")
26942694 return false;
26952695
26962696 // A struct with no fields is not comptime-only.
......@@ -3051,7 +3051,7 @@ pub const Type = struct {
30513051 switch (ip.indexToKey(ty.toIntern())) {
30523052 .struct_type => {
30533053 const struct_type = ip.loadStructType(ty.toIntern());
3054 assert(struct_type.layout != .Packed);
3054 assert(struct_type.layout != .@"packed");
30553055 const explicit_align = struct_type.fieldAlign(ip, index);
30563056 const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[index]);
30573057 return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout);
......@@ -3132,7 +3132,7 @@ pub const Type = struct {
31323132 .struct_type => {
31333133 const struct_type = ip.loadStructType(ty.toIntern());
31343134 assert(struct_type.haveLayout(ip));
3135 assert(struct_type.layout != .Packed);
3135 assert(struct_type.layout != .@"packed");
31363136 return struct_type.offsets.get(ip)[index];
31373137 },
31383138
......@@ -3208,7 +3208,7 @@ pub const Type = struct {
32083208 return switch (ip.indexToKey(ty.toIntern())) {
32093209 .struct_type => {
32103210 const struct_type = ip.loadStructType(ty.toIntern());
3211 if (struct_type.layout == .Packed) return false;
3211 if (struct_type.layout == .@"packed") return false;
32123212 if (struct_type.decl == .none) return false;
32133213 return struct_type.flagsPtr(ip).is_tuple;
32143214 },
......@@ -3230,7 +3230,7 @@ pub const Type = struct {
32303230 return switch (ip.indexToKey(ty.toIntern())) {
32313231 .struct_type => {
32323232 const struct_type = ip.loadStructType(ty.toIntern());
3233 if (struct_type.layout == .Packed) return false;
3233 if (struct_type.layout == .@"packed") return false;
32343234 if (struct_type.decl == .none) return false;
32353235 return struct_type.flagsPtr(ip).is_tuple;
32363236 },
test/behavior/tuple.zig+3-3
......@@ -135,7 +135,7 @@ test "array-like initializer for tuple types" {
135135 const T = @Type(.{
136136 .Struct = .{
137137 .is_tuple = true,
138 .layout = .Auto,
138 .layout = .auto,
139139 .decls = &.{},
140140 .fields = &.{
141141 .{
......@@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" {
323323 data: @Type(.{
324324 .Struct = .{
325325 .is_tuple = true,
326 .layout = .Auto,
326 .layout = .auto,
327327 .decls = &.{},
328328 .fields = &.{.{
329329 .name = "0",
......@@ -471,7 +471,7 @@ test "coerce anon tuple to tuple" {
471471
472472test "empty tuple type" {
473473 const S = @Type(.{ .Struct = .{
474 .layout = .Auto,
474 .layout = .auto,
475475 .fields = &.{},
476476 .decls = &.{},
477477 .is_tuple = true,
test/behavior/tuple_declarations.zig+1-1
......@@ -12,7 +12,7 @@ test "tuple declaration type info" {
1212 const T = struct { comptime u32 align(2) = 1, []const u8 };
1313 const info = @typeInfo(T).Struct;
1414
15 try expect(info.layout == .Auto);
15 try expect(info.layout == .auto);
1616 try expect(info.backing_integer == null);
1717 try expect(info.fields.len == 2);
1818 try expect(info.decls.len == 0);
test/behavior/type.zig+19-19
......@@ -263,7 +263,7 @@ test "Type.Struct" {
263263
264264 const A = @Type(@typeInfo(struct { x: u8, y: u32 }));
265265 const infoA = @typeInfo(A).Struct;
266 try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout);
266 try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout);
267267 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);
268268 try testing.expectEqual(u8, infoA.fields[0].type);
269269 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);
......@@ -281,7 +281,7 @@ test "Type.Struct" {
281281
282282 const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 }));
283283 const infoB = @typeInfo(B).Struct;
284 try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout);
284 try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout);
285285 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);
286286 try testing.expectEqual(u8, infoB.fields[0].type);
287287 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);
......@@ -293,7 +293,7 @@ test "Type.Struct" {
293293
294294 const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 }));
295295 const infoC = @typeInfo(C).Struct;
296 try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout);
296 try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout);
297297 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);
298298 try testing.expectEqual(u8, infoC.fields[0].type);
299299 try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*);
......@@ -306,7 +306,7 @@ test "Type.Struct" {
306306 // anon structs
307307 const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 })));
308308 const infoD = @typeInfo(D).Struct;
309 try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout);
309 try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout);
310310 try testing.expectEqualSlices(u8, "x", infoD.fields[0].name);
311311 try testing.expectEqual(comptime_int, infoD.fields[0].type);
312312 try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*);
......@@ -319,7 +319,7 @@ test "Type.Struct" {
319319 // tuples
320320 const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 })));
321321 const infoE = @typeInfo(E).Struct;
322 try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout);
322 try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout);
323323 try testing.expectEqualSlices(u8, "0", infoE.fields[0].name);
324324 try testing.expectEqual(comptime_int, infoE.fields[0].type);
325325 try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*);
......@@ -332,14 +332,14 @@ test "Type.Struct" {
332332 // empty struct
333333 const F = @Type(@typeInfo(struct {}));
334334 const infoF = @typeInfo(F).Struct;
335 try testing.expectEqual(Type.ContainerLayout.Auto, infoF.layout);
335 try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout);
336336 try testing.expect(infoF.fields.len == 0);
337337 try testing.expectEqual(@as(bool, false), infoF.is_tuple);
338338
339339 // empty tuple
340340 const G = @Type(@typeInfo(@TypeOf(.{})));
341341 const infoG = @typeInfo(G).Struct;
342 try testing.expectEqual(Type.ContainerLayout.Auto, infoG.layout);
342 try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout);
343343 try testing.expect(infoG.fields.len == 0);
344344 try testing.expectEqual(@as(bool, true), infoG.is_tuple);
345345}
......@@ -386,7 +386,7 @@ test "Type.Union" {
386386
387387 const Untagged = @Type(.{
388388 .Union = .{
389 .layout = .Extern,
389 .layout = .@"extern",
390390 .tag_type = null,
391391 .fields = &.{
392392 .{ .name = "int", .type = i32, .alignment = @alignOf(f32) },
......@@ -402,7 +402,7 @@ test "Type.Union" {
402402
403403 const PackedUntagged = @Type(.{
404404 .Union = .{
405 .layout = .Packed,
405 .layout = .@"packed",
406406 .tag_type = null,
407407 .fields = &.{
408408 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
......@@ -429,7 +429,7 @@ test "Type.Union" {
429429 });
430430 const Tagged = @Type(.{
431431 .Union = .{
432 .layout = .Auto,
432 .layout = .auto,
433433 .tag_type = Tag,
434434 .fields = &.{
435435 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
......@@ -457,7 +457,7 @@ test "Type.Union from Type.Enum" {
457457 });
458458 const T = @Type(.{
459459 .Union = .{
460 .layout = .Auto,
460 .layout = .auto,
461461 .tag_type = Tag,
462462 .fields = &.{
463463 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },
......@@ -472,7 +472,7 @@ test "Type.Union from regular enum" {
472472 const E = enum { working_as_expected };
473473 const T = @Type(.{
474474 .Union = .{
475 .layout = .Auto,
475 .layout = .auto,
476476 .tag_type = E,
477477 .fields = &.{
478478 .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) },
......@@ -487,7 +487,7 @@ test "Type.Union from empty regular enum" {
487487 const E = enum {};
488488 const U = @Type(.{
489489 .Union = .{
490 .layout = .Auto,
490 .layout = .auto,
491491 .tag_type = E,
492492 .fields = &.{},
493493 .decls = &.{},
......@@ -507,7 +507,7 @@ test "Type.Union from empty Type.Enum" {
507507 });
508508 const U = @Type(.{
509509 .Union = .{
510 .layout = .Auto,
510 .layout = .auto,
511511 .tag_type = E,
512512 .fields = &.{},
513513 .decls = &.{},
......@@ -553,7 +553,7 @@ test "reified struct field name from optional payload" {
553553 const m_name: ?[1:0]u8 = "a".*;
554554 if (m_name) |*name| {
555555 const T = @Type(.{ .Struct = .{
556 .layout = .Auto,
556 .layout = .auto,
557557 .fields = &.{.{
558558 .name = name,
559559 .type = u8,
......@@ -575,7 +575,7 @@ test "reified union uses @alignOf" {
575575 fn CreateUnion(comptime T: type) type {
576576 return @Type(.{
577577 .Union = .{
578 .layout = .Auto,
578 .layout = .auto,
579579 .tag_type = null,
580580 .fields = &[_]std.builtin.Type.UnionField{
581581 .{
......@@ -597,7 +597,7 @@ test "reified struct uses @alignOf" {
597597 fn NamespacedGlobals(comptime modules: anytype) type {
598598 return @Type(.{
599599 .Struct = .{
600 .layout = .Auto,
600 .layout = .auto,
601601 .is_tuple = false,
602602 .fields = &.{
603603 .{
......@@ -659,7 +659,7 @@ test "empty struct assigned to reified struct field" {
659659 fn NamespacedComponents(comptime modules: anytype) type {
660660 return @Type(.{
661661 .Struct = .{
662 .layout = .Auto,
662 .layout = .auto,
663663 .is_tuple = false,
664664 .fields = &.{.{
665665 .name = "components",
......@@ -721,7 +721,7 @@ test "struct field names sliced at comptime from larger string" {
721721
722722 const T = @Type(.{
723723 .Struct = .{
724 .layout = .Auto,
724 .layout = .auto,
725725 .is_tuple = false,
726726 .fields = fields,
727727 .decls = &.{},
test/behavior/type_info.zig+4-4
......@@ -250,7 +250,7 @@ test "type info: union info" {
250250fn testUnion() !void {
251251 const typeinfo_info = @typeInfo(Type);
252252 try expect(typeinfo_info == .Union);
253 try expect(typeinfo_info.Union.layout == .Auto);
253 try expect(typeinfo_info.Union.layout == .auto);
254254 try expect(typeinfo_info.Union.tag_type.? == TypeId);
255255 try expect(typeinfo_info.Union.fields.len == 24);
256256 try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int));
......@@ -264,7 +264,7 @@ fn testUnion() !void {
264264 const notag_union_info = @typeInfo(TestNoTagUnion);
265265 try expect(notag_union_info == .Union);
266266 try expect(notag_union_info.Union.tag_type == null);
267 try expect(notag_union_info.Union.layout == .Auto);
267 try expect(notag_union_info.Union.layout == .auto);
268268 try expect(notag_union_info.Union.fields.len == 2);
269269 try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void));
270270 try expect(notag_union_info.Union.fields[1].type == u32);
......@@ -275,7 +275,7 @@ fn testUnion() !void {
275275 };
276276
277277 const extern_union_info = @typeInfo(TestExternUnion);
278 try expect(extern_union_info.Union.layout == .Extern);
278 try expect(extern_union_info.Union.layout == .@"extern");
279279 try expect(extern_union_info.Union.tag_type == null);
280280 try expect(extern_union_info.Union.fields[0].type == *anyopaque);
281281}
......@@ -310,7 +310,7 @@ fn testPackedStruct() !void {
310310 const struct_info = @typeInfo(TestPackedStruct);
311311 try expect(struct_info == .Struct);
312312 try expect(struct_info.Struct.is_tuple == false);
313 try expect(struct_info.Struct.layout == .Packed);
313 try expect(struct_info.Struct.layout == .@"packed");
314314 try expect(struct_info.Struct.backing_integer == u128);
315315 try expect(struct_info.Struct.fields.len == 4);
316316 try expect(struct_info.Struct.fields[0].alignment == 0);
test/cases/compile_errors/packed_struct_field_alignment_unavailable_for_reify_type.zig+1-1
......@@ -1,5 +1,5 @@
11export fn entry() void {
2 _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{
2 _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{
33 .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 },
44 }, .decls = &.{}, .is_tuple = false } });
55}
test/cases/compile_errors/reify_struct.zig+5-5
......@@ -1,6 +1,6 @@
11comptime {
22 @Type(.{ .Struct = .{
3 .layout = .Auto,
3 .layout = .auto,
44 .fields = &.{.{
55 .name = "foo",
66 .type = u32,
......@@ -14,7 +14,7 @@ comptime {
1414}
1515comptime {
1616 @Type(.{ .Struct = .{
17 .layout = .Auto,
17 .layout = .auto,
1818 .fields = &.{.{
1919 .name = "3",
2020 .type = u32,
......@@ -28,7 +28,7 @@ comptime {
2828}
2929comptime {
3030 @Type(.{ .Struct = .{
31 .layout = .Auto,
31 .layout = .auto,
3232 .fields = &.{.{
3333 .name = "0",
3434 .type = u32,
......@@ -42,7 +42,7 @@ comptime {
4242}
4343comptime {
4444 @Type(.{ .Struct = .{
45 .layout = .Extern,
45 .layout = .@"extern",
4646 .fields = &.{.{
4747 .name = "0",
4848 .type = u32,
......@@ -56,7 +56,7 @@ comptime {
5656}
5757comptime {
5858 @Type(.{ .Struct = .{
59 .layout = .Packed,
59 .layout = .@"packed",
6060 .fields = &.{.{
6161 .name = "0",
6262 .type = u32,
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig+1-1
......@@ -12,7 +12,7 @@ const Tag = @Type(.{
1212});
1313const Tagged = @Type(.{
1414 .Union = .{
15 .layout = .Auto,
15 .layout = .auto,
1616 .tag_type = Tag,
1717 .fields = &.{
1818 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig+1-1
......@@ -11,7 +11,7 @@ const Tag = @Type(.{
1111});
1212const Tagged = @Type(.{
1313 .Union = .{
14 .layout = .Auto,
14 .layout = .auto,
1515 .tag_type = Tag,
1616 .fields = &.{
1717 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
test/cases/compile_errors/reify_type_for_tagged_union_with_no_enum_fields.zig+1-1
......@@ -8,7 +8,7 @@ const Tag = @Type(.{
88});
99const Tagged = @Type(.{
1010 .Union = .{
11 .layout = .Auto,
11 .layout = .auto,
1212 .tag_type = Tag,
1313 .fields = &.{
1414 .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) },
test/cases/compile_errors/reify_type_for_tagged_union_with_no_union_fields.zig+1-1
......@@ -11,7 +11,7 @@ const Tag = @Type(.{
1111});
1212const Tagged = @Type(.{
1313 .Union = .{
14 .layout = .Auto,
14 .layout = .auto,
1515 .tag_type = Tag,
1616 .fields = &.{},
1717 .decls = &.{},
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+1-1
......@@ -1,6 +1,6 @@
11const Untagged = @Type(.{
22 .Union = .{
3 .layout = .Auto,
3 .layout = .auto,
44 .tag_type = null,
55 .fields = &.{
66 .{ .name = "foo", .type = opaque {}, .alignment = 1 },
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+2-2
......@@ -1,7 +1,7 @@
11comptime {
22 _ = @Type(.{
33 .Union = .{
4 .layout = .Auto,
4 .layout = .auto,
55 .tag_type = null,
66 .fields = &.{
77 .{ .name = "foo", .type = usize, .alignment = 3 },
......@@ -13,7 +13,7 @@ comptime {
1313comptime {
1414 _ = @Type(.{
1515 .Struct = .{
16 .layout = .Auto,
16 .layout = .auto,
1717 .fields = &.{.{
1818 .name = "0",
1919 .type = u32,
test/cases/compile_errors/reify_type_with_undefined.zig+2-2
......@@ -7,7 +7,7 @@ comptime {
77 .fields = undefined,
88 .decls = undefined,
99 .is_tuple = false,
10 .layout = .Auto,
10 .layout = .auto,
1111 },
1212 });
1313}
......@@ -16,7 +16,7 @@ comptime {
1616 const fields: [1]std.builtin.Type.StructField = undefined;
1717 _ = @Type(.{
1818 .Struct = .{
19 .layout = .Auto,
19 .layout = .auto,
2020 .fields = &fields,
2121 .decls = &.{},
2222 .is_tuple = false,