| author | |
| committer | |
| log | 099f3c4039d5702b073639ef8b55881973b71c80 |
| tree | 2be1bb7abc86fb4c9148b82314718eac6a01e895 |
| parent | d0c06ca7127110a8afeb0ef524a197049892db21 |
| signature |
45 files changed, 291 insertions(+), 293 deletions(-)
lib/compiler/aro/aro/Attribute.zig+1-1| ... | ... | @@ -653,7 +653,7 @@ pub const Arguments = blk: { |
| 653 | 653 | |
| 654 | 654 | break :blk @Type(.{ |
| 655 | 655 | .Union = .{ |
| 656 | .layout = .Auto, | |
| 656 | .layout = .auto, | |
| 657 | 657 | .tag_type = null, |
| 658 | 658 | .fields = &union_fields, |
| 659 | 659 | .decls = &.{}, |
lib/std/builtin.zig+4-4| ... | ... | @@ -334,9 +334,9 @@ pub const Type = union(enum) { |
| 334 | 334 | /// This data structure is used by the Zig language code generation and |
| 335 | 335 | /// therefore must be kept in sync with the compiler implementation. |
| 336 | 336 | pub const ContainerLayout = enum(u2) { |
| 337 | Auto, | |
| 338 | Extern, | |
| 339 | Packed, | |
| 337 | auto, | |
| 338 | @"extern", | |
| 339 | @"packed", | |
| 340 | 340 | }; |
| 341 | 341 | |
| 342 | 342 | /// This data structure is used by the Zig language code generation and |
| ... | ... | @@ -353,7 +353,7 @@ pub const Type = union(enum) { |
| 353 | 353 | /// therefore must be kept in sync with the compiler implementation. |
| 354 | 354 | pub const Struct = struct { |
| 355 | 355 | layout: ContainerLayout, |
| 356 | /// Only valid if layout is .Packed | |
| 356 | /// Only valid if layout is .@"packed" | |
| 357 | 357 | backing_integer: ?type = null, |
| 358 | 358 | fields: []const StructField, |
| 359 | 359 | 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 |
| 22 | 22 | }}; |
| 23 | 23 | } |
| 24 | 24 | return @Type(.{ .Struct = .{ |
| 25 | .layout = .Auto, | |
| 25 | .layout = .auto, | |
| 26 | 26 | .fields = fields, |
| 27 | 27 | .decls = &.{}, |
| 28 | 28 | .is_tuple = false, |
lib/std/io.zig+1-1| ... | ... | @@ -688,7 +688,7 @@ pub fn PollFiles(comptime StreamEnum: type) type { |
| 688 | 688 | }; |
| 689 | 689 | } |
| 690 | 690 | return @Type(.{ .Struct = .{ |
| 691 | .layout = .Auto, | |
| 691 | .layout = .auto, | |
| 692 | 692 | .fields = &struct_fields, |
| 693 | 693 | .decls = &.{}, |
| 694 | 694 | .is_tuple = false, |
lib/std/io/Reader.zig+1-1| ... | ... | @@ -326,7 +326,7 @@ pub fn isBytes(self: Self, slice: []const u8) anyerror!bool { |
| 326 | 326 | |
| 327 | 327 | pub fn readStruct(self: Self, comptime T: type) anyerror!T { |
| 328 | 328 | // 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); | |
| 330 | 330 | var res: [1]T = undefined; |
| 331 | 331 | try self.readNoEof(mem.sliceAsBytes(res[0..])); |
| 332 | 332 | 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 |
| 55 | 55 | |
| 56 | 56 | pub fn writeStruct(self: Self, value: anytype) anyerror!void { |
| 57 | 57 | // 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); | |
| 59 | 59 | return self.writeAll(mem.asBytes(&value)); |
| 60 | 60 | } |
| 61 | 61 |
lib/std/mem.zig+3-3| ... | ... | @@ -238,7 +238,7 @@ pub fn zeroes(comptime T: type) T { |
| 238 | 238 | }, |
| 239 | 239 | .Struct => |struct_info| { |
| 240 | 240 | if (@sizeOf(T) == 0) return undefined; |
| 241 | if (struct_info.layout == .Extern) { | |
| 241 | if (struct_info.layout == .@"extern") { | |
| 242 | 242 | var item: T = undefined; |
| 243 | 243 | @memset(asBytes(&item), 0); |
| 244 | 244 | return item; |
| ... | ... | @@ -284,7 +284,7 @@ pub fn zeroes(comptime T: type) T { |
| 284 | 284 | return @splat(zeroes(info.child)); |
| 285 | 285 | }, |
| 286 | 286 | .Union => |info| { |
| 287 | if (info.layout == .Extern) { | |
| 287 | if (info.layout == .@"extern") { | |
| 288 | 288 | var item: T = undefined; |
| 289 | 289 | @memset(asBytes(&item), 0); |
| 290 | 290 | return item; |
| ... | ... | @@ -429,7 +429,7 @@ pub fn zeroInit(comptime T: type, init: anytype) T { |
| 429 | 429 | } |
| 430 | 430 | } |
| 431 | 431 | |
| 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; | |
| 433 | 433 | |
| 434 | 434 | inline for (struct_info.fields, 0..) |field, i| { |
| 435 | 435 | if (field.is_comptime) { |
lib/std/meta.zig+7-7| ... | ... | @@ -269,12 +269,12 @@ test containerLayout { |
| 269 | 269 | a: u8, |
| 270 | 270 | }; |
| 271 | 271 | |
| 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"); | |
| 278 | 278 | } |
| 279 | 279 | |
| 280 | 280 | /// 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 { |
| 1025 | 1025 | return @Type(.{ |
| 1026 | 1026 | .Struct = .{ |
| 1027 | 1027 | .is_tuple = true, |
| 1028 | .layout = .Auto, | |
| 1028 | .layout = .auto, | |
| 1029 | 1029 | .decls = &.{}, |
| 1030 | 1030 | .fields = &tuple_fields, |
| 1031 | 1031 | }, |
lib/std/meta/trailer_flags.zig+1-1| ... | ... | @@ -32,7 +32,7 @@ pub fn TrailerFlags(comptime Fields: type) type { |
| 32 | 32 | } |
| 33 | 33 | break :blk @Type(.{ |
| 34 | 34 | .Struct = .{ |
| 35 | .layout = .Auto, | |
| 35 | .layout = .auto, | |
| 36 | 36 | .fields = &fields, |
| 37 | 37 | .decls = &.{}, |
| 38 | 38 | .is_tuple = false, |
lib/std/multi_array_list.zig+1-1| ... | ... | @@ -558,7 +558,7 @@ pub fn MultiArrayList(comptime T: type) type { |
| 558 | 558 | .alignment = fields[i].alignment, |
| 559 | 559 | }; |
| 560 | 560 | break :entry @Type(.{ .Struct = .{ |
| 561 | .layout = .Extern, | |
| 561 | .layout = .@"extern", | |
| 562 | 562 | .fields = &entry_fields, |
| 563 | 563 | .decls = &.{}, |
| 564 | 564 | .is_tuple = false, |
lib/std/zig/AstGen.zig+20-21| ... | ... | @@ -175,7 +175,7 @@ pub fn generate(gpa: Allocator, tree: Ast) Allocator.Error!Zir { |
| 175 | 175 | &gen_scope.base, |
| 176 | 176 | 0, |
| 177 | 177 | tree.containerDeclRoot(), |
| 178 | .Auto, | |
| 178 | .auto, | |
| 179 | 179 | 0, |
| 180 | 180 | )) |struct_decl_ref| { |
| 181 | 181 | assert(struct_decl_ref.toIndex().? == .main_struct_inst); |
| ... | ... | @@ -4907,7 +4907,7 @@ fn structDeclInner( |
| 4907 | 4907 | var backing_int_body_len: usize = 0; |
| 4908 | 4908 | const backing_int_ref: Zir.Inst.Ref = blk: { |
| 4909 | 4909 | if (backing_int_node != 0) { |
| 4910 | if (layout != .Packed) { | |
| 4910 | if (layout != .@"packed") { | |
| 4911 | 4911 | return astgen.failNode(backing_int_node, "non-packed struct does not support backing integer type", .{}); |
| 4912 | 4912 | } else { |
| 4913 | 4913 | const backing_int_ref = try typeExpr(&block_scope, &namespace.base, backing_int_node); |
| ... | ... | @@ -4958,9 +4958,9 @@ fn structDeclInner( |
| 4958 | 4958 | } else false; |
| 4959 | 4959 | |
| 4960 | 4960 | 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", .{}), | |
| 4964 | 4964 | }; |
| 4965 | 4965 | |
| 4966 | 4966 | if (is_tuple) for (container_decl.ast.members) |member_node| { |
| ... | ... | @@ -5055,9 +5055,9 @@ fn structDeclInner( |
| 5055 | 5055 | |
| 5056 | 5056 | if (is_comptime) { |
| 5057 | 5057 | 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, | |
| 5061 | 5061 | } |
| 5062 | 5062 | } else { |
| 5063 | 5063 | known_non_opv = known_non_opv or |
| ... | ... | @@ -5082,7 +5082,7 @@ fn structDeclInner( |
| 5082 | 5082 | } |
| 5083 | 5083 | |
| 5084 | 5084 | if (have_align) { |
| 5085 | if (layout == .Packed) { | |
| 5085 | if (layout == .@"packed") { | |
| 5086 | 5086 | try astgen.appendErrorNode(member.ast.align_expr, "unable to override alignment of packed struct fields", .{}); |
| 5087 | 5087 | } |
| 5088 | 5088 | any_aligned_fields = true; |
| ... | ... | @@ -5229,12 +5229,11 @@ fn unionDeclInner( |
| 5229 | 5229 | const decl_count = try astgen.scanDecls(&namespace, members); |
| 5230 | 5230 | const field_count: u32 = @intCast(members.len - decl_count); |
| 5231 | 5231 | |
| 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)) { | |
| 5234 | 5233 | 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)}); | |
| 5236 | 5235 | } 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)}); | |
| 5238 | 5237 | } |
| 5239 | 5238 | } |
| 5240 | 5239 | |
| ... | ... | @@ -5429,21 +5428,21 @@ fn containerDecl( |
| 5429 | 5428 | |
| 5430 | 5429 | switch (token_tags[container_decl.ast.main_token]) { |
| 5431 | 5430 | .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", | |
| 5435 | 5434 | else => unreachable, |
| 5436 | } else std.builtin.Type.ContainerLayout.Auto; | |
| 5435 | } else .auto; | |
| 5437 | 5436 | |
| 5438 | 5437 | const result = try structDeclInner(gz, scope, node, container_decl, layout, container_decl.ast.arg); |
| 5439 | 5438 | return rvalue(gz, ri, result, node); |
| 5440 | 5439 | }, |
| 5441 | 5440 | .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", | |
| 5445 | 5444 | else => unreachable, |
| 5446 | } else std.builtin.Type.ContainerLayout.Auto; | |
| 5445 | } else .auto; | |
| 5447 | 5446 | |
| 5448 | 5447 | const result = try unionDeclInner(gz, scope, node, container_decl.ast.members, layout, container_decl.ast.arg, container_decl.ast.enum_token); |
| 5449 | 5448 | return rvalue(gz, ri, result, node); |
lib/std/zig/Server.zig+3-3| ... | ... | @@ -250,18 +250,18 @@ fn bswap(x: anytype) @TypeOf(x) { |
| 250 | 250 | .Enum => return @as(T, @enumFromInt(@byteSwap(@intFromEnum(x)))), |
| 251 | 251 | .Int => return @byteSwap(x), |
| 252 | 252 | .Struct => |info| switch (info.layout) { |
| 253 | .Extern => { | |
| 253 | .@"extern" => { | |
| 254 | 254 | var result: T = undefined; |
| 255 | 255 | inline for (info.fields) |field| { |
| 256 | 256 | @field(result, field.name) = bswap(@field(x, field.name)); |
| 257 | 257 | } |
| 258 | 258 | return result; |
| 259 | 259 | }, |
| 260 | .Packed => { | |
| 260 | .@"packed" => { | |
| 261 | 261 | const I = info.backing_integer.?; |
| 262 | 262 | return @as(T, @bitCast(@byteSwap(@as(I, @bitCast(x))))); |
| 263 | 263 | }, |
| 264 | .Auto => @compileError("auto layout struct"), | |
| 264 | .auto => @compileError("auto layout struct"), | |
| 265 | 265 | }, |
| 266 | 266 | else => @compileError("bswap on type " ++ @typeName(T)), |
| 267 | 267 | } |
src/InternPool.zig+35-36| ... | ... | @@ -2025,15 +2025,15 @@ pub const LoadedStructType = struct { |
| 2025 | 2025 | /// complicated logic. |
| 2026 | 2026 | pub fn knownNonOpv(s: @This(), ip: *InternPool) bool { |
| 2027 | 2027 | 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, | |
| 2030 | 2030 | }; |
| 2031 | 2031 | } |
| 2032 | 2032 | |
| 2033 | 2033 | /// The returned pointer expires with any addition to the `InternPool`. |
| 2034 | 2034 | /// Asserts the struct is not packed. |
| 2035 | 2035 | pub fn flagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStruct.Flags { |
| 2036 | assert(self.layout != .Packed); | |
| 2036 | assert(self.layout != .@"packed"); | |
| 2037 | 2037 | const flags_field_index = std.meta.fieldIndex(Tag.TypeStruct, "flags").?; |
| 2038 | 2038 | return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]); |
| 2039 | 2039 | } |
| ... | ... | @@ -2041,13 +2041,13 @@ pub const LoadedStructType = struct { |
| 2041 | 2041 | /// The returned pointer expires with any addition to the `InternPool`. |
| 2042 | 2042 | /// Asserts that the struct is packed. |
| 2043 | 2043 | pub fn packedFlagsPtr(self: @This(), ip: *const InternPool) *Tag.TypeStructPacked.Flags { |
| 2044 | assert(self.layout == .Packed); | |
| 2044 | assert(self.layout == .@"packed"); | |
| 2045 | 2045 | const flags_field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "flags").?; |
| 2046 | 2046 | return @ptrCast(&ip.extra.items[self.extra_index + flags_field_index]); |
| 2047 | 2047 | } |
| 2048 | 2048 | |
| 2049 | 2049 | pub fn assumeRuntimeBitsIfFieldTypesWip(s: @This(), ip: *InternPool) bool { |
| 2050 | if (s.layout == .Packed) return false; | |
| 2050 | if (s.layout == .@"packed") return false; | |
| 2051 | 2051 | const flags_ptr = s.flagsPtr(ip); |
| 2052 | 2052 | if (flags_ptr.field_types_wip) { |
| 2053 | 2053 | flags_ptr.assumed_runtime_bits = true; |
| ... | ... | @@ -2057,7 +2057,7 @@ pub const LoadedStructType = struct { |
| 2057 | 2057 | } |
| 2058 | 2058 | |
| 2059 | 2059 | pub fn setTypesWip(s: @This(), ip: *InternPool) bool { |
| 2060 | if (s.layout == .Packed) return false; | |
| 2060 | if (s.layout == .@"packed") return false; | |
| 2061 | 2061 | const flags_ptr = s.flagsPtr(ip); |
| 2062 | 2062 | if (flags_ptr.field_types_wip) return true; |
| 2063 | 2063 | flags_ptr.field_types_wip = true; |
| ... | ... | @@ -2065,12 +2065,12 @@ pub const LoadedStructType = struct { |
| 2065 | 2065 | } |
| 2066 | 2066 | |
| 2067 | 2067 | pub fn clearTypesWip(s: @This(), ip: *InternPool) void { |
| 2068 | if (s.layout == .Packed) return; | |
| 2068 | if (s.layout == .@"packed") return; | |
| 2069 | 2069 | s.flagsPtr(ip).field_types_wip = false; |
| 2070 | 2070 | } |
| 2071 | 2071 | |
| 2072 | 2072 | pub fn setLayoutWip(s: @This(), ip: *InternPool) bool { |
| 2073 | if (s.layout == .Packed) return false; | |
| 2073 | if (s.layout == .@"packed") return false; | |
| 2074 | 2074 | const flags_ptr = s.flagsPtr(ip); |
| 2075 | 2075 | if (flags_ptr.layout_wip) return true; |
| 2076 | 2076 | flags_ptr.layout_wip = true; |
| ... | ... | @@ -2078,12 +2078,12 @@ pub const LoadedStructType = struct { |
| 2078 | 2078 | } |
| 2079 | 2079 | |
| 2080 | 2080 | pub fn clearLayoutWip(s: @This(), ip: *InternPool) void { |
| 2081 | if (s.layout == .Packed) return; | |
| 2081 | if (s.layout == .@"packed") return; | |
| 2082 | 2082 | s.flagsPtr(ip).layout_wip = false; |
| 2083 | 2083 | } |
| 2084 | 2084 | |
| 2085 | 2085 | pub fn setAlignmentWip(s: @This(), ip: *InternPool) bool { |
| 2086 | if (s.layout == .Packed) return false; | |
| 2086 | if (s.layout == .@"packed") return false; | |
| 2087 | 2087 | const flags_ptr = s.flagsPtr(ip); |
| 2088 | 2088 | if (flags_ptr.alignment_wip) return true; |
| 2089 | 2089 | flags_ptr.alignment_wip = true; |
| ... | ... | @@ -2091,19 +2091,19 @@ pub const LoadedStructType = struct { |
| 2091 | 2091 | } |
| 2092 | 2092 | |
| 2093 | 2093 | pub fn clearAlignmentWip(s: @This(), ip: *InternPool) void { |
| 2094 | if (s.layout == .Packed) return; | |
| 2094 | if (s.layout == .@"packed") return; | |
| 2095 | 2095 | s.flagsPtr(ip).alignment_wip = false; |
| 2096 | 2096 | } |
| 2097 | 2097 | |
| 2098 | 2098 | pub fn setInitsWip(s: @This(), ip: *InternPool) bool { |
| 2099 | 2099 | switch (s.layout) { |
| 2100 | .Packed => { | |
| 2100 | .@"packed" => { | |
| 2101 | 2101 | const flag = &s.packedFlagsPtr(ip).field_inits_wip; |
| 2102 | 2102 | if (flag.*) return true; |
| 2103 | 2103 | flag.* = true; |
| 2104 | 2104 | return false; |
| 2105 | 2105 | }, |
| 2106 | .Auto, .Extern => { | |
| 2106 | .auto, .@"extern" => { | |
| 2107 | 2107 | const flag = &s.flagsPtr(ip).field_inits_wip; |
| 2108 | 2108 | if (flag.*) return true; |
| 2109 | 2109 | flag.* = true; |
| ... | ... | @@ -2114,13 +2114,13 @@ pub const LoadedStructType = struct { |
| 2114 | 2114 | |
| 2115 | 2115 | pub fn clearInitsWip(s: @This(), ip: *InternPool) void { |
| 2116 | 2116 | 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, | |
| 2119 | 2119 | } |
| 2120 | 2120 | } |
| 2121 | 2121 | |
| 2122 | 2122 | pub fn setFullyResolved(s: @This(), ip: *InternPool) bool { |
| 2123 | if (s.layout == .Packed) return true; | |
| 2123 | if (s.layout == .@"packed") return true; | |
| 2124 | 2124 | const flags_ptr = s.flagsPtr(ip); |
| 2125 | 2125 | if (flags_ptr.fully_resolved) return true; |
| 2126 | 2126 | flags_ptr.fully_resolved = true; |
| ... | ... | @@ -2134,7 +2134,7 @@ pub const LoadedStructType = struct { |
| 2134 | 2134 | /// The returned pointer expires with any addition to the `InternPool`. |
| 2135 | 2135 | /// Asserts the struct is not packed. |
| 2136 | 2136 | pub fn size(self: @This(), ip: *InternPool) *u32 { |
| 2137 | assert(self.layout != .Packed); | |
| 2137 | assert(self.layout != .@"packed"); | |
| 2138 | 2138 | const size_field_index = std.meta.fieldIndex(Tag.TypeStruct, "size").?; |
| 2139 | 2139 | return @ptrCast(&ip.extra.items[self.extra_index + size_field_index]); |
| 2140 | 2140 | } |
| ... | ... | @@ -2144,14 +2144,14 @@ pub const LoadedStructType = struct { |
| 2144 | 2144 | /// set to `none` until the layout is resolved. |
| 2145 | 2145 | /// Asserts the struct is packed. |
| 2146 | 2146 | pub fn backingIntType(s: @This(), ip: *const InternPool) *Index { |
| 2147 | assert(s.layout == .Packed); | |
| 2147 | assert(s.layout == .@"packed"); | |
| 2148 | 2148 | const field_index = std.meta.fieldIndex(Tag.TypeStructPacked, "backing_int_ty").?; |
| 2149 | 2149 | return @ptrCast(&ip.extra.items[s.extra_index + field_index]); |
| 2150 | 2150 | } |
| 2151 | 2151 | |
| 2152 | 2152 | /// Asserts the struct is not packed. |
| 2153 | 2153 | pub fn setZirIndex(s: @This(), ip: *InternPool, new_zir_index: TrackedInst.Index.Optional) void { |
| 2154 | assert(s.layout != .Packed); | |
| 2154 | assert(s.layout != .@"packed"); | |
| 2155 | 2155 | const field_index = std.meta.fieldIndex(Tag.TypeStruct, "zir_index").?; |
| 2156 | 2156 | ip.extra.items[s.extra_index + field_index] = @intFromEnum(new_zir_index); |
| 2157 | 2157 | } |
| ... | ... | @@ -2163,31 +2163,31 @@ pub const LoadedStructType = struct { |
| 2163 | 2163 | |
| 2164 | 2164 | pub fn haveFieldInits(s: @This(), ip: *const InternPool) bool { |
| 2165 | 2165 | 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, | |
| 2168 | 2168 | }; |
| 2169 | 2169 | } |
| 2170 | 2170 | |
| 2171 | 2171 | pub fn setHaveFieldInits(s: @This(), ip: *InternPool) void { |
| 2172 | 2172 | 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, | |
| 2175 | 2175 | } |
| 2176 | 2176 | } |
| 2177 | 2177 | |
| 2178 | 2178 | pub fn haveLayout(s: @This(), ip: *InternPool) bool { |
| 2179 | 2179 | 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, | |
| 2182 | 2182 | }; |
| 2183 | 2183 | } |
| 2184 | 2184 | |
| 2185 | 2185 | 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; | |
| 2187 | 2187 | } |
| 2188 | 2188 | |
| 2189 | 2189 | pub fn hasReorderedFields(s: @This()) bool { |
| 2190 | return s.layout == .Auto; | |
| 2190 | return s.layout == .auto; | |
| 2191 | 2191 | } |
| 2192 | 2192 | |
| 2193 | 2193 | pub const RuntimeOrderIterator = struct { |
| ... | ... | @@ -2221,7 +2221,7 @@ pub const LoadedStructType = struct { |
| 2221 | 2221 | /// May or may not include zero-bit fields. |
| 2222 | 2222 | /// Asserts the struct is not packed. |
| 2223 | 2223 | pub fn iterateRuntimeOrder(s: @This(), ip: *InternPool) RuntimeOrderIterator { |
| 2224 | assert(s.layout != .Packed); | |
| 2224 | assert(s.layout != .@"packed"); | |
| 2225 | 2225 | return .{ |
| 2226 | 2226 | .ip = ip, |
| 2227 | 2227 | .field_index = 0, |
| ... | ... | @@ -2239,7 +2239,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 2239 | 2239 | .decl = .none, |
| 2240 | 2240 | .namespace = .none, |
| 2241 | 2241 | .zir_index = .none, |
| 2242 | .layout = .Auto, | |
| 2242 | .layout = .auto, | |
| 2243 | 2243 | .field_names = .{ .start = 0, .len = 0 }, |
| 2244 | 2244 | .field_types = .{ .start = 0, .len = 0 }, |
| 2245 | 2245 | .field_inits = .{ .start = 0, .len = 0 }, |
| ... | ... | @@ -2314,7 +2314,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 2314 | 2314 | .decl = extra.data.decl.toOptional(), |
| 2315 | 2315 | .namespace = namespace, |
| 2316 | 2316 | .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, | |
| 2318 | 2318 | .field_names = names, |
| 2319 | 2319 | .field_types = field_types, |
| 2320 | 2320 | .field_inits = inits, |
| ... | ... | @@ -2367,7 +2367,7 @@ pub fn loadStructType(ip: *const InternPool, index: Index) LoadedStructType { |
| 2367 | 2367 | .decl = extra.data.decl.toOptional(), |
| 2368 | 2368 | .namespace = extra.data.namespace, |
| 2369 | 2369 | .zir_index = extra.data.zir_index.toOptional(), |
| 2370 | .layout = .Packed, | |
| 2370 | .layout = .@"packed", | |
| 2371 | 2371 | .field_names = field_names, |
| 2372 | 2372 | .field_types = field_types, |
| 2373 | 2373 | .field_inits = field_inits, |
| ... | ... | @@ -4455,7 +4455,6 @@ pub fn indexToKey(ip: *const InternPool, index: Index) Key { |
| 4455 | 4455 | } else .{ .start = 0, .len = 0 } }, |
| 4456 | 4456 | } }; |
| 4457 | 4457 | } }, |
| 4458 | ||
| 4459 | 4458 | .type_struct_anon => .{ .anon_struct_type = extraTypeStructAnon(ip, data) }, |
| 4460 | 4459 | .type_tuple_anon => .{ .anon_struct_type = extraTypeTupleAnon(ip, data) }, |
| 4461 | 4460 | .type_union => .{ .union_type = ns: { |
| ... | ... | @@ -6009,9 +6008,9 @@ pub fn getStructType( |
| 6009 | 6008 | }; |
| 6010 | 6009 | |
| 6011 | 6010 | const is_extern = switch (ini.layout) { |
| 6012 | .Auto => false, | |
| 6013 | .Extern => true, | |
| 6014 | .Packed => { | |
| 6011 | .auto => false, | |
| 6012 | .@"extern" => true, | |
| 6013 | .@"packed" => { | |
| 6015 | 6014 | try ip.extra.ensureUnusedCapacity(gpa, @typeInfo(Tag.TypeStructPacked).Struct.fields.len + |
| 6016 | 6015 | // TODO: fmt bug |
| 6017 | 6016 | // zig fmt: off |
| ... | ... | @@ -6140,7 +6139,7 @@ pub fn getStructType( |
| 6140 | 6139 | if (ini.any_comptime_fields) { |
| 6141 | 6140 | ip.extra.appendNTimesAssumeCapacity(0, comptime_elements_len); |
| 6142 | 6141 | } |
| 6143 | if (ini.layout == .Auto) { | |
| 6142 | if (ini.layout == .auto) { | |
| 6144 | 6143 | ip.extra.appendNTimesAssumeCapacity(@intFromEnum(LoadedStructType.RuntimeOrder.unresolved), ini.fields_len); |
| 6145 | 6144 | } |
| 6146 | 6145 | 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 |
| 3310 | 3310 | const small: Zir.Inst.StructDecl.Small = @bitCast(extended.small); |
| 3311 | 3311 | assert(!small.has_captures_len); |
| 3312 | 3312 | assert(!small.has_backing_int); |
| 3313 | assert(small.layout == .Auto); | |
| 3313 | assert(small.layout == .auto); | |
| 3314 | 3314 | var extra_index: usize = extended.operand + @typeInfo(Zir.Inst.StructDecl).Struct.fields.len; |
| 3315 | 3315 | const fields_len = if (small.has_fields_len) blk: { |
| 3316 | 3316 | const fields_len = file.zir.extra[extra_index]; |
| ... | ... | @@ -3327,7 +3327,7 @@ fn getFileRootStruct(zcu: *Zcu, decl_index: Decl.Index, namespace_index: Namespa |
| 3327 | 3327 | |
| 3328 | 3328 | const tracked_inst = try ip.trackZir(gpa, file, .main_struct_inst); |
| 3329 | 3329 | const wip_ty = switch (try ip.getStructType(gpa, .{ |
| 3330 | .layout = .Auto, | |
| 3330 | .layout = .auto, | |
| 3331 | 3331 | .fields_len = fields_len, |
| 3332 | 3332 | .known_non_opv = small.known_non_opv, |
| 3333 | 3333 | .requires_comptime = if (small.known_comptime_only) .yes else .unknown, |
| ... | ... | @@ -5969,7 +5969,7 @@ pub fn typeToStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType { |
| 5969 | 5969 | |
| 5970 | 5970 | pub fn typeToPackedStruct(mod: *Module, ty: Type) ?InternPool.LoadedStructType { |
| 5971 | 5971 | const s = mod.typeToStruct(ty) orelse return null; |
| 5972 | if (s.layout != .Packed) return null; | |
| 5972 | if (s.layout != .@"packed") return null; | |
| 5973 | 5973 | return s; |
| 5974 | 5974 | } |
| 5975 | 5975 | |
| ... | ... | @@ -6185,18 +6185,18 @@ pub fn structFieldAlignment( |
| 6185 | 6185 | field_ty: Type, |
| 6186 | 6186 | layout: std.builtin.Type.ContainerLayout, |
| 6187 | 6187 | ) Alignment { |
| 6188 | assert(layout != .Packed); | |
| 6188 | assert(layout != .@"packed"); | |
| 6189 | 6189 | if (explicit_alignment != .none) return explicit_alignment; |
| 6190 | 6190 | switch (layout) { |
| 6191 | .Packed => unreachable, | |
| 6192 | .Auto => { | |
| 6191 | .@"packed" => unreachable, | |
| 6192 | .auto => { | |
| 6193 | 6193 | if (mod.getTarget().ofmt == .c) { |
| 6194 | 6194 | return structFieldAlignmentExtern(mod, field_ty); |
| 6195 | 6195 | } else { |
| 6196 | 6196 | return field_ty.abiAlignment(mod); |
| 6197 | 6197 | } |
| 6198 | 6198 | }, |
| 6199 | .Extern => return structFieldAlignmentExtern(mod, field_ty), | |
| 6199 | .@"extern" => return structFieldAlignmentExtern(mod, field_ty), | |
| 6200 | 6200 | } |
| 6201 | 6201 | } |
| 6202 | 6202 | |
| ... | ... | @@ -6224,7 +6224,7 @@ pub fn structPackedFieldBitOffset( |
| 6224 | 6224 | field_index: u32, |
| 6225 | 6225 | ) u16 { |
| 6226 | 6226 | const ip = &mod.intern_pool; |
| 6227 | assert(struct_type.layout == .Packed); | |
| 6227 | assert(struct_type.layout == .@"packed"); | |
| 6228 | 6228 | assert(struct_type.haveLayout(ip)); |
| 6229 | 6229 | var bit_sum: u64 = 0; |
| 6230 | 6230 | for (0..struct_type.field_types.len) |i| { |
src/Sema.zig+54-54| ... | ... | @@ -3236,7 +3236,7 @@ fn zirUnionDecl( |
| 3236 | 3236 | .status = .none, |
| 3237 | 3237 | .runtime_tag = if (small.has_tag_type or small.auto_enum_tag) |
| 3238 | 3238 | .tagged |
| 3239 | else if (small.layout != .Auto) | |
| 3239 | else if (small.layout != .auto) | |
| 3240 | 3240 | .none |
| 3241 | 3241 | else switch (block.wantSafety()) { |
| 3242 | 3242 | true => .safety, |
| ... | ... | @@ -10380,7 +10380,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10380 | 10380 | }; |
| 10381 | 10381 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10382 | 10382 | }, |
| 10383 | .Struct, .Union => if (dest_ty.containerLayout(mod) == .Auto) { | |
| 10383 | .Struct, .Union => if (dest_ty.containerLayout(mod) == .auto) { | |
| 10384 | 10384 | const container = switch (dest_ty.zigTypeTag(mod)) { |
| 10385 | 10385 | .Struct => "struct", |
| 10386 | 10386 | .Union => "union", |
| ... | ... | @@ -10443,7 +10443,7 @@ fn zirBitcast(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air |
| 10443 | 10443 | }; |
| 10444 | 10444 | return sema.failWithOwnedErrorMsg(block, msg); |
| 10445 | 10445 | }, |
| 10446 | .Struct, .Union => if (operand_ty.containerLayout(mod) == .Auto) { | |
| 10446 | .Struct, .Union => if (operand_ty.containerLayout(mod) == .auto) { | |
| 10447 | 10447 | const container = switch (operand_ty.zigTypeTag(mod)) { |
| 10448 | 10448 | .Struct => "struct", |
| 10449 | 10449 | .Union => "union", |
| ... | ... | @@ -18131,8 +18131,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai |
| 18131 | 18131 | }; |
| 18132 | 18132 | |
| 18133 | 18133 | 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, | |
| 18136 | 18136 | }; |
| 18137 | 18137 | |
| 18138 | 18138 | 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 |
| 18350 | 18350 | const opt_default_val = if (field_init == .none) null else Value.fromInterned(field_init); |
| 18351 | 18351 | const default_val_ptr = try sema.optRefValue(opt_default_val); |
| 18352 | 18352 | const alignment = switch (struct_type.layout) { |
| 18353 | .Packed => .none, | |
| 18353 | .@"packed" => .none, | |
| 18354 | 18354 | else => try sema.structFieldAlignment( |
| 18355 | 18355 | struct_type.fieldAlign(ip, i), |
| 18356 | 18356 | field_ty, |
| ... | ... | @@ -19906,7 +19906,7 @@ fn zirStructInit( |
| 19906 | 19906 | var field_i: u32 = 0; |
| 19907 | 19907 | var extra_index = extra.end; |
| 19908 | 19908 | |
| 19909 | const is_packed = resolved_ty.containerLayout(mod) == .Packed; | |
| 19909 | const is_packed = resolved_ty.containerLayout(mod) == .@"packed"; | |
| 19910 | 19910 | while (field_i < extra.data.fields_len) : (field_i += 1) { |
| 19911 | 19911 | const item = sema.code.extraData(Zir.Inst.StructInit.Item, extra_index); |
| 19912 | 19912 | extra_index = item.end; |
| ... | ... | @@ -21302,7 +21302,7 @@ fn zirReify( |
| 21302 | 21302 | return sema.fail(block, src, "reified structs must have no decls", .{}); |
| 21303 | 21303 | } |
| 21304 | 21304 | |
| 21305 | if (layout != .Packed and !backing_integer_val.isNull(mod)) { | |
| 21305 | if (layout != .@"packed" and !backing_integer_val.isNull(mod)) { | |
| 21306 | 21306 | return sema.fail(block, src, "non-packed struct does not support backing integer type", .{}); |
| 21307 | 21307 | } |
| 21308 | 21308 | |
| ... | ... | @@ -21665,7 +21665,7 @@ fn reifyUnion( |
| 21665 | 21665 | .status = .none, |
| 21666 | 21666 | .runtime_tag = if (opt_tag_type_val.optionalValue(mod) != null) |
| 21667 | 21667 | .tagged |
| 21668 | else if (layout != .Auto) | |
| 21668 | else if (layout != .auto) | |
| 21669 | 21669 | .none |
| 21670 | 21670 | else switch (block.wantSafety()) { |
| 21671 | 21671 | true => .safety, |
| ... | ... | @@ -21804,7 +21804,7 @@ fn reifyUnion( |
| 21804 | 21804 | break :msg msg; |
| 21805 | 21805 | }); |
| 21806 | 21806 | } |
| 21807 | if (layout == .Extern and !try sema.validateExternType(field_ty, .union_field)) { | |
| 21807 | if (layout == .@"extern" and !try sema.validateExternType(field_ty, .union_field)) { | |
| 21808 | 21808 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21809 | 21809 | const msg = try sema.errMsg(block, src, "extern unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)}); |
| 21810 | 21810 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -21815,7 +21815,7 @@ fn reifyUnion( |
| 21815 | 21815 | try sema.addDeclaredHereNote(msg, field_ty); |
| 21816 | 21816 | break :msg msg; |
| 21817 | 21817 | }); |
| 21818 | } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { | |
| 21818 | } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { | |
| 21819 | 21819 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 21820 | 21820 | const msg = try sema.errMsg(block, src, "packed unions cannot contain fields of type '{}'", .{field_ty.fmt(mod)}); |
| 21821 | 21821 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -21938,9 +21938,9 @@ fn reifyStruct( |
| 21938 | 21938 | errdefer wip_ty.cancel(ip); |
| 21939 | 21939 | |
| 21940 | 21940 | 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 => {}, | |
| 21944 | 21944 | }; |
| 21945 | 21945 | |
| 21946 | 21946 | const new_decl_index = try sema.createAnonymousDeclTypeNamed(block, src, .{ |
| ... | ... | @@ -21990,11 +21990,11 @@ fn reifyStruct( |
| 21990 | 21990 | |
| 21991 | 21991 | const byte_align = try field_alignment_val.toUnsignedIntAdvanced(sema); |
| 21992 | 21992 | if (byte_align == 0) { |
| 21993 | if (layout != .Packed) { | |
| 21993 | if (layout != .@"packed") { | |
| 21994 | 21994 | struct_type.field_aligns.get(ip)[field_idx] = .none; |
| 21995 | 21995 | } |
| 21996 | 21996 | } 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", .{}); | |
| 21998 | 21998 | if (!math.isPowerOfTwo(byte_align)) return sema.fail(block, src, "alignment value '{d}' is not a power of two or zero", .{byte_align}); |
| 21999 | 21999 | struct_type.field_aligns.get(ip)[field_idx] = Alignment.fromNonzeroByteUnits(byte_align); |
| 22000 | 22000 | } |
| ... | ... | @@ -22004,9 +22004,9 @@ fn reifyStruct( |
| 22004 | 22004 | if (field_is_comptime) { |
| 22005 | 22005 | assert(any_comptime_fields); |
| 22006 | 22006 | 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), | |
| 22010 | 22010 | } |
| 22011 | 22011 | } |
| 22012 | 22012 | |
| ... | ... | @@ -22047,7 +22047,7 @@ fn reifyStruct( |
| 22047 | 22047 | break :msg msg; |
| 22048 | 22048 | }); |
| 22049 | 22049 | } |
| 22050 | if (layout == .Extern and !try sema.validateExternType(field_ty, .struct_field)) { | |
| 22050 | if (layout == .@"extern" and !try sema.validateExternType(field_ty, .struct_field)) { | |
| 22051 | 22051 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22052 | 22052 | const msg = try sema.errMsg(block, src, "extern structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); |
| 22053 | 22053 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22058,7 +22058,7 @@ fn reifyStruct( |
| 22058 | 22058 | try sema.addDeclaredHereNote(msg, field_ty); |
| 22059 | 22059 | break :msg msg; |
| 22060 | 22060 | }); |
| 22061 | } else if (layout == .Packed and !try sema.validatePackedType(field_ty)) { | |
| 22061 | } else if (layout == .@"packed" and !try sema.validatePackedType(field_ty)) { | |
| 22062 | 22062 | return sema.failWithOwnedErrorMsg(block, msg: { |
| 22063 | 22063 | const msg = try sema.errMsg(block, src, "packed structs cannot contain fields of type '{}'", .{field_ty.fmt(sema.mod)}); |
| 22064 | 22064 | errdefer msg.destroy(gpa); |
| ... | ... | @@ -22072,7 +22072,7 @@ fn reifyStruct( |
| 22072 | 22072 | } |
| 22073 | 22073 | } |
| 22074 | 22074 | |
| 22075 | if (layout == .Packed) { | |
| 22075 | if (layout == .@"packed") { | |
| 22076 | 22076 | var fields_bit_sum: u64 = 0; |
| 22077 | 22077 | for (0..struct_type.field_types.len) |field_idx| { |
| 22078 | 22078 | 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 |
| 23311 | 23311 | } |
| 23312 | 23312 | |
| 23313 | 23313 | switch (ty.containerLayout(mod)) { |
| 23314 | .Packed => { | |
| 23314 | .@"packed" => { | |
| 23315 | 23315 | var bit_sum: u64 = 0; |
| 23316 | 23316 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 23317 | 23317 | for (0..struct_type.field_types.len) |i| { |
| ... | ... | @@ -24710,7 +24710,7 @@ fn zirFieldParentPtr(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileEr |
| 24710 | 24710 | }, |
| 24711 | 24711 | }; |
| 24712 | 24712 | |
| 24713 | if (parent_ty.containerLayout(mod) == .Packed) { | |
| 24713 | if (parent_ty.containerLayout(mod) == .@"packed") { | |
| 24714 | 24714 | return sema.fail(block, src, "TODO handle packed structs/unions with @fieldParentPtr", .{}); |
| 24715 | 24715 | } else { |
| 24716 | 24716 | ptr_ty_data.flags.alignment = blk: { |
| ... | ... | @@ -26328,15 +26328,15 @@ fn validateExternType( |
| 26328 | 26328 | return sema.validateExternType(ty.intTagType(mod), position); |
| 26329 | 26329 | }, |
| 26330 | 26330 | .Struct, .Union => switch (ty.containerLayout(mod)) { |
| 26331 | .Extern => return true, | |
| 26332 | .Packed => { | |
| 26331 | .@"extern" => return true, | |
| 26332 | .@"packed" => { | |
| 26333 | 26333 | const bit_size = try ty.bitSizeAdvanced(mod, sema); |
| 26334 | 26334 | switch (bit_size) { |
| 26335 | 26335 | 0, 8, 16, 32, 64, 128 => return true, |
| 26336 | 26336 | else => return false, |
| 26337 | 26337 | } |
| 26338 | 26338 | }, |
| 26339 | .Auto => return !(try sema.typeHasRuntimeBits(ty)), | |
| 26339 | .auto => return !(try sema.typeHasRuntimeBits(ty)), | |
| 26340 | 26340 | }, |
| 26341 | 26341 | .Array => { |
| 26342 | 26342 | if (position == .ret_ty or position == .param_ty) return false; |
| ... | ... | @@ -26456,7 +26456,7 @@ fn validatePackedType(sema: *Sema, ty: Type) !bool { |
| 26456 | 26456 | .Enum, |
| 26457 | 26457 | => return true, |
| 26458 | 26458 | .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", | |
| 26460 | 26460 | } |
| 26461 | 26461 | } |
| 26462 | 26462 | |
| ... | ... | @@ -27596,7 +27596,7 @@ fn structFieldPtrByIndex( |
| 27596 | 27596 | else |
| 27597 | 27597 | try sema.typeAbiAlignment(Type.fromInterned(struct_ptr_ty_info.child)); |
| 27598 | 27598 | |
| 27599 | if (struct_type.layout == .Packed) { | |
| 27599 | if (struct_type.layout == .@"packed") { | |
| 27600 | 27600 | comptime assert(Type.packed_struct_layout_version == 2); |
| 27601 | 27601 | |
| 27602 | 27602 | var running_bits: u16 = 0; |
| ... | ... | @@ -27641,7 +27641,7 @@ fn structFieldPtrByIndex( |
| 27641 | 27641 | ptr_ty_data.packed_offset = .{ .host_size = 0, .bit_offset = 0 }; |
| 27642 | 27642 | } |
| 27643 | 27643 | } |
| 27644 | } else if (struct_type.layout == .Extern) { | |
| 27644 | } else if (struct_type.layout == .@"extern") { | |
| 27645 | 27645 | // For extern structs, field alignment might be bigger than type's |
| 27646 | 27646 | // natural alignment. Eg, in `extern struct { x: u32, y: u16 }` the |
| 27647 | 27647 | // second field is aligned as u32. |
| ... | ... | @@ -27846,7 +27846,7 @@ fn unionFieldPtr( |
| 27846 | 27846 | .is_const = union_ptr_info.flags.is_const, |
| 27847 | 27847 | .is_volatile = union_ptr_info.flags.is_volatile, |
| 27848 | 27848 | .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: { | |
| 27850 | 27850 | const union_align = if (union_ptr_info.flags.alignment != .none) |
| 27851 | 27851 | union_ptr_info.flags.alignment |
| 27852 | 27852 | else |
| ... | ... | @@ -27875,7 +27875,7 @@ fn unionFieldPtr( |
| 27875 | 27875 | |
| 27876 | 27876 | if (try sema.resolveDefinedValue(block, src, union_ptr)) |union_ptr_val| ct: { |
| 27877 | 27877 | switch (union_obj.getLayout(ip)) { |
| 27878 | .Auto => if (!initializing) { | |
| 27878 | .auto => if (!initializing) { | |
| 27879 | 27879 | const union_val = (try sema.pointerDeref(block, src, union_ptr_val, union_ptr_ty)) orelse |
| 27880 | 27880 | break :ct; |
| 27881 | 27881 | if (union_val.isUndef(mod)) { |
| ... | ... | @@ -27899,7 +27899,7 @@ fn unionFieldPtr( |
| 27899 | 27899 | return sema.failWithOwnedErrorMsg(block, msg); |
| 27900 | 27900 | } |
| 27901 | 27901 | }, |
| 27902 | .Packed, .Extern => {}, | |
| 27902 | .@"packed", .@"extern" => {}, | |
| 27903 | 27903 | } |
| 27904 | 27904 | return Air.internedToRef((try mod.intern(.{ .ptr = .{ |
| 27905 | 27905 | .ty = ptr_field_ty.toIntern(), |
| ... | ... | @@ -27911,7 +27911,7 @@ fn unionFieldPtr( |
| 27911 | 27911 | } |
| 27912 | 27912 | |
| 27913 | 27913 | 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 | |
| 27915 | 27915 | union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1) |
| 27916 | 27916 | { |
| 27917 | 27917 | const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| ... | ... | @@ -27954,7 +27954,7 @@ fn unionFieldVal( |
| 27954 | 27954 | const field_tag = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| 27955 | 27955 | const tag_matches = un.tag == field_tag.toIntern(); |
| 27956 | 27956 | switch (union_obj.getLayout(ip)) { |
| 27957 | .Auto => { | |
| 27957 | .auto => { | |
| 27958 | 27958 | if (tag_matches) { |
| 27959 | 27959 | return Air.internedToRef(un.val); |
| 27960 | 27960 | } else { |
| ... | ... | @@ -27971,7 +27971,7 @@ fn unionFieldVal( |
| 27971 | 27971 | return sema.failWithOwnedErrorMsg(block, msg); |
| 27972 | 27972 | } |
| 27973 | 27973 | }, |
| 27974 | .Packed, .Extern => |layout| { | |
| 27974 | .@"packed", .@"extern" => |layout| { | |
| 27975 | 27975 | if (tag_matches) { |
| 27976 | 27976 | return Air.internedToRef(un.val); |
| 27977 | 27977 | } else { |
| ... | ... | @@ -27989,7 +27989,7 @@ fn unionFieldVal( |
| 27989 | 27989 | } |
| 27990 | 27990 | |
| 27991 | 27991 | 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 | |
| 27993 | 27993 | union_ty.unionTagTypeSafety(mod) != null and union_obj.field_types.len > 1) |
| 27994 | 27994 | { |
| 27995 | 27995 | const wanted_tag_val = try mod.enumValueFieldIndex(Type.fromInterned(union_obj.enum_tag_ty), enum_field_index); |
| ... | ... | @@ -30961,7 +30961,7 @@ fn beginComptimePtrMutation( |
| 30961 | 30961 | |
| 30962 | 30962 | const tag_type = base_child_ty.unionTagTypeHypothetical(mod); |
| 30963 | 30963 | 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))) { | |
| 30965 | 30965 | // We need to set the active field of the union. |
| 30966 | 30966 | payload.tag = hypothetical_tag; |
| 30967 | 30967 | |
| ... | ... | @@ -30988,7 +30988,7 @@ fn beginComptimePtrMutation( |
| 30988 | 30988 | .pointee = .{ .reinterpret = .{ |
| 30989 | 30989 | .val_ptr = val_ptr, |
| 30990 | 30990 | .byte_offset = 0, |
| 30991 | .write_packed = layout == .Packed, | |
| 30991 | .write_packed = layout == .@"packed", | |
| 30992 | 30992 | } }, |
| 30993 | 30993 | .ty = parent.ty, |
| 30994 | 30994 | }; |
| ... | ... | @@ -31395,7 +31395,7 @@ fn beginComptimePtrLoad( |
| 31395 | 31395 | |
| 31396 | 31396 | if (container_ty.hasWellDefinedLayout(mod)) { |
| 31397 | 31397 | 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") { | |
| 31399 | 31399 | // packed structs are not byte addressable |
| 31400 | 31400 | deref.parent = null; |
| 31401 | 31401 | } else if (deref.parent) |*parent| { |
| ... | ... | @@ -31551,7 +31551,7 @@ fn bitCastUnionFieldVal( |
| 31551 | 31551 | |
| 31552 | 31552 | // Reading a larger value means we need to reinterpret from undefined bytes. |
| 31553 | 31553 | const offset = switch (layout) { |
| 31554 | .Extern => offset: { | |
| 31554 | .@"extern" => offset: { | |
| 31555 | 31555 | if (field_size > old_size) @memset(buffer[old_size..], 0xaa); |
| 31556 | 31556 | val.writeToMemory(old_ty, mod, buffer) catch |err| switch (err) { |
| 31557 | 31557 | error.OutOfMemory => return error.OutOfMemory, |
| ... | ... | @@ -31561,7 +31561,7 @@ fn bitCastUnionFieldVal( |
| 31561 | 31561 | }; |
| 31562 | 31562 | break :offset 0; |
| 31563 | 31563 | }, |
| 31564 | .Packed => offset: { | |
| 31564 | .@"packed" => offset: { | |
| 31565 | 31565 | if (field_size > old_size) { |
| 31566 | 31566 | const min_size = @max(old_size, 1); |
| 31567 | 31567 | switch (endian) { |
| ... | ... | @@ -31577,7 +31577,7 @@ fn bitCastUnionFieldVal( |
| 31577 | 31577 | |
| 31578 | 31578 | break :offset if (endian == .big) buffer.len - field_size else 0; |
| 31579 | 31579 | }, |
| 31580 | .Auto => unreachable, | |
| 31580 | .auto => unreachable, | |
| 31581 | 31581 | }; |
| 31582 | 31582 | |
| 31583 | 31583 | return Value.readFromMemory(field_ty, mod, buffer[offset..], sema.arena) catch |err| switch (err) { |
| ... | ... | @@ -35608,7 +35608,7 @@ pub fn resolveStructAlignment( |
| 35608 | 35608 | const target = mod.getTarget(); |
| 35609 | 35609 | |
| 35610 | 35610 | assert(struct_type.flagsPtr(ip).alignment == .none); |
| 35611 | assert(struct_type.layout != .Packed); | |
| 35611 | assert(struct_type.layout != .@"packed"); | |
| 35612 | 35612 | |
| 35613 | 35613 | if (struct_type.flagsPtr(ip).field_types_wip) { |
| 35614 | 35614 | // We'll guess "pointer-aligned", if the struct has an |
| ... | ... | @@ -35661,7 +35661,7 @@ fn resolveStructLayout(sema: *Sema, ty: Type) CompileError!void { |
| 35661 | 35661 | |
| 35662 | 35662 | try sema.resolveTypeFields(ty); |
| 35663 | 35663 | |
| 35664 | if (struct_type.layout == .Packed) { | |
| 35664 | if (struct_type.layout == .@"packed") { | |
| 35665 | 35665 | try semaBackingIntType(mod, struct_type); |
| 35666 | 35666 | return; |
| 35667 | 35667 | } |
| ... | ... | @@ -36625,11 +36625,11 @@ fn semaStructFields( |
| 36625 | 36625 | const fields_len, const small, var extra_index = structZirInfo(zir, zir_index); |
| 36626 | 36626 | |
| 36627 | 36627 | if (fields_len == 0) switch (struct_type.layout) { |
| 36628 | .Packed => { | |
| 36628 | .@"packed" => { | |
| 36629 | 36629 | try semaBackingIntType(mod, struct_type); |
| 36630 | 36630 | return; |
| 36631 | 36631 | }, |
| 36632 | .Auto, .Extern => { | |
| 36632 | .auto, .@"extern" => { | |
| 36633 | 36633 | struct_type.size(ip).* = 0; |
| 36634 | 36634 | struct_type.flagsPtr(ip).layout_resolved = true; |
| 36635 | 36635 | return; |
| ... | ... | @@ -36810,7 +36810,7 @@ fn semaStructFields( |
| 36810 | 36810 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 36811 | 36811 | } |
| 36812 | 36812 | switch (struct_type.layout) { |
| 36813 | .Extern => if (!try sema.validateExternType(field_ty, .struct_field)) { | |
| 36813 | .@"extern" => if (!try sema.validateExternType(field_ty, .struct_field)) { | |
| 36814 | 36814 | const msg = msg: { |
| 36815 | 36815 | const ty_src = mod.fieldSrcLoc(decl_index, .{ |
| 36816 | 36816 | .index = field_i, |
| ... | ... | @@ -36826,7 +36826,7 @@ fn semaStructFields( |
| 36826 | 36826 | }; |
| 36827 | 36827 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 36828 | 36828 | }, |
| 36829 | .Packed => if (!try sema.validatePackedType(field_ty)) { | |
| 36829 | .@"packed" => if (!try sema.validatePackedType(field_ty)) { | |
| 36830 | 36830 | const msg = msg: { |
| 36831 | 36831 | const ty_src = mod.fieldSrcLoc(decl_index, .{ |
| 36832 | 36832 | .index = field_i, |
| ... | ... | @@ -37350,7 +37350,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded |
| 37350 | 37350 | return sema.failWithOwnedErrorMsg(&block_scope, msg); |
| 37351 | 37351 | } |
| 37352 | 37352 | const layout = union_type.getLayout(ip); |
| 37353 | if (layout == .Extern and | |
| 37353 | if (layout == .@"extern" and | |
| 37354 | 37354 | !try sema.validateExternType(field_ty, .union_field)) |
| 37355 | 37355 | { |
| 37356 | 37356 | const msg = msg: { |
| ... | ... | @@ -37367,7 +37367,7 @@ fn semaUnionFields(mod: *Module, arena: Allocator, union_type: InternPool.Loaded |
| 37367 | 37367 | break :msg msg; |
| 37368 | 37368 | }; |
| 37369 | 37369 | 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)) { | |
| 37371 | 37371 | const msg = msg: { |
| 37372 | 37372 | const ty_src = mod.fieldSrcLoc(union_type.decl, .{ |
| 37373 | 37373 | .index = field_i, |
| ... | ... | @@ -38286,9 +38286,9 @@ fn structFieldAlignment( |
| 38286 | 38286 | return explicit_alignment; |
| 38287 | 38287 | const mod = sema.mod; |
| 38288 | 38288 | 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" => {}, | |
| 38292 | 38292 | } |
| 38293 | 38293 | // extern |
| 38294 | 38294 | 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{ |
| 676 | 676 | .Struct => { |
| 677 | 677 | const struct_type = mod.typeToStruct(ty) orelse return error.IllDefinedMemoryLayout; |
| 678 | 678 | 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| { | |
| 681 | 681 | const off: usize = @intCast(ty.structFieldOffset(i, mod)); |
| 682 | 682 | const field_val = switch (val.ip_index) { |
| 683 | 683 | .none => switch (val.tag()) { |
| ... | ... | @@ -701,7 +701,7 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ |
| 701 | 701 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[i]); |
| 702 | 702 | try writeToMemory(field_val, field_ty, mod, buffer[off..]); |
| 703 | 703 | }, |
| 704 | .Packed => { | |
| 704 | .@"packed" => { | |
| 705 | 705 | const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; |
| 706 | 706 | return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); |
| 707 | 707 | }, |
| ... | ... | @@ -724,8 +724,8 @@ pub fn writeToMemory(val: Value, ty: Type, mod: *Module, buffer: []u8) error{ |
| 724 | 724 | bigint.writeTwosComplement(buffer[0..byte_count], endian); |
| 725 | 725 | }, |
| 726 | 726 | .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" => { | |
| 729 | 729 | if (val.unionTag(mod)) |union_tag| { |
| 730 | 730 | const union_obj = mod.typeToUnion(ty).?; |
| 731 | 731 | 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{ |
| 739 | 739 | return writeToMemory(val.unionValue(mod), backing_ty, mod, buffer[0..byte_count]); |
| 740 | 740 | } |
| 741 | 741 | }, |
| 742 | .Packed => { | |
| 742 | .@"packed" => { | |
| 743 | 743 | const backing_ty = try ty.unionBackingType(mod); |
| 744 | 744 | const byte_count: usize = @intCast(backing_ty.abiSize(mod)); |
| 745 | 745 | return writeToPackedMemory(val, ty, mod, buffer[0..byte_count], 0); |
| ... | ... | @@ -841,7 +841,7 @@ pub fn writeToPackedMemory( |
| 841 | 841 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 842 | 842 | // Sema is supposed to have emitted a compile error already in the case of Auto, |
| 843 | 843 | // and Extern is handled in non-packed writeToMemory. |
| 844 | assert(struct_type.layout == .Packed); | |
| 844 | assert(struct_type.layout == .@"packed"); | |
| 845 | 845 | var bits: u16 = 0; |
| 846 | 846 | for (0..struct_type.field_types.len) |i| { |
| 847 | 847 | const field_val = switch (val.ip_index) { |
| ... | ... | @@ -866,8 +866,8 @@ pub fn writeToPackedMemory( |
| 866 | 866 | .Union => { |
| 867 | 867 | const union_obj = mod.typeToUnion(ty).?; |
| 868 | 868 | 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" => { | |
| 871 | 871 | if (val.unionTag(mod)) |union_tag| { |
| 872 | 872 | const field_index = mod.unionTagFieldIndex(union_obj, union_tag).?; |
| 873 | 873 | const field_type = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| ... | ... | @@ -991,8 +991,8 @@ pub fn readFromMemory( |
| 991 | 991 | .Struct => { |
| 992 | 992 | const struct_type = mod.typeToStruct(ty).?; |
| 993 | 993 | 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" => { | |
| 996 | 996 | const field_types = struct_type.field_types; |
| 997 | 997 | const field_vals = try arena.alloc(InternPool.Index, field_types.len); |
| 998 | 998 | for (field_vals, 0..) |*field_val, i| { |
| ... | ... | @@ -1006,7 +1006,7 @@ pub fn readFromMemory( |
| 1006 | 1006 | .storage = .{ .elems = field_vals }, |
| 1007 | 1007 | } }))); |
| 1008 | 1008 | }, |
| 1009 | .Packed => { | |
| 1009 | .@"packed" => { | |
| 1010 | 1010 | const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; |
| 1011 | 1011 | return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); |
| 1012 | 1012 | }, |
| ... | ... | @@ -1025,8 +1025,8 @@ pub fn readFromMemory( |
| 1025 | 1025 | } }))); |
| 1026 | 1026 | }, |
| 1027 | 1027 | .Union => switch (ty.containerLayout(mod)) { |
| 1028 | .Auto => return error.IllDefinedMemoryLayout, | |
| 1029 | .Extern => { | |
| 1028 | .auto => return error.IllDefinedMemoryLayout, | |
| 1029 | .@"extern" => { | |
| 1030 | 1030 | const union_size = ty.abiSize(mod); |
| 1031 | 1031 | const array_ty = try mod.arrayType(.{ .len = union_size, .child = .u8_type }); |
| 1032 | 1032 | const val = try (try readFromMemory(array_ty, mod, buffer, arena)).intern(array_ty, mod); |
| ... | ... | @@ -1036,7 +1036,7 @@ pub fn readFromMemory( |
| 1036 | 1036 | .val = val, |
| 1037 | 1037 | } }))); |
| 1038 | 1038 | }, |
| 1039 | .Packed => { | |
| 1039 | .@"packed" => { | |
| 1040 | 1040 | const byte_count = (@as(usize, @intCast(ty.bitSize(mod))) + 7) / 8; |
| 1041 | 1041 | return readFromPackedMemory(ty, mod, buffer[0..byte_count], 0, arena); |
| 1042 | 1042 | }, |
| ... | ... | @@ -1177,8 +1177,8 @@ pub fn readFromPackedMemory( |
| 1177 | 1177 | } }))); |
| 1178 | 1178 | }, |
| 1179 | 1179 | .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" => { | |
| 1182 | 1182 | const backing_ty = try ty.unionBackingType(mod); |
| 1183 | 1183 | const val = (try readFromPackedMemory(backing_ty, mod, buffer, bit_offset, arena)).toIntern(); |
| 1184 | 1184 | return Value.fromInterned((try mod.intern(.{ .un = .{ |
| ... | ... | @@ -4064,7 +4064,7 @@ fn dbHelper(self: *Value, tag_to_payload_map: *map: { |
| 4064 | 4064 | .alignment = 0, |
| 4065 | 4065 | }; |
| 4066 | 4066 | break :map @Type(.{ .Struct = .{ |
| 4067 | .layout = .Extern, | |
| 4067 | .layout = .@"extern", | |
| 4068 | 4068 | .fields = &fields, |
| 4069 | 4069 | .decls = &.{}, |
| 4070 | 4070 | .is_tuple = false, |
src/arch/aarch64/abi.zig+2-2| ... | ... | @@ -21,7 +21,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 21 | 21 | var maybe_float_bits: ?u16 = null; |
| 22 | 22 | switch (ty.zigTypeTag(mod)) { |
| 23 | 23 | .Struct => { |
| 24 | if (ty.containerLayout(mod) == .Packed) return .byval; | |
| 24 | if (ty.containerLayout(mod) == .@"packed") return .byval; | |
| 25 | 25 | const float_count = countFloats(ty, mod, &maybe_float_bits); |
| 26 | 26 | if (float_count <= sret_float_count) return .{ .float_array = float_count }; |
| 27 | 27 | |
| ... | ... | @@ -31,7 +31,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 31 | 31 | return .integer; |
| 32 | 32 | }, |
| 33 | 33 | .Union => { |
| 34 | if (ty.containerLayout(mod) == .Packed) return .byval; | |
| 34 | if (ty.containerLayout(mod) == .@"packed") return .byval; | |
| 35 | 35 | const float_count = countFloats(ty, mod, &maybe_float_bits); |
| 36 | 36 | if (float_count <= sret_float_count) return .{ .float_array = float_count }; |
| 37 | 37 |
src/arch/arm/abi.zig+2-2| ... | ... | @@ -33,7 +33,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class { |
| 33 | 33 | switch (ty.zigTypeTag(mod)) { |
| 34 | 34 | .Struct => { |
| 35 | 35 | const bit_size = ty.bitSize(mod); |
| 36 | if (ty.containerLayout(mod) == .Packed) { | |
| 36 | if (ty.containerLayout(mod) == .@"packed") { | |
| 37 | 37 | if (bit_size > 64) return .memory; |
| 38 | 38 | return .byval; |
| 39 | 39 | } |
| ... | ... | @@ -56,7 +56,7 @@ pub fn classifyType(ty: Type, mod: *Module, ctx: Context) Class { |
| 56 | 56 | .Union => { |
| 57 | 57 | const bit_size = ty.bitSize(mod); |
| 58 | 58 | const union_obj = mod.typeToUnion(ty).?; |
| 59 | if (union_obj.getLayout(ip) == .Packed) { | |
| 59 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 60 | 60 | if (bit_size > 64) return .memory; |
| 61 | 61 | return .byval; |
| 62 | 62 | } |
src/arch/riscv64/abi.zig+2-2| ... | ... | @@ -15,7 +15,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 15 | 15 | switch (ty.zigTypeTag(mod)) { |
| 16 | 16 | .Struct => { |
| 17 | 17 | const bit_size = ty.bitSize(mod); |
| 18 | if (ty.containerLayout(mod) == .Packed) { | |
| 18 | if (ty.containerLayout(mod) == .@"packed") { | |
| 19 | 19 | if (bit_size > max_byval_size) return .memory; |
| 20 | 20 | return .byval; |
| 21 | 21 | } |
| ... | ... | @@ -44,7 +44,7 @@ pub fn classifyType(ty: Type, mod: *Module) Class { |
| 44 | 44 | }, |
| 45 | 45 | .Union => { |
| 46 | 46 | const bit_size = ty.bitSize(mod); |
| 47 | if (ty.containerLayout(mod) == .Packed) { | |
| 47 | if (ty.containerLayout(mod) == .@"packed") { | |
| 48 | 48 | if (bit_size > max_byval_size) return .memory; |
| 49 | 49 | return .byval; |
| 50 | 50 | } |
src/arch/wasm/CodeGen.zig+7-7| ... | ... | @@ -1018,7 +1018,7 @@ fn typeToValtype(ty: Type, mod: *Module) wasm.Valtype { |
| 1018 | 1018 | .unrolled => wasm.Valtype.i32, |
| 1019 | 1019 | }, |
| 1020 | 1020 | .Union => switch (ty.containerLayout(mod)) { |
| 1021 | .Packed => { | |
| 1021 | .@"packed" => { | |
| 1022 | 1022 | const int_ty = mod.intType(.unsigned, @as(u16, @intCast(ty.bitSize(mod)))) catch @panic("out of memory"); |
| 1023 | 1023 | return typeToValtype(int_ty, mod); |
| 1024 | 1024 | }, |
| ... | ... | @@ -1737,7 +1737,7 @@ fn isByRef(ty: Type, mod: *Module) bool { |
| 1737 | 1737 | => return ty.hasRuntimeBitsIgnoreComptime(mod), |
| 1738 | 1738 | .Union => { |
| 1739 | 1739 | if (mod.typeToUnion(ty)) |union_obj| { |
| 1740 | if (union_obj.getLayout(ip) == .Packed) { | |
| 1740 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 1741 | 1741 | return ty.abiSize(mod) > 8; |
| 1742 | 1742 | } |
| 1743 | 1743 | } |
| ... | ... | @@ -3097,7 +3097,7 @@ fn lowerParentPtr(func: *CodeGen, ptr_val: Value, offset: u32) InnerError!WValue |
| 3097 | 3097 | break :blk parent_ty.structFieldOffset(field_index, mod); |
| 3098 | 3098 | }, |
| 3099 | 3099 | .Union => switch (parent_ty.containerLayout(mod)) { |
| 3100 | .Packed => 0, | |
| 3100 | .@"packed" => 0, | |
| 3101 | 3101 | else => blk: { |
| 3102 | 3102 | const layout: Module.UnionLayout = parent_ty.unionGetLayout(mod); |
| 3103 | 3103 | if (layout.payload_size == 0) break :blk 0; |
| ... | ... | @@ -3358,7 +3358,7 @@ fn lowerConstant(func: *CodeGen, val: Value, ty: Type) InnerError!WValue { |
| 3358 | 3358 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3359 | 3359 | // non-packed structs are not handled in this function because they |
| 3360 | 3360 | // are by-ref types. |
| 3361 | assert(struct_type.layout == .Packed); | |
| 3361 | assert(struct_type.layout == .@"packed"); | |
| 3362 | 3362 | var buf: [8]u8 = .{0} ** 8; // zero the buffer so we do not read 0xaa as integer |
| 3363 | 3363 | val.writeToPackedMemory(ty, mod, &buf, 0) catch unreachable; |
| 3364 | 3364 | const backing_int_ty = Type.fromInterned(struct_type.backingIntType(ip).*); |
| ... | ... | @@ -3890,7 +3890,7 @@ fn structFieldPtr( |
| 3890 | 3890 | const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); |
| 3891 | 3891 | |
| 3892 | 3892 | const offset = switch (struct_ty.containerLayout(mod)) { |
| 3893 | .Packed => switch (struct_ty.zigTypeTag(mod)) { | |
| 3893 | .@"packed" => switch (struct_ty.zigTypeTag(mod)) { | |
| 3894 | 3894 | .Struct => offset: { |
| 3895 | 3895 | if (result_ty.ptrInfo(mod).packed_offset.host_size != 0) { |
| 3896 | 3896 | break :offset @as(u32, 0); |
| ... | ... | @@ -3928,7 +3928,7 @@ fn airStructFieldVal(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 3928 | 3928 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) return func.finishAir(inst, .none, &.{struct_field.struct_operand}); |
| 3929 | 3929 | |
| 3930 | 3930 | const result = switch (struct_ty.containerLayout(mod)) { |
| 3931 | .Packed => switch (struct_ty.zigTypeTag(mod)) { | |
| 3931 | .@"packed" => switch (struct_ty.zigTypeTag(mod)) { | |
| 3932 | 3932 | .Struct => result: { |
| 3933 | 3933 | const packed_struct = mod.typeToPackedStruct(struct_ty).?; |
| 3934 | 3934 | const offset = mod.structPackedFieldBitOffset(packed_struct, field_index); |
| ... | ... | @@ -5321,7 +5321,7 @@ fn airAggregateInit(func: *CodeGen, inst: Air.Inst.Index) InnerError!void { |
| 5321 | 5321 | break :result_value result; |
| 5322 | 5322 | }, |
| 5323 | 5323 | .Struct => switch (result_ty.containerLayout(mod)) { |
| 5324 | .Packed => { | |
| 5324 | .@"packed" => { | |
| 5325 | 5325 | if (isByRef(result_ty, mod)) { |
| 5326 | 5326 | return func.fail("TODO: airAggregateInit for packed structs larger than 64 bits", .{}); |
| 5327 | 5327 | } |
src/arch/wasm/abi.zig+3-3| ... | ... | @@ -29,7 +29,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { |
| 29 | 29 | switch (ty.zigTypeTag(mod)) { |
| 30 | 30 | .Struct => { |
| 31 | 31 | const struct_type = mod.typeToStruct(ty).?; |
| 32 | if (struct_type.layout == .Packed) { | |
| 32 | if (struct_type.layout == .@"packed") { | |
| 33 | 33 | if (ty.bitSize(mod) <= 64) return direct; |
| 34 | 34 | return .{ .direct, .direct }; |
| 35 | 35 | } |
| ... | ... | @@ -70,7 +70,7 @@ pub fn classifyType(ty: Type, mod: *Module) [2]Class { |
| 70 | 70 | }, |
| 71 | 71 | .Union => { |
| 72 | 72 | const union_obj = mod.typeToUnion(ty).?; |
| 73 | if (union_obj.getLayout(ip) == .Packed) { | |
| 73 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 74 | 74 | if (ty.bitSize(mod) <= 64) return direct; |
| 75 | 75 | return .{ .direct, .direct }; |
| 76 | 76 | } |
| ... | ... | @@ -113,7 +113,7 @@ pub fn scalarType(ty: Type, mod: *Module) Type { |
| 113 | 113 | }, |
| 114 | 114 | .Union => { |
| 115 | 115 | const union_obj = mod.typeToUnion(ty).?; |
| 116 | if (union_obj.getLayout(ip) != .Packed) { | |
| 116 | if (union_obj.getLayout(ip) != .@"packed") { | |
| 117 | 117 | const layout = mod.getUnionLayout(union_obj); |
| 118 | 118 | if (layout.payload_size == 0 and layout.tag_size != 0) { |
| 119 | 119 | 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 { |
| 7962 | 7962 | |
| 7963 | 7963 | const src_mcv = try self.resolveInst(operand); |
| 7964 | 7964 | 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| | |
| 7967 | 7967 | mod.structPackedFieldBitOffset(struct_type, index) |
| 7968 | 7968 | else |
| 7969 | 7969 | 0, |
| ... | ... | @@ -17979,7 +17979,7 @@ fn airAggregateInit(self: *Self, inst: Air.Inst.Index) !void { |
| 17979 | 17979 | switch (result_ty.zigTypeTag(mod)) { |
| 17980 | 17980 | .Struct => { |
| 17981 | 17981 | 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") { | |
| 17983 | 17983 | const struct_type = mod.typeToStruct(result_ty).?; |
| 17984 | 17984 | try self.genInlineMemset( |
| 17985 | 17985 | .{ .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 { |
| 42 | 42 | 1, 2, 4, 8 => return .integer, |
| 43 | 43 | else => switch (ty.zigTypeTag(mod)) { |
| 44 | 44 | .Int => return .win_i128, |
| 45 | .Struct, .Union => if (ty.containerLayout(mod) == .Packed) { | |
| 45 | .Struct, .Union => if (ty.containerLayout(mod) == .@"packed") { | |
| 46 | 46 | return .win_i128; |
| 47 | 47 | } else { |
| 48 | 48 | return .memory; |
| ... | ... | @@ -238,7 +238,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class { |
| 238 | 238 | // separately.". |
| 239 | 239 | const struct_type = mod.typeToStruct(ty).?; |
| 240 | 240 | const ty_size = ty.abiSize(mod); |
| 241 | if (struct_type.layout == .Packed) { | |
| 241 | if (struct_type.layout == .@"packed") { | |
| 242 | 242 | assert(ty_size <= 16); |
| 243 | 243 | result[0] = .integer; |
| 244 | 244 | if (ty_size > 8) result[1] = .integer; |
| ... | ... | @@ -356,7 +356,7 @@ pub fn classifySystemV(ty: Type, mod: *Module, ctx: Context) [8]Class { |
| 356 | 356 | // separately.". |
| 357 | 357 | const union_obj = mod.typeToUnion(ty).?; |
| 358 | 358 | const ty_size = mod.unionAbiSize(union_obj); |
| 359 | if (union_obj.getLayout(ip) == .Packed) { | |
| 359 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 360 | 360 | assert(ty_size <= 16); |
| 361 | 361 | result[0] = .integer; |
| 362 | 362 | if (ty_size > 8) result[1] = .integer; |
src/codegen.zig+4-4| ... | ... | @@ -513,7 +513,7 @@ pub fn generateSymbol( |
| 513 | 513 | .struct_type => { |
| 514 | 514 | const struct_type = ip.loadStructType(typed_value.ty.toIntern()); |
| 515 | 515 | switch (struct_type.layout) { |
| 516 | .Packed => { | |
| 516 | .@"packed" => { | |
| 517 | 517 | const abi_size = math.cast(usize, typed_value.ty.abiSize(mod)) orelse |
| 518 | 518 | return error.Overflow; |
| 519 | 519 | const current_pos = code.items.len; |
| ... | ... | @@ -550,7 +550,7 @@ pub fn generateSymbol( |
| 550 | 550 | bits += @as(u16, @intCast(Type.fromInterned(field_ty).bitSize(mod))); |
| 551 | 551 | } |
| 552 | 552 | }, |
| 553 | .Auto, .Extern => { | |
| 553 | .auto, .@"extern" => { | |
| 554 | 554 | const struct_begin = code.items.len; |
| 555 | 555 | const field_types = struct_type.field_types.get(ip); |
| 556 | 556 | const offsets = struct_type.offsets.get(ip); |
| ... | ... | @@ -736,11 +736,11 @@ fn lowerParentPtr( |
| 736 | 736 | .anon_struct_type, |
| 737 | 737 | .union_type, |
| 738 | 738 | => 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( | |
| 740 | 740 | @intCast(field.index), |
| 741 | 741 | mod, |
| 742 | 742 | )), |
| 743 | .Packed => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj| | |
| 743 | .@"packed" => if (mod.typeToStruct(Type.fromInterned(base_ty))) |struct_obj| | |
| 744 | 744 | if (Type.fromInterned(ptr.ty).ptrInfo(mod).packed_offset.host_size == 0) |
| 745 | 745 | @divExact(Type.fromInterned(base_ptr_ty).ptrInfo(mod) |
| 746 | 746 | .packed_offset.bit_offset + mod.structPackedFieldBitOffset( |
src/codegen/c.zig+15-15| ... | ... | @@ -890,7 +890,7 @@ pub const DeclGen = struct { |
| 890 | 890 | return writer.writeAll(" }"); |
| 891 | 891 | }, |
| 892 | 892 | .Struct => switch (ty.containerLayout(mod)) { |
| 893 | .Auto, .Extern => { | |
| 893 | .auto, .@"extern" => { | |
| 894 | 894 | if (!location.isInitializer()) { |
| 895 | 895 | try writer.writeByte('('); |
| 896 | 896 | try dg.renderType(writer, ty); |
| ... | ... | @@ -912,7 +912,7 @@ pub const DeclGen = struct { |
| 912 | 912 | |
| 913 | 913 | return writer.writeByte('}'); |
| 914 | 914 | }, |
| 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)}), | |
| 916 | 916 | }, |
| 917 | 917 | .Union => { |
| 918 | 918 | if (!location.isInitializer()) { |
| ... | ... | @@ -1379,7 +1379,7 @@ pub const DeclGen = struct { |
| 1379 | 1379 | .struct_type => { |
| 1380 | 1380 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 1381 | 1381 | switch (struct_type.layout) { |
| 1382 | .Auto, .Extern => { | |
| 1382 | .auto, .@"extern" => { | |
| 1383 | 1383 | if (!location.isInitializer()) { |
| 1384 | 1384 | try writer.writeByte('('); |
| 1385 | 1385 | try dg.renderType(writer, ty); |
| ... | ... | @@ -1408,7 +1408,7 @@ pub const DeclGen = struct { |
| 1408 | 1408 | } |
| 1409 | 1409 | try writer.writeByte('}'); |
| 1410 | 1410 | }, |
| 1411 | .Packed => { | |
| 1411 | .@"packed" => { | |
| 1412 | 1412 | const int_info = ty.intInfo(mod); |
| 1413 | 1413 | |
| 1414 | 1414 | const bits = Type.smallestUnsignedBits(int_info.bits - 1); |
| ... | ... | @@ -1517,7 +1517,7 @@ pub const DeclGen = struct { |
| 1517 | 1517 | if (un.tag == .none) { |
| 1518 | 1518 | const backing_ty = try ty.unionBackingType(mod); |
| 1519 | 1519 | switch (union_obj.getLayout(ip)) { |
| 1520 | .Packed => { | |
| 1520 | .@"packed" => { | |
| 1521 | 1521 | if (!location.isInitializer()) { |
| 1522 | 1522 | try writer.writeByte('('); |
| 1523 | 1523 | try dg.renderType(writer, backing_ty); |
| ... | ... | @@ -1525,7 +1525,7 @@ pub const DeclGen = struct { |
| 1525 | 1525 | } |
| 1526 | 1526 | try dg.renderValue(writer, backing_ty, Value.fromInterned(un.val), initializer_type); |
| 1527 | 1527 | }, |
| 1528 | .Extern => { | |
| 1528 | .@"extern" => { | |
| 1529 | 1529 | if (location == .StaticInitializer) { |
| 1530 | 1530 | return dg.fail("TODO: C backend: implement extern union backing type rendering in static initializers", .{}); |
| 1531 | 1531 | } |
| ... | ... | @@ -1551,7 +1551,7 @@ pub const DeclGen = struct { |
| 1551 | 1551 | const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?; |
| 1552 | 1552 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 1553 | 1553 | 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") { | |
| 1555 | 1555 | if (field_ty.hasRuntimeBits(mod)) { |
| 1556 | 1556 | if (field_ty.isPtrAtRuntime(mod)) { |
| 1557 | 1557 | try writer.writeByte('('); |
| ... | ... | @@ -5497,7 +5497,7 @@ fn fieldLocation( |
| 5497 | 5497 | .Union => { |
| 5498 | 5498 | const union_obj = mod.typeToUnion(container_ty).?; |
| 5499 | 5499 | return switch (union_obj.getLayout(ip)) { |
| 5500 | .Auto, .Extern => { | |
| 5500 | .auto, .@"extern" => { | |
| 5501 | 5501 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 5502 | 5502 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) |
| 5503 | 5503 | return if (container_ty.unionTagTypeSafety(mod) != null and |
| ... | ... | @@ -5511,7 +5511,7 @@ fn fieldLocation( |
| 5511 | 5511 | else |
| 5512 | 5512 | .{ .identifier = ip.stringToSlice(field_name) } }; |
| 5513 | 5513 | }, |
| 5514 | .Packed => .begin, | |
| 5514 | .@"packed" => .begin, | |
| 5515 | 5515 | }; |
| 5516 | 5516 | }, |
| 5517 | 5517 | .Pointer => switch (container_ty.ptrSize(mod)) { |
| ... | ... | @@ -5671,11 +5671,11 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5671 | 5671 | |
| 5672 | 5672 | const field_name: CValue = switch (mod.intern_pool.indexToKey(struct_ty.ip_index)) { |
| 5673 | 5673 | .struct_type => switch (struct_ty.containerLayout(mod)) { |
| 5674 | .Auto, .Extern => if (struct_ty.isSimpleTuple(mod)) | |
| 5674 | .auto, .@"extern" => if (struct_ty.isSimpleTuple(mod)) | |
| 5675 | 5675 | .{ .field = extra.field_index } |
| 5676 | 5676 | else |
| 5677 | 5677 | .{ .identifier = ip.stringToSlice(struct_ty.legacyStructFieldName(extra.field_index, mod)) }, |
| 5678 | .Packed => { | |
| 5678 | .@"packed" => { | |
| 5679 | 5679 | const struct_type = mod.typeToStruct(struct_ty).?; |
| 5680 | 5680 | const int_info = struct_ty.intInfo(mod); |
| 5681 | 5681 | |
| ... | ... | @@ -5740,7 +5740,7 @@ fn airStructFieldVal(f: *Function, inst: Air.Inst.Index) !CValue { |
| 5740 | 5740 | |
| 5741 | 5741 | .union_type => field_name: { |
| 5742 | 5742 | const union_obj = ip.loadUnionType(struct_ty.toIntern()); |
| 5743 | if (union_obj.flagsPtr(ip).layout == .Packed) { | |
| 5743 | if (union_obj.flagsPtr(ip).layout == .@"packed") { | |
| 5744 | 5744 | const operand_lval = if (struct_byval == .constant) blk: { |
| 5745 | 5745 | const operand_local = try f.allocLocal(inst, struct_ty); |
| 5746 | 5746 | try f.writeCValue(writer, operand_local, .Other); |
| ... | ... | @@ -7081,7 +7081,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7081 | 7081 | } |
| 7082 | 7082 | }, |
| 7083 | 7083 | .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| { | |
| 7085 | 7085 | if (inst_ty.structFieldIsComptime(field_index, mod)) continue; |
| 7086 | 7086 | const field_ty = inst_ty.structFieldType(field_index, mod); |
| 7087 | 7087 | if (!field_ty.hasRuntimeBitsIgnoreComptime(mod)) continue; |
| ... | ... | @@ -7095,7 +7095,7 @@ fn airAggregateInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7095 | 7095 | try f.writeCValue(writer, element, .Other); |
| 7096 | 7096 | try a.end(f, writer); |
| 7097 | 7097 | }, |
| 7098 | .Packed => { | |
| 7098 | .@"packed" => { | |
| 7099 | 7099 | try f.writeCValue(writer, local, .Other); |
| 7100 | 7100 | try writer.writeAll(" = "); |
| 7101 | 7101 | const int_info = inst_ty.intInfo(mod); |
| ... | ... | @@ -7181,7 +7181,7 @@ fn airUnionInit(f: *Function, inst: Air.Inst.Index) !CValue { |
| 7181 | 7181 | |
| 7182 | 7182 | const writer = f.object.writer(); |
| 7183 | 7183 | const local = try f.allocLocal(inst, union_ty); |
| 7184 | if (union_obj.getLayout(ip) == .Packed) { | |
| 7184 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 7185 | 7185 | try f.writeCValue(writer, local, .Other); |
| 7186 | 7186 | try writer.writeAll(" = "); |
| 7187 | 7187 | try f.writeCValue(writer, payload, .Initializer); |
src/codegen/c/type.zig+1-1| ... | ... | @@ -1495,7 +1495,7 @@ pub const CType = extern union { |
| 1495 | 1495 | } |
| 1496 | 1496 | }, |
| 1497 | 1497 | |
| 1498 | .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .Packed) { | |
| 1498 | .Struct, .Union => |zig_ty_tag| if (ty.containerLayout(mod) == .@"packed") { | |
| 1499 | 1499 | if (mod.typeToPackedStruct(ty)) |packed_struct| { |
| 1500 | 1500 | try self.initType(Type.fromInterned(packed_struct.backingIntType(ip).*), kind, lookup); |
| 1501 | 1501 | } else { |
src/codegen/llvm.zig+17-17| ... | ... | @@ -3327,7 +3327,7 @@ pub const Object = struct { |
| 3327 | 3327 | |
| 3328 | 3328 | const struct_type = ip.loadStructType(t.toIntern()); |
| 3329 | 3329 | |
| 3330 | if (struct_type.layout == .Packed) { | |
| 3330 | if (struct_type.layout == .@"packed") { | |
| 3331 | 3331 | const int_ty = try o.lowerType(Type.fromInterned(struct_type.backingIntType(ip).*)); |
| 3332 | 3332 | try o.type_map.put(o.gpa, t.toIntern(), int_ty); |
| 3333 | 3333 | return int_ty; |
| ... | ... | @@ -3477,7 +3477,7 @@ pub const Object = struct { |
| 3477 | 3477 | const union_obj = ip.loadUnionType(t.toIntern()); |
| 3478 | 3478 | const layout = mod.getUnionLayout(union_obj); |
| 3479 | 3479 | |
| 3480 | if (union_obj.flagsPtr(ip).layout == .Packed) { | |
| 3480 | if (union_obj.flagsPtr(ip).layout == .@"packed") { | |
| 3481 | 3481 | const int_ty = try o.builder.intType(@intCast(t.bitSize(mod))); |
| 3482 | 3482 | try o.type_map.put(o.gpa, t.toIntern(), int_ty); |
| 3483 | 3483 | return int_ty; |
| ... | ... | @@ -4038,7 +4038,7 @@ pub const Object = struct { |
| 4038 | 4038 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 4039 | 4039 | assert(struct_type.haveLayout(ip)); |
| 4040 | 4040 | const struct_ty = try o.lowerType(ty); |
| 4041 | if (struct_type.layout == .Packed) { | |
| 4041 | if (struct_type.layout == .@"packed") { | |
| 4042 | 4042 | comptime assert(Type.packed_struct_layout_version == 2); |
| 4043 | 4043 | var running_int = try o.builder.intConst(struct_ty, 0); |
| 4044 | 4044 | var running_bits: u16 = 0; |
| ... | ... | @@ -4154,7 +4154,7 @@ pub const Object = struct { |
| 4154 | 4154 | const payload = if (un.tag != .none) p: { |
| 4155 | 4155 | const field_index = mod.unionTagFieldIndex(union_obj, Value.fromInterned(un.tag)).?; |
| 4156 | 4156 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[field_index]); |
| 4157 | if (container_layout == .Packed) { | |
| 4157 | if (container_layout == .@"packed") { | |
| 4158 | 4158 | if (!field_ty.hasRuntimeBits(mod)) return o.builder.intConst(union_ty, 0); |
| 4159 | 4159 | const small_int_val = try o.builder.castConst( |
| 4160 | 4160 | if (field_ty.isPtrAtRuntime(mod)) .ptrtoint else .bitcast, |
| ... | ... | @@ -4190,7 +4190,7 @@ pub const Object = struct { |
| 4190 | 4190 | } else p: { |
| 4191 | 4191 | assert(layout.tag_size == 0); |
| 4192 | 4192 | const union_val = try o.lowerValue(un.val); |
| 4193 | if (container_layout == .Packed) { | |
| 4193 | if (container_layout == .@"packed") { | |
| 4194 | 4194 | const bitcast_val = try o.builder.castConst( |
| 4195 | 4195 | .bitcast, |
| 4196 | 4196 | union_val, |
| ... | ... | @@ -4324,7 +4324,7 @@ pub const Object = struct { |
| 4324 | 4324 | const field_index: u32 = @intCast(field_ptr.index); |
| 4325 | 4325 | switch (parent_ty.zigTypeTag(mod)) { |
| 4326 | 4326 | .Union => { |
| 4327 | if (parent_ty.containerLayout(mod) == .Packed) { | |
| 4327 | if (parent_ty.containerLayout(mod) == .@"packed") { | |
| 4328 | 4328 | return parent_ptr; |
| 4329 | 4329 | } |
| 4330 | 4330 | |
| ... | ... | @@ -6531,7 +6531,7 @@ pub const FuncGen = struct { |
| 6531 | 6531 | assert(!isByRef(field_ty, mod)); |
| 6532 | 6532 | switch (struct_ty.zigTypeTag(mod)) { |
| 6533 | 6533 | .Struct => switch (struct_ty.containerLayout(mod)) { |
| 6534 | .Packed => { | |
| 6534 | .@"packed" => { | |
| 6535 | 6535 | const struct_type = mod.typeToStruct(struct_ty).?; |
| 6536 | 6536 | const bit_offset = mod.structPackedFieldBitOffset(struct_type, field_index); |
| 6537 | 6537 | const containing_int = struct_llvm_val; |
| ... | ... | @@ -6558,7 +6558,7 @@ pub const FuncGen = struct { |
| 6558 | 6558 | }, |
| 6559 | 6559 | }, |
| 6560 | 6560 | .Union => { |
| 6561 | assert(struct_ty.containerLayout(mod) == .Packed); | |
| 6561 | assert(struct_ty.containerLayout(mod) == .@"packed"); | |
| 6562 | 6562 | const containing_int = struct_llvm_val; |
| 6563 | 6563 | const elem_llvm_ty = try o.lowerType(field_ty); |
| 6564 | 6564 | if (field_ty.zigTypeTag(mod) == .Float or field_ty.zigTypeTag(mod) == .Vector) { |
| ... | ... | @@ -6581,7 +6581,7 @@ pub const FuncGen = struct { |
| 6581 | 6581 | switch (struct_ty.zigTypeTag(mod)) { |
| 6582 | 6582 | .Struct => { |
| 6583 | 6583 | const layout = struct_ty.containerLayout(mod); |
| 6584 | assert(layout != .Packed); | |
| 6584 | assert(layout != .@"packed"); | |
| 6585 | 6585 | const struct_llvm_ty = try o.lowerType(struct_ty); |
| 6586 | 6586 | const llvm_field_index = o.llvmFieldIndex(struct_ty, field_index).?; |
| 6587 | 6587 | const field_ptr = |
| ... | ... | @@ -9995,7 +9995,7 @@ pub const FuncGen = struct { |
| 9995 | 9995 | return running_int; |
| 9996 | 9996 | } |
| 9997 | 9997 | |
| 9998 | assert(result_ty.containerLayout(mod) != .Packed); | |
| 9998 | assert(result_ty.containerLayout(mod) != .@"packed"); | |
| 9999 | 9999 | |
| 10000 | 10000 | if (isByRef(result_ty, mod)) { |
| 10001 | 10001 | // TODO in debug builds init to undef so that the padding will be 0xaa |
| ... | ... | @@ -10080,7 +10080,7 @@ pub const FuncGen = struct { |
| 10080 | 10080 | const layout = union_ty.unionGetLayout(mod); |
| 10081 | 10081 | const union_obj = mod.typeToUnion(union_ty).?; |
| 10082 | 10082 | |
| 10083 | if (union_obj.getLayout(ip) == .Packed) { | |
| 10083 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 10084 | 10084 | const big_bits = union_ty.bitSize(mod); |
| 10085 | 10085 | const int_llvm_ty = try o.builder.intType(@intCast(big_bits)); |
| 10086 | 10086 | const field_ty = Type.fromInterned(union_obj.field_types.get(ip)[extra.field_index]); |
| ... | ... | @@ -10420,7 +10420,7 @@ pub const FuncGen = struct { |
| 10420 | 10420 | const struct_ty = struct_ptr_ty.childType(mod); |
| 10421 | 10421 | switch (struct_ty.zigTypeTag(mod)) { |
| 10422 | 10422 | .Struct => switch (struct_ty.containerLayout(mod)) { |
| 10423 | .Packed => { | |
| 10423 | .@"packed" => { | |
| 10424 | 10424 | const result_ty = self.typeOfIndex(inst); |
| 10425 | 10425 | const result_ty_info = result_ty.ptrInfo(mod); |
| 10426 | 10426 | const struct_ptr_ty_info = struct_ptr_ty.ptrInfo(mod); |
| ... | ... | @@ -10462,7 +10462,7 @@ pub const FuncGen = struct { |
| 10462 | 10462 | }, |
| 10463 | 10463 | .Union => { |
| 10464 | 10464 | 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; | |
| 10466 | 10466 | const payload_index = @intFromBool(layout.tag_align.compare(.gte, layout.payload_align)); |
| 10467 | 10467 | const union_llvm_ty = try o.lowerType(struct_ty); |
| 10468 | 10468 | return self.wip.gepStruct(union_llvm_ty, struct_ptr, payload_index, ""); |
| ... | ... | @@ -11572,7 +11572,7 @@ fn isByRef(ty: Type, mod: *Module) bool { |
| 11572 | 11572 | }; |
| 11573 | 11573 | |
| 11574 | 11574 | // Packed structs are represented to LLVM as integers. |
| 11575 | if (struct_type.layout == .Packed) return false; | |
| 11575 | if (struct_type.layout == .@"packed") return false; | |
| 11576 | 11576 | |
| 11577 | 11577 | const field_types = struct_type.field_types.get(ip); |
| 11578 | 11578 | var it = struct_type.iterateRuntimeOrder(ip); |
| ... | ... | @@ -11586,7 +11586,7 @@ fn isByRef(ty: Type, mod: *Module) bool { |
| 11586 | 11586 | return false; |
| 11587 | 11587 | }, |
| 11588 | 11588 | .Union => switch (ty.containerLayout(mod)) { |
| 11589 | .Packed => return false, | |
| 11589 | .@"packed" => return false, | |
| 11590 | 11590 | else => return ty.hasRuntimeBits(mod), |
| 11591 | 11591 | }, |
| 11592 | 11592 | .ErrorUnion => { |
| ... | ... | @@ -11624,8 +11624,8 @@ fn isScalar(mod: *Module, ty: Type) bool { |
| 11624 | 11624 | .Vector, |
| 11625 | 11625 | => true, |
| 11626 | 11626 | |
| 11627 | .Struct => ty.containerLayout(mod) == .Packed, | |
| 11628 | .Union => ty.containerLayout(mod) == .Packed, | |
| 11627 | .Struct => ty.containerLayout(mod) == .@"packed", | |
| 11628 | .Union => ty.containerLayout(mod) == .@"packed", | |
| 11629 | 11629 | else => false, |
| 11630 | 11630 | }; |
| 11631 | 11631 | } |
src/codegen/spirv.zig+8-8| ... | ... | @@ -979,7 +979,7 @@ const DeclGen = struct { |
| 979 | 979 | }, |
| 980 | 980 | .struct_type => { |
| 981 | 981 | const struct_type = mod.typeToStruct(ty).?; |
| 982 | if (struct_type.layout == .Packed) { | |
| 982 | if (struct_type.layout == .@"packed") { | |
| 983 | 983 | return self.todo("packed struct constants", .{}); |
| 984 | 984 | } |
| 985 | 985 | |
| ... | ... | @@ -1275,7 +1275,7 @@ const DeclGen = struct { |
| 1275 | 1275 | const ip = &mod.intern_pool; |
| 1276 | 1276 | const union_obj = mod.typeToUnion(ty).?; |
| 1277 | 1277 | |
| 1278 | if (union_obj.getLayout(ip) == .Packed) { | |
| 1278 | if (union_obj.getLayout(ip) == .@"packed") { | |
| 1279 | 1279 | return self.todo("packed union types", .{}); |
| 1280 | 1280 | } |
| 1281 | 1281 | |
| ... | ... | @@ -1532,7 +1532,7 @@ const DeclGen = struct { |
| 1532 | 1532 | else => unreachable, |
| 1533 | 1533 | }; |
| 1534 | 1534 | |
| 1535 | if (struct_type.layout == .Packed) { | |
| 1535 | if (struct_type.layout == .@"packed") { | |
| 1536 | 1536 | return try self.resolveType(Type.fromInterned(struct_type.backingIntType(ip).*), .direct); |
| 1537 | 1537 | } |
| 1538 | 1538 | |
| ... | ... | @@ -3904,7 +3904,7 @@ const DeclGen = struct { |
| 3904 | 3904 | const union_ty = mod.typeToUnion(ty).?; |
| 3905 | 3905 | const tag_ty = Type.fromInterned(union_ty.enum_tag_ty); |
| 3906 | 3906 | |
| 3907 | if (union_ty.getLayout(ip) == .Packed) { | |
| 3907 | if (union_ty.getLayout(ip) == .@"packed") { | |
| 3908 | 3908 | unreachable; // TODO |
| 3909 | 3909 | } |
| 3910 | 3910 | |
| ... | ... | @@ -3984,11 +3984,11 @@ const DeclGen = struct { |
| 3984 | 3984 | |
| 3985 | 3985 | switch (object_ty.zigTypeTag(mod)) { |
| 3986 | 3986 | .Struct => switch (object_ty.containerLayout(mod)) { |
| 3987 | .Packed => unreachable, // TODO | |
| 3987 | .@"packed" => unreachable, // TODO | |
| 3988 | 3988 | else => return try self.extractField(field_ty, object_id, field_index), |
| 3989 | 3989 | }, |
| 3990 | 3990 | .Union => switch (object_ty.containerLayout(mod)) { |
| 3991 | .Packed => unreachable, // TODO | |
| 3991 | .@"packed" => unreachable, // TODO | |
| 3992 | 3992 | else => { |
| 3993 | 3993 | // Store, ptr-elem-ptr, pointer-cast, load |
| 3994 | 3994 | const layout = self.unionLayout(object_ty); |
| ... | ... | @@ -4058,13 +4058,13 @@ const DeclGen = struct { |
| 4058 | 4058 | const object_ty = object_ptr_ty.childType(mod); |
| 4059 | 4059 | switch (object_ty.zigTypeTag(mod)) { |
| 4060 | 4060 | .Struct => switch (object_ty.containerLayout(mod)) { |
| 4061 | .Packed => unreachable, // TODO | |
| 4061 | .@"packed" => unreachable, // TODO | |
| 4062 | 4062 | else => { |
| 4063 | 4063 | return try self.accessChain(result_ty_ref, object_ptr, &.{field_index}); |
| 4064 | 4064 | }, |
| 4065 | 4065 | }, |
| 4066 | 4066 | .Union => switch (object_ty.containerLayout(mod)) { |
| 4067 | .Packed => unreachable, // TODO | |
| 4067 | .@"packed" => unreachable, // TODO | |
| 4068 | 4068 | else => { |
| 4069 | 4069 | const layout = self.unionLayout(object_ty); |
| 4070 | 4070 | 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) |
| 154 | 154 | } |
| 155 | 155 | }, |
| 156 | 156 | .Struct => |info| { |
| 157 | if (info.layout == .Packed) { | |
| 157 | if (info.layout == .@"packed") { | |
| 158 | 158 | section.writeWord(@as(Word, @bitCast(operand))); |
| 159 | 159 | } else { |
| 160 | 160 | section.writeExtendedMask(Operand, operand); |
| ... | ... | @@ -288,7 +288,7 @@ fn operandSize(comptime Operand: type, operand: Operand) usize { |
| 288 | 288 | } |
| 289 | 289 | break :blk total; |
| 290 | 290 | }, |
| 291 | .Struct => |info| if (info.layout == .Packed) 1 else extendedMaskSize(Operand, operand), | |
| 291 | .Struct => |info| if (info.layout == .@"packed") 1 else extendedMaskSize(Operand, operand), | |
| 292 | 292 | .Union => extendedUnionSize(Operand, operand), |
| 293 | 293 | else => unreachable, |
| 294 | 294 | }, |
src/link/Dwarf.zig+1-1| ... | ... | @@ -317,7 +317,7 @@ pub const DeclState = struct { |
| 317 | 317 | try ty.print(dbg_info_buffer.writer(), mod); |
| 318 | 318 | try dbg_info_buffer.append(0); |
| 319 | 319 | |
| 320 | if (struct_type.layout == .Packed) { | |
| 320 | if (struct_type.layout == .@"packed") { | |
| 321 | 321 | log.debug("TODO implement .debug_info for packed structs", .{}); |
| 322 | 322 | break :blk; |
| 323 | 323 | } |
src/print_zir.zig+1-1| ... | ... | @@ -1440,7 +1440,7 @@ const Writer = struct { |
| 1440 | 1440 | if (small.has_backing_int) { |
| 1441 | 1441 | const backing_int_body_len = self.code.extra[extra_index]; |
| 1442 | 1442 | extra_index += 1; |
| 1443 | try stream.writeAll("Packed("); | |
| 1443 | try stream.writeAll("packed("); | |
| 1444 | 1444 | if (backing_int_body_len == 0) { |
| 1445 | 1445 | const backing_int_ref: Zir.Inst.Ref = @enumFromInt(self.code.extra[extra_index]); |
| 1446 | 1446 | extra_index += 1; |
src/type.zig+19-19| ... | ... | @@ -741,12 +741,12 @@ pub const Type = struct { |
| 741 | 741 | .struct_type => { |
| 742 | 742 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 743 | 743 | // 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; | |
| 745 | 745 | }, |
| 746 | 746 | .union_type => { |
| 747 | 747 | const union_type = ip.loadUnionType(ty.toIntern()); |
| 748 | 748 | 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, | |
| 750 | 750 | .tagged => false, |
| 751 | 751 | }; |
| 752 | 752 | }, |
| ... | ... | @@ -1027,7 +1027,7 @@ pub const Type = struct { |
| 1027 | 1027 | }, |
| 1028 | 1028 | .struct_type => { |
| 1029 | 1029 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 1030 | if (struct_type.layout == .Packed) { | |
| 1030 | if (struct_type.layout == .@"packed") { | |
| 1031 | 1031 | switch (strat) { |
| 1032 | 1032 | .sema => |sema| try sema.resolveTypeLayout(ty), |
| 1033 | 1033 | .lazy => if (struct_type.backingIntType(ip).* == .none) return .{ |
| ... | ... | @@ -1407,7 +1407,7 @@ pub const Type = struct { |
| 1407 | 1407 | switch (strat) { |
| 1408 | 1408 | .sema => |sema| try sema.resolveTypeLayout(ty), |
| 1409 | 1409 | .lazy => switch (struct_type.layout) { |
| 1410 | .Packed => { | |
| 1410 | .@"packed" => { | |
| 1411 | 1411 | if (struct_type.backingIntType(ip).* == .none) return .{ |
| 1412 | 1412 | .val = Value.fromInterned((try mod.intern(.{ .int = .{ |
| 1413 | 1413 | .ty = .comptime_int_type, |
| ... | ... | @@ -1415,7 +1415,7 @@ pub const Type = struct { |
| 1415 | 1415 | } }))), |
| 1416 | 1416 | }; |
| 1417 | 1417 | }, |
| 1418 | .Auto, .Extern => { | |
| 1418 | .auto, .@"extern" => { | |
| 1419 | 1419 | if (!struct_type.haveLayout(ip)) return .{ |
| 1420 | 1420 | .val = Value.fromInterned((try mod.intern(.{ .int = .{ |
| 1421 | 1421 | .ty = .comptime_int_type, |
| ... | ... | @@ -1427,10 +1427,10 @@ pub const Type = struct { |
| 1427 | 1427 | .eager => {}, |
| 1428 | 1428 | } |
| 1429 | 1429 | switch (struct_type.layout) { |
| 1430 | .Packed => return .{ | |
| 1430 | .@"packed" => return .{ | |
| 1431 | 1431 | .scalar = Type.fromInterned(struct_type.backingIntType(ip).*).abiSize(mod), |
| 1432 | 1432 | }, |
| 1433 | .Auto, .Extern => { | |
| 1433 | .auto, .@"extern" => { | |
| 1434 | 1434 | assert(struct_type.haveLayout(ip)); |
| 1435 | 1435 | return .{ .scalar = struct_type.size(ip).* }; |
| 1436 | 1436 | }, |
| ... | ... | @@ -1656,7 +1656,7 @@ pub const Type = struct { |
| 1656 | 1656 | }, |
| 1657 | 1657 | .struct_type => { |
| 1658 | 1658 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 1659 | const is_packed = struct_type.layout == .Packed; | |
| 1659 | const is_packed = struct_type.layout == .@"packed"; | |
| 1660 | 1660 | if (opt_sema) |sema| { |
| 1661 | 1661 | try sema.resolveTypeFields(ty); |
| 1662 | 1662 | if (is_packed) try sema.resolveTypeLayout(ty); |
| ... | ... | @@ -1674,7 +1674,7 @@ pub const Type = struct { |
| 1674 | 1674 | |
| 1675 | 1675 | .union_type => { |
| 1676 | 1676 | const union_type = ip.loadUnionType(ty.toIntern()); |
| 1677 | const is_packed = ty.containerLayout(mod) == .Packed; | |
| 1677 | const is_packed = ty.containerLayout(mod) == .@"packed"; | |
| 1678 | 1678 | if (opt_sema) |sema| { |
| 1679 | 1679 | try sema.resolveTypeFields(ty); |
| 1680 | 1680 | if (is_packed) try sema.resolveTypeLayout(ty); |
| ... | ... | @@ -1987,9 +1987,9 @@ pub const Type = struct { |
| 1987 | 1987 | /// Asserts the type is either an extern or packed union. |
| 1988 | 1988 | pub fn unionBackingType(ty: Type, mod: *Module) !Type { |
| 1989 | 1989 | 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, | |
| 1993 | 1993 | }; |
| 1994 | 1994 | } |
| 1995 | 1995 | |
| ... | ... | @@ -2003,7 +2003,7 @@ pub const Type = struct { |
| 2003 | 2003 | const ip = &mod.intern_pool; |
| 2004 | 2004 | return switch (ip.indexToKey(ty.toIntern())) { |
| 2005 | 2005 | .struct_type => ip.loadStructType(ty.toIntern()).layout, |
| 2006 | .anon_struct_type => .Auto, | |
| 2006 | .anon_struct_type => .auto, | |
| 2007 | 2007 | .union_type => ip.loadUnionType(ty.toIntern()).flagsPtr(ip).layout, |
| 2008 | 2008 | else => unreachable, |
| 2009 | 2009 | }; |
| ... | ... | @@ -2177,7 +2177,7 @@ pub const Type = struct { |
| 2177 | 2177 | pub fn isAbiInt(ty: Type, mod: *Module) bool { |
| 2178 | 2178 | return switch (ty.zigTypeTag(mod)) { |
| 2179 | 2179 | .Int, .Enum, .ErrorSet => true, |
| 2180 | .Struct => ty.containerLayout(mod) == .Packed, | |
| 2180 | .Struct => ty.containerLayout(mod) == .@"packed", | |
| 2181 | 2181 | else => false, |
| 2182 | 2182 | }; |
| 2183 | 2183 | } |
| ... | ... | @@ -2690,7 +2690,7 @@ pub const Type = struct { |
| 2690 | 2690 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 2691 | 2691 | // packed structs cannot be comptime-only because they have a well-defined |
| 2692 | 2692 | // memory layout and every field has a well-defined bit pattern. |
| 2693 | if (struct_type.layout == .Packed) | |
| 2693 | if (struct_type.layout == .@"packed") | |
| 2694 | 2694 | return false; |
| 2695 | 2695 | |
| 2696 | 2696 | // A struct with no fields is not comptime-only. |
| ... | ... | @@ -3051,7 +3051,7 @@ pub const Type = struct { |
| 3051 | 3051 | switch (ip.indexToKey(ty.toIntern())) { |
| 3052 | 3052 | .struct_type => { |
| 3053 | 3053 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3054 | assert(struct_type.layout != .Packed); | |
| 3054 | assert(struct_type.layout != .@"packed"); | |
| 3055 | 3055 | const explicit_align = struct_type.fieldAlign(ip, index); |
| 3056 | 3056 | const field_ty = Type.fromInterned(struct_type.field_types.get(ip)[index]); |
| 3057 | 3057 | return mod.structFieldAlignment(explicit_align, field_ty, struct_type.layout); |
| ... | ... | @@ -3132,7 +3132,7 @@ pub const Type = struct { |
| 3132 | 3132 | .struct_type => { |
| 3133 | 3133 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3134 | 3134 | assert(struct_type.haveLayout(ip)); |
| 3135 | assert(struct_type.layout != .Packed); | |
| 3135 | assert(struct_type.layout != .@"packed"); | |
| 3136 | 3136 | return struct_type.offsets.get(ip)[index]; |
| 3137 | 3137 | }, |
| 3138 | 3138 | |
| ... | ... | @@ -3208,7 +3208,7 @@ pub const Type = struct { |
| 3208 | 3208 | return switch (ip.indexToKey(ty.toIntern())) { |
| 3209 | 3209 | .struct_type => { |
| 3210 | 3210 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3211 | if (struct_type.layout == .Packed) return false; | |
| 3211 | if (struct_type.layout == .@"packed") return false; | |
| 3212 | 3212 | if (struct_type.decl == .none) return false; |
| 3213 | 3213 | return struct_type.flagsPtr(ip).is_tuple; |
| 3214 | 3214 | }, |
| ... | ... | @@ -3230,7 +3230,7 @@ pub const Type = struct { |
| 3230 | 3230 | return switch (ip.indexToKey(ty.toIntern())) { |
| 3231 | 3231 | .struct_type => { |
| 3232 | 3232 | const struct_type = ip.loadStructType(ty.toIntern()); |
| 3233 | if (struct_type.layout == .Packed) return false; | |
| 3233 | if (struct_type.layout == .@"packed") return false; | |
| 3234 | 3234 | if (struct_type.decl == .none) return false; |
| 3235 | 3235 | return struct_type.flagsPtr(ip).is_tuple; |
| 3236 | 3236 | }, |
test/behavior/tuple.zig+3-3| ... | ... | @@ -135,7 +135,7 @@ test "array-like initializer for tuple types" { |
| 135 | 135 | const T = @Type(.{ |
| 136 | 136 | .Struct = .{ |
| 137 | 137 | .is_tuple = true, |
| 138 | .layout = .Auto, | |
| 138 | .layout = .auto, | |
| 139 | 139 | .decls = &.{}, |
| 140 | 140 | .fields = &.{ |
| 141 | 141 | .{ |
| ... | ... | @@ -323,7 +323,7 @@ test "zero sized struct in tuple handled correctly" { |
| 323 | 323 | data: @Type(.{ |
| 324 | 324 | .Struct = .{ |
| 325 | 325 | .is_tuple = true, |
| 326 | .layout = .Auto, | |
| 326 | .layout = .auto, | |
| 327 | 327 | .decls = &.{}, |
| 328 | 328 | .fields = &.{.{ |
| 329 | 329 | .name = "0", |
| ... | ... | @@ -471,7 +471,7 @@ test "coerce anon tuple to tuple" { |
| 471 | 471 | |
| 472 | 472 | test "empty tuple type" { |
| 473 | 473 | const S = @Type(.{ .Struct = .{ |
| 474 | .layout = .Auto, | |
| 474 | .layout = .auto, | |
| 475 | 475 | .fields = &.{}, |
| 476 | 476 | .decls = &.{}, |
| 477 | 477 | .is_tuple = true, |
test/behavior/tuple_declarations.zig+1-1| ... | ... | @@ -12,7 +12,7 @@ test "tuple declaration type info" { |
| 12 | 12 | const T = struct { comptime u32 align(2) = 1, []const u8 }; |
| 13 | 13 | const info = @typeInfo(T).Struct; |
| 14 | 14 | |
| 15 | try expect(info.layout == .Auto); | |
| 15 | try expect(info.layout == .auto); | |
| 16 | 16 | try expect(info.backing_integer == null); |
| 17 | 17 | try expect(info.fields.len == 2); |
| 18 | 18 | try expect(info.decls.len == 0); |
test/behavior/type.zig+19-19| ... | ... | @@ -263,7 +263,7 @@ test "Type.Struct" { |
| 263 | 263 | |
| 264 | 264 | const A = @Type(@typeInfo(struct { x: u8, y: u32 })); |
| 265 | 265 | const infoA = @typeInfo(A).Struct; |
| 266 | try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout); | |
| 266 | try testing.expectEqual(Type.ContainerLayout.auto, infoA.layout); | |
| 267 | 267 | try testing.expectEqualSlices(u8, "x", infoA.fields[0].name); |
| 268 | 268 | try testing.expectEqual(u8, infoA.fields[0].type); |
| 269 | 269 | try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value); |
| ... | ... | @@ -281,7 +281,7 @@ test "Type.Struct" { |
| 281 | 281 | |
| 282 | 282 | const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 })); |
| 283 | 283 | const infoB = @typeInfo(B).Struct; |
| 284 | try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout); | |
| 284 | try testing.expectEqual(Type.ContainerLayout.@"extern", infoB.layout); | |
| 285 | 285 | try testing.expectEqualSlices(u8, "x", infoB.fields[0].name); |
| 286 | 286 | try testing.expectEqual(u8, infoB.fields[0].type); |
| 287 | 287 | try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value); |
| ... | ... | @@ -293,7 +293,7 @@ test "Type.Struct" { |
| 293 | 293 | |
| 294 | 294 | const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 })); |
| 295 | 295 | const infoC = @typeInfo(C).Struct; |
| 296 | try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout); | |
| 296 | try testing.expectEqual(Type.ContainerLayout.@"packed", infoC.layout); | |
| 297 | 297 | try testing.expectEqualSlices(u8, "x", infoC.fields[0].name); |
| 298 | 298 | try testing.expectEqual(u8, infoC.fields[0].type); |
| 299 | 299 | try testing.expectEqual(@as(u8, 3), @as(*const u8, @ptrCast(infoC.fields[0].default_value.?)).*); |
| ... | ... | @@ -306,7 +306,7 @@ test "Type.Struct" { |
| 306 | 306 | // anon structs |
| 307 | 307 | const D = @Type(@typeInfo(@TypeOf(.{ .x = 3, .y = 5 }))); |
| 308 | 308 | const infoD = @typeInfo(D).Struct; |
| 309 | try testing.expectEqual(Type.ContainerLayout.Auto, infoD.layout); | |
| 309 | try testing.expectEqual(Type.ContainerLayout.auto, infoD.layout); | |
| 310 | 310 | try testing.expectEqualSlices(u8, "x", infoD.fields[0].name); |
| 311 | 311 | try testing.expectEqual(comptime_int, infoD.fields[0].type); |
| 312 | 312 | try testing.expectEqual(@as(comptime_int, 3), @as(*const comptime_int, @ptrCast(infoD.fields[0].default_value.?)).*); |
| ... | ... | @@ -319,7 +319,7 @@ test "Type.Struct" { |
| 319 | 319 | // tuples |
| 320 | 320 | const E = @Type(@typeInfo(@TypeOf(.{ 1, 2 }))); |
| 321 | 321 | const infoE = @typeInfo(E).Struct; |
| 322 | try testing.expectEqual(Type.ContainerLayout.Auto, infoE.layout); | |
| 322 | try testing.expectEqual(Type.ContainerLayout.auto, infoE.layout); | |
| 323 | 323 | try testing.expectEqualSlices(u8, "0", infoE.fields[0].name); |
| 324 | 324 | try testing.expectEqual(comptime_int, infoE.fields[0].type); |
| 325 | 325 | try testing.expectEqual(@as(comptime_int, 1), @as(*const comptime_int, @ptrCast(infoE.fields[0].default_value.?)).*); |
| ... | ... | @@ -332,14 +332,14 @@ test "Type.Struct" { |
| 332 | 332 | // empty struct |
| 333 | 333 | const F = @Type(@typeInfo(struct {})); |
| 334 | 334 | const infoF = @typeInfo(F).Struct; |
| 335 | try testing.expectEqual(Type.ContainerLayout.Auto, infoF.layout); | |
| 335 | try testing.expectEqual(Type.ContainerLayout.auto, infoF.layout); | |
| 336 | 336 | try testing.expect(infoF.fields.len == 0); |
| 337 | 337 | try testing.expectEqual(@as(bool, false), infoF.is_tuple); |
| 338 | 338 | |
| 339 | 339 | // empty tuple |
| 340 | 340 | const G = @Type(@typeInfo(@TypeOf(.{}))); |
| 341 | 341 | const infoG = @typeInfo(G).Struct; |
| 342 | try testing.expectEqual(Type.ContainerLayout.Auto, infoG.layout); | |
| 342 | try testing.expectEqual(Type.ContainerLayout.auto, infoG.layout); | |
| 343 | 343 | try testing.expect(infoG.fields.len == 0); |
| 344 | 344 | try testing.expectEqual(@as(bool, true), infoG.is_tuple); |
| 345 | 345 | } |
| ... | ... | @@ -386,7 +386,7 @@ test "Type.Union" { |
| 386 | 386 | |
| 387 | 387 | const Untagged = @Type(.{ |
| 388 | 388 | .Union = .{ |
| 389 | .layout = .Extern, | |
| 389 | .layout = .@"extern", | |
| 390 | 390 | .tag_type = null, |
| 391 | 391 | .fields = &.{ |
| 392 | 392 | .{ .name = "int", .type = i32, .alignment = @alignOf(f32) }, |
| ... | ... | @@ -402,7 +402,7 @@ test "Type.Union" { |
| 402 | 402 | |
| 403 | 403 | const PackedUntagged = @Type(.{ |
| 404 | 404 | .Union = .{ |
| 405 | .layout = .Packed, | |
| 405 | .layout = .@"packed", | |
| 406 | 406 | .tag_type = null, |
| 407 | 407 | .fields = &.{ |
| 408 | 408 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| ... | ... | @@ -429,7 +429,7 @@ test "Type.Union" { |
| 429 | 429 | }); |
| 430 | 430 | const Tagged = @Type(.{ |
| 431 | 431 | .Union = .{ |
| 432 | .layout = .Auto, | |
| 432 | .layout = .auto, | |
| 433 | 433 | .tag_type = Tag, |
| 434 | 434 | .fields = &.{ |
| 435 | 435 | .{ .name = "signed", .type = i32, .alignment = @alignOf(i32) }, |
| ... | ... | @@ -457,7 +457,7 @@ test "Type.Union from Type.Enum" { |
| 457 | 457 | }); |
| 458 | 458 | const T = @Type(.{ |
| 459 | 459 | .Union = .{ |
| 460 | .layout = .Auto, | |
| 460 | .layout = .auto, | |
| 461 | 461 | .tag_type = Tag, |
| 462 | 462 | .fields = &.{ |
| 463 | 463 | .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, |
| ... | ... | @@ -472,7 +472,7 @@ test "Type.Union from regular enum" { |
| 472 | 472 | const E = enum { working_as_expected }; |
| 473 | 473 | const T = @Type(.{ |
| 474 | 474 | .Union = .{ |
| 475 | .layout = .Auto, | |
| 475 | .layout = .auto, | |
| 476 | 476 | .tag_type = E, |
| 477 | 477 | .fields = &.{ |
| 478 | 478 | .{ .name = "working_as_expected", .type = u32, .alignment = @alignOf(u32) }, |
| ... | ... | @@ -487,7 +487,7 @@ test "Type.Union from empty regular enum" { |
| 487 | 487 | const E = enum {}; |
| 488 | 488 | const U = @Type(.{ |
| 489 | 489 | .Union = .{ |
| 490 | .layout = .Auto, | |
| 490 | .layout = .auto, | |
| 491 | 491 | .tag_type = E, |
| 492 | 492 | .fields = &.{}, |
| 493 | 493 | .decls = &.{}, |
| ... | ... | @@ -507,7 +507,7 @@ test "Type.Union from empty Type.Enum" { |
| 507 | 507 | }); |
| 508 | 508 | const U = @Type(.{ |
| 509 | 509 | .Union = .{ |
| 510 | .layout = .Auto, | |
| 510 | .layout = .auto, | |
| 511 | 511 | .tag_type = E, |
| 512 | 512 | .fields = &.{}, |
| 513 | 513 | .decls = &.{}, |
| ... | ... | @@ -553,7 +553,7 @@ test "reified struct field name from optional payload" { |
| 553 | 553 | const m_name: ?[1:0]u8 = "a".*; |
| 554 | 554 | if (m_name) |*name| { |
| 555 | 555 | const T = @Type(.{ .Struct = .{ |
| 556 | .layout = .Auto, | |
| 556 | .layout = .auto, | |
| 557 | 557 | .fields = &.{.{ |
| 558 | 558 | .name = name, |
| 559 | 559 | .type = u8, |
| ... | ... | @@ -575,7 +575,7 @@ test "reified union uses @alignOf" { |
| 575 | 575 | fn CreateUnion(comptime T: type) type { |
| 576 | 576 | return @Type(.{ |
| 577 | 577 | .Union = .{ |
| 578 | .layout = .Auto, | |
| 578 | .layout = .auto, | |
| 579 | 579 | .tag_type = null, |
| 580 | 580 | .fields = &[_]std.builtin.Type.UnionField{ |
| 581 | 581 | .{ |
| ... | ... | @@ -597,7 +597,7 @@ test "reified struct uses @alignOf" { |
| 597 | 597 | fn NamespacedGlobals(comptime modules: anytype) type { |
| 598 | 598 | return @Type(.{ |
| 599 | 599 | .Struct = .{ |
| 600 | .layout = .Auto, | |
| 600 | .layout = .auto, | |
| 601 | 601 | .is_tuple = false, |
| 602 | 602 | .fields = &.{ |
| 603 | 603 | .{ |
| ... | ... | @@ -659,7 +659,7 @@ test "empty struct assigned to reified struct field" { |
| 659 | 659 | fn NamespacedComponents(comptime modules: anytype) type { |
| 660 | 660 | return @Type(.{ |
| 661 | 661 | .Struct = .{ |
| 662 | .layout = .Auto, | |
| 662 | .layout = .auto, | |
| 663 | 663 | .is_tuple = false, |
| 664 | 664 | .fields = &.{.{ |
| 665 | 665 | .name = "components", |
| ... | ... | @@ -721,7 +721,7 @@ test "struct field names sliced at comptime from larger string" { |
| 721 | 721 | |
| 722 | 722 | const T = @Type(.{ |
| 723 | 723 | .Struct = .{ |
| 724 | .layout = .Auto, | |
| 724 | .layout = .auto, | |
| 725 | 725 | .is_tuple = false, |
| 726 | 726 | .fields = fields, |
| 727 | 727 | .decls = &.{}, |
test/behavior/type_info.zig+4-4| ... | ... | @@ -250,7 +250,7 @@ test "type info: union info" { |
| 250 | 250 | fn testUnion() !void { |
| 251 | 251 | const typeinfo_info = @typeInfo(Type); |
| 252 | 252 | try expect(typeinfo_info == .Union); |
| 253 | try expect(typeinfo_info.Union.layout == .Auto); | |
| 253 | try expect(typeinfo_info.Union.layout == .auto); | |
| 254 | 254 | try expect(typeinfo_info.Union.tag_type.? == TypeId); |
| 255 | 255 | try expect(typeinfo_info.Union.fields.len == 24); |
| 256 | 256 | try expect(typeinfo_info.Union.fields[4].type == @TypeOf(@typeInfo(u8).Int)); |
| ... | ... | @@ -264,7 +264,7 @@ fn testUnion() !void { |
| 264 | 264 | const notag_union_info = @typeInfo(TestNoTagUnion); |
| 265 | 265 | try expect(notag_union_info == .Union); |
| 266 | 266 | 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); | |
| 268 | 268 | try expect(notag_union_info.Union.fields.len == 2); |
| 269 | 269 | try expect(notag_union_info.Union.fields[0].alignment == @alignOf(void)); |
| 270 | 270 | try expect(notag_union_info.Union.fields[1].type == u32); |
| ... | ... | @@ -275,7 +275,7 @@ fn testUnion() !void { |
| 275 | 275 | }; |
| 276 | 276 | |
| 277 | 277 | const extern_union_info = @typeInfo(TestExternUnion); |
| 278 | try expect(extern_union_info.Union.layout == .Extern); | |
| 278 | try expect(extern_union_info.Union.layout == .@"extern"); | |
| 279 | 279 | try expect(extern_union_info.Union.tag_type == null); |
| 280 | 280 | try expect(extern_union_info.Union.fields[0].type == *anyopaque); |
| 281 | 281 | } |
| ... | ... | @@ -310,7 +310,7 @@ fn testPackedStruct() !void { |
| 310 | 310 | const struct_info = @typeInfo(TestPackedStruct); |
| 311 | 311 | try expect(struct_info == .Struct); |
| 312 | 312 | try expect(struct_info.Struct.is_tuple == false); |
| 313 | try expect(struct_info.Struct.layout == .Packed); | |
| 313 | try expect(struct_info.Struct.layout == .@"packed"); | |
| 314 | 314 | try expect(struct_info.Struct.backing_integer == u128); |
| 315 | 315 | try expect(struct_info.Struct.fields.len == 4); |
| 316 | 316 | 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 @@ |
| 1 | 1 | export fn entry() void { |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .Packed, .fields = &.{ | |
| 2 | _ = @Type(.{ .Struct = .{ .layout = .@"packed", .fields = &.{ | |
| 3 | 3 | .{ .name = "one", .type = u4, .default_value = null, .is_comptime = false, .alignment = 2 }, |
| 4 | 4 | }, .decls = &.{}, .is_tuple = false } }); |
| 5 | 5 | } |
test/cases/compile_errors/reify_struct.zig+5-5| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | comptime { |
| 2 | 2 | @Type(.{ .Struct = .{ |
| 3 | .layout = .Auto, | |
| 3 | .layout = .auto, | |
| 4 | 4 | .fields = &.{.{ |
| 5 | 5 | .name = "foo", |
| 6 | 6 | .type = u32, |
| ... | ... | @@ -14,7 +14,7 @@ comptime { |
| 14 | 14 | } |
| 15 | 15 | comptime { |
| 16 | 16 | @Type(.{ .Struct = .{ |
| 17 | .layout = .Auto, | |
| 17 | .layout = .auto, | |
| 18 | 18 | .fields = &.{.{ |
| 19 | 19 | .name = "3", |
| 20 | 20 | .type = u32, |
| ... | ... | @@ -28,7 +28,7 @@ comptime { |
| 28 | 28 | } |
| 29 | 29 | comptime { |
| 30 | 30 | @Type(.{ .Struct = .{ |
| 31 | .layout = .Auto, | |
| 31 | .layout = .auto, | |
| 32 | 32 | .fields = &.{.{ |
| 33 | 33 | .name = "0", |
| 34 | 34 | .type = u32, |
| ... | ... | @@ -42,7 +42,7 @@ comptime { |
| 42 | 42 | } |
| 43 | 43 | comptime { |
| 44 | 44 | @Type(.{ .Struct = .{ |
| 45 | .layout = .Extern, | |
| 45 | .layout = .@"extern", | |
| 46 | 46 | .fields = &.{.{ |
| 47 | 47 | .name = "0", |
| 48 | 48 | .type = u32, |
| ... | ... | @@ -56,7 +56,7 @@ comptime { |
| 56 | 56 | } |
| 57 | 57 | comptime { |
| 58 | 58 | @Type(.{ .Struct = .{ |
| 59 | .layout = .Packed, | |
| 59 | .layout = .@"packed", | |
| 60 | 60 | .fields = &.{.{ |
| 61 | 61 | .name = "0", |
| 62 | 62 | .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(.{ |
| 12 | 12 | }); |
| 13 | 13 | const Tagged = @Type(.{ |
| 14 | 14 | .Union = .{ |
| 15 | .layout = .Auto, | |
| 15 | .layout = .auto, | |
| 16 | 16 | .tag_type = Tag, |
| 17 | 17 | .fields = &.{ |
| 18 | 18 | .{ .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(.{ |
| 11 | 11 | }); |
| 12 | 12 | const Tagged = @Type(.{ |
| 13 | 13 | .Union = .{ |
| 14 | .layout = .Auto, | |
| 14 | .layout = .auto, | |
| 15 | 15 | .tag_type = Tag, |
| 16 | 16 | .fields = &.{ |
| 17 | 17 | .{ .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(.{ |
| 8 | 8 | }); |
| 9 | 9 | const Tagged = @Type(.{ |
| 10 | 10 | .Union = .{ |
| 11 | .layout = .Auto, | |
| 11 | .layout = .auto, | |
| 12 | 12 | .tag_type = Tag, |
| 13 | 13 | .fields = &.{ |
| 14 | 14 | .{ .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(.{ |
| 11 | 11 | }); |
| 12 | 12 | const Tagged = @Type(.{ |
| 13 | 13 | .Union = .{ |
| 14 | .layout = .Auto, | |
| 14 | .layout = .auto, | |
| 15 | 15 | .tag_type = Tag, |
| 16 | 16 | .fields = &.{}, |
| 17 | 17 | .decls = &.{}, |
test/cases/compile_errors/reify_type_for_union_with_opaque_field.zig+1-1| ... | ... | @@ -1,6 +1,6 @@ |
| 1 | 1 | const Untagged = @Type(.{ |
| 2 | 2 | .Union = .{ |
| 3 | .layout = .Auto, | |
| 3 | .layout = .auto, | |
| 4 | 4 | .tag_type = null, |
| 5 | 5 | .fields = &.{ |
| 6 | 6 | .{ .name = "foo", .type = opaque {}, .alignment = 1 }, |
test/cases/compile_errors/reify_type_with_invalid_field_alignment.zig+2-2| ... | ... | @@ -1,7 +1,7 @@ |
| 1 | 1 | comptime { |
| 2 | 2 | _ = @Type(.{ |
| 3 | 3 | .Union = .{ |
| 4 | .layout = .Auto, | |
| 4 | .layout = .auto, | |
| 5 | 5 | .tag_type = null, |
| 6 | 6 | .fields = &.{ |
| 7 | 7 | .{ .name = "foo", .type = usize, .alignment = 3 }, |
| ... | ... | @@ -13,7 +13,7 @@ comptime { |
| 13 | 13 | comptime { |
| 14 | 14 | _ = @Type(.{ |
| 15 | 15 | .Struct = .{ |
| 16 | .layout = .Auto, | |
| 16 | .layout = .auto, | |
| 17 | 17 | .fields = &.{.{ |
| 18 | 18 | .name = "0", |
| 19 | 19 | .type = u32, |
test/cases/compile_errors/reify_type_with_undefined.zig+2-2| ... | ... | @@ -7,7 +7,7 @@ comptime { |
| 7 | 7 | .fields = undefined, |
| 8 | 8 | .decls = undefined, |
| 9 | 9 | .is_tuple = false, |
| 10 | .layout = .Auto, | |
| 10 | .layout = .auto, | |
| 11 | 11 | }, |
| 12 | 12 | }); |
| 13 | 13 | } |
| ... | ... | @@ -16,7 +16,7 @@ comptime { |
| 16 | 16 | const fields: [1]std.builtin.Type.StructField = undefined; |
| 17 | 17 | _ = @Type(.{ |
| 18 | 18 | .Struct = .{ |
| 19 | .layout = .Auto, | |
| 19 | .layout = .auto, | |
| 20 | 20 | .fields = &fields, |
| 21 | 21 | .decls = &.{}, |
| 22 | 22 | .is_tuple = false, |