diff options
| -rw-r--r-- | lib/std/builtin.zig | 2 | ||||
| -rw-r--r-- | lib/std/meta.zig | 14 | ||||
| -rw-r--r-- | lib/std/meta/trait.zig | 2 | ||||
| -rw-r--r-- | src/Sema.zig | 24 | ||||
| -rw-r--r-- | test/behavior/generics.zig | 1 | ||||
| -rw-r--r-- | test/behavior/type.zig | 4 | ||||
| -rw-r--r-- | test/behavior/type_info.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/reified_enum_field_value_overflow.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/reify_enum_with_duplicate_field.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig | 1 | ||||
| -rw-r--r-- | test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig | 3 | ||||
| -rw-r--r-- | test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig | 3 |
14 files changed, 8 insertions, 51 deletions
diff --git a/lib/std/builtin.zig b/lib/std/builtin.zig index 349d976ddc..a0b3011d5c 100644 --- a/lib/std/builtin.zig +++ b/lib/std/builtin.zig @@ -330,8 +330,6 @@ pub const Type = union(enum) { /// This data structure is used by the Zig language code generation and /// therefore must be kept in sync with the compiler implementation. pub const Enum = struct { - /// TODO enums should no longer have this field in type info. - layout: ContainerLayout, tag_type: type, fields: []const EnumField, decls: []const Declaration, diff --git a/lib/std/meta.zig b/lib/std/meta.zig index b4a73ffb3a..39d561469f 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -371,16 +371,12 @@ test "std.meta.assumeSentinel" { pub fn containerLayout(comptime T: type) Type.ContainerLayout { return switch (@typeInfo(T)) { .Struct => |info| info.layout, - .Enum => |info| info.layout, .Union => |info| info.layout, - else => @compileError("Expected struct, enum or union type, found '" ++ @typeName(T) ++ "'"), + else => @compileError("expected struct or union type, found '" ++ @typeName(T) ++ "'"), }; } test "std.meta.containerLayout" { - const E1 = enum { - A, - }; const S1 = struct {}; const S2 = packed struct {}; const S3 = extern struct {}; @@ -394,7 +390,6 @@ test "std.meta.containerLayout" { a: u8, }; - try testing.expect(containerLayout(E1) == .Auto); try testing.expect(containerLayout(S1) == .Auto); try testing.expect(containerLayout(S2) == .Packed); try testing.expect(containerLayout(S3) == .Extern); @@ -634,7 +629,6 @@ pub fn FieldEnum(comptime T: type) type { if (field_infos.len == 0) { return @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u0, .fields = &.{}, .decls = &.{}, @@ -664,7 +658,6 @@ pub fn FieldEnum(comptime T: type) type { } return @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = std.math.IntFittingRange(0, field_infos.len - 1), .fields = &enumFields, .decls = &decls, @@ -677,10 +670,6 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void { // TODO: https://github.com/ziglang/zig/issues/7419 // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum); try testing.expectEqual( - @typeInfo(expected).Enum.layout, - @typeInfo(actual).Enum.layout, - ); - try testing.expectEqual( @typeInfo(expected).Enum.tag_type, @typeInfo(actual).Enum.tag_type, ); @@ -740,7 +729,6 @@ pub fn DeclEnum(comptime T: type) type { } return @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = std.math.IntFittingRange(0, fieldInfos.len - 1), .fields = &enumDecls, .decls = &decls, diff --git a/lib/std/meta/trait.zig b/lib/std/meta/trait.zig index 73d1292406..843ada7f56 100644 --- a/lib/std/meta/trait.zig +++ b/lib/std/meta/trait.zig @@ -154,7 +154,6 @@ pub fn isExtern(comptime T: type) bool { return switch (@typeInfo(T)) { .Struct => |s| s.layout == .Extern, .Union => |u| u.layout == .Extern, - .Enum => |e| e.layout == .Extern, else => false, }; } @@ -172,7 +171,6 @@ pub fn isPacked(comptime T: type) bool { return switch (@typeInfo(T)) { .Struct => |s| s.layout == .Packed, .Union => |u| u.layout == .Packed, - .Enum => |e| e.layout == .Packed, else => false, }; } diff --git a/src/Sema.zig b/src/Sema.zig index 6f1af51d28..f403b7e7e2 100644 --- a/src/Sema.zig +++ b/src/Sema.zig @@ -15690,14 +15690,8 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai const decls_val = try sema.typeInfoDecls(block, src, type_info_ty, ty.getNamespace()); - const field_values = try sema.arena.create([5]Value); + const field_values = try sema.arena.create([4]Value); field_values.* = .{ - // layout: ContainerLayout, - try Value.Tag.enum_field_index.create( - sema.arena, - @enumToInt(std.builtin.Type.ContainerLayout.Auto), - ), - // tag_type: type, try Value.Tag.ty.create(sema.arena, int_tag_ty), // fields: []const EnumField, @@ -18312,22 +18306,14 @@ fn zirReify(sema: *Sema, block: *Block, extended: Zir.Inst.Extended.InstData, in .Enum => { const struct_val: []const Value = union_val.val.castTag(.aggregate).?.data; // TODO use reflection instead of magic numbers here - // layout: ContainerLayout, - const layout_val = struct_val[0]; // tag_type: type, - const tag_type_val = struct_val[1]; + const tag_type_val = struct_val[0]; // fields: []const EnumField, - const fields_val = struct_val[2]; + const fields_val = struct_val[1]; // decls: []const Declaration, - const decls_val = struct_val[3]; + const decls_val = struct_val[2]; // is_exhaustive: bool, - const is_exhaustive_val = struct_val[4]; - - // enum layout is always auto - const layout = layout_val.toEnum(std.builtin.Type.ContainerLayout); - if (layout != .Auto) { - return sema.fail(block, src, "reified enums must have a layout .Auto", .{}); - } + const is_exhaustive_val = struct_val[3]; // Decls if (decls_val.sliceLen(mod) > 0) { diff --git a/test/behavior/generics.zig b/test/behavior/generics.zig index dafbfbafe8..17194fc445 100644 --- a/test/behavior/generics.zig +++ b/test/behavior/generics.zig @@ -273,7 +273,6 @@ test "generic function instantiation turns into comptime call" { var enumFields: [1]std.builtin.Type.EnumField = .{.{ .name = "A", .value = 0 }}; return @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u0, .fields = &enumFields, .decls = &.{}, diff --git a/test/behavior/type.zig b/test/behavior/type.zig index 157eff81e8..325bf0a8ed 100644 --- a/test/behavior/type.zig +++ b/test/behavior/type.zig @@ -354,7 +354,6 @@ test "Type.Enum" { const Foo = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u8, .fields = &.{ .{ .name = "a", .value = 1 }, @@ -369,7 +368,6 @@ test "Type.Enum" { try testing.expectEqual(@as(u8, 5), @enumToInt(Foo.b)); const Bar = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u32, .fields = &.{ .{ .name = "a", .value = 1 }, @@ -424,7 +422,6 @@ test "Type.Union" { const Tag = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u1, .fields = &.{ .{ .name = "signed", .value = 0 }, @@ -456,7 +453,6 @@ test "Type.Union from Type.Enum" { const Tag = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u0, .fields = &.{ .{ .name = "working_as_expected", .value = 0 }, diff --git a/test/behavior/type_info.zig b/test/behavior/type_info.zig index 04656a2034..8c895ceb00 100644 --- a/test/behavior/type_info.zig +++ b/test/behavior/type_info.zig @@ -238,7 +238,6 @@ fn testEnum() !void { const os_info = @typeInfo(Os); try expect(os_info == .Enum); - try expect(os_info.Enum.layout == .Auto); try expect(os_info.Enum.fields.len == 4); try expect(mem.eql(u8, os_info.Enum.fields[1].name, "Macos")); try expect(os_info.Enum.fields[3].value == 3); diff --git a/test/cases/compile_errors/reified_enum_field_value_overflow.zig b/test/cases/compile_errors/reified_enum_field_value_overflow.zig index ad8596ebcc..d9f0e2057f 100644 --- a/test/cases/compile_errors/reified_enum_field_value_overflow.zig +++ b/test/cases/compile_errors/reified_enum_field_value_overflow.zig @@ -1,6 +1,5 @@ comptime { const E = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u1, .fields = &.{ .{ .name = "f0", .value = 0 }, diff --git a/test/cases/compile_errors/reify_enum_with_duplicate_field.zig b/test/cases/compile_errors/reify_enum_with_duplicate_field.zig index f8cadd9185..a4779b65ef 100644 --- a/test/cases/compile_errors/reify_enum_with_duplicate_field.zig +++ b/test/cases/compile_errors/reify_enum_with_duplicate_field.zig @@ -1,7 +1,6 @@ export fn entry() void { _ = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u32, .fields = &.{ .{ .name = "A", .value = 0 }, diff --git a/test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig b/test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig index c3211fe301..b9be7cdaed 100644 --- a/test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig +++ b/test/cases/compile_errors/reify_enum_with_duplicate_tag_value.zig @@ -1,7 +1,6 @@ export fn entry() void { _ = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u32, .fields = &.{ .{ .name = "A", .value = 10 }, diff --git a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig index e72b783d83..60c6ce9a59 100644 --- a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig +++ b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_non-integer_tag_type.zig @@ -1,6 +1,5 @@ const Tag = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = bool, .fields = &.{}, .decls = &.{}, diff --git a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig index 1c237a17bd..896d689046 100644 --- a/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig +++ b/test/cases/compile_errors/reify_type_for_exhaustive_enum_with_undefined_tag_type.zig @@ -1,6 +1,5 @@ const Tag = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = undefined, .fields = &.{}, .decls = &.{}, diff --git a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig index 293e5c62e3..96da0752df 100644 --- a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig +++ b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_enum_field.zig @@ -1,6 +1,5 @@ const Tag = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u2, .fields = &.{ .{ .name = "signed", .value = 0 }, @@ -31,6 +30,6 @@ export fn entry() void { // backend=stage2 // target=native // -// :14:16: error: enum field(s) missing in union +// :13:16: error: enum field(s) missing in union // :1:13: note: field 'arst' missing, declared here // :1:13: note: enum declared here diff --git a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig index bb26230f22..559eb81fcd 100644 --- a/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig +++ b/test/cases/compile_errors/reify_type_for_tagged_union_with_extra_union_field.zig @@ -1,6 +1,5 @@ const Tag = @Type(.{ .Enum = .{ - .layout = .Auto, .tag_type = u1, .fields = &.{ .{ .name = "signed", .value = 0 }, @@ -31,5 +30,5 @@ export fn entry() void { // backend=stage2 // target=native // -// :13:16: error: no field named 'arst' in enum 'tmp.Tag' +// :12:16: error: no field named 'arst' in enum 'tmp.Tag' // :1:13: note: enum declared here |
