authorgravatar for johnnymarler@gmail.comJonathan Marler <johnnymarler@gmail.com> 2022-02-01 11:42:41-07:00
committergravatar for git@vexu.euVeikka Tuominen <git@vexu.eu> 2022-03-08 20:38:12+02:00
logd805adddd6744e0d55263c02d2a03e27ad0c7d68
tree430dca3714090db578e6b34ed497ff2b3baee783
parent404f5d617982e2323c6ab6b878c29880af3d64c2

deprecated TypeInfo in favor of Type

Co-authored-by: Veikka Tuominen <git@vexu.eu>

27 files changed, 219 insertions(+), 225 deletions(-)

lib/std/bit_set.zig+1-1
......@@ -252,7 +252,7 @@ pub fn IntegerBitSet(comptime size: u16) type {
252252/// This set is good for sets with a larger size, but may use
253253/// more bytes than necessary if your set is small.
254254pub fn ArrayBitSet(comptime MaskIntType: type, comptime size: usize) type {
255 const mask_info: std.builtin.TypeInfo = @typeInfo(MaskIntType);
255 const mask_info: std.builtin.Type = @typeInfo(MaskIntType);
256256
257257 // Make sure the mask int is indeed an int
258258 if (mask_info != .Int) @compileError("ArrayBitSet can only operate on integer masks, but was passed " ++ @typeName(MaskIntType));
lib/std/builtin.zig+5-3
......@@ -174,12 +174,14 @@ pub const SourceLocation = struct {
174174 column: u32,
175175};
176176
177pub const TypeId = std.meta.Tag(TypeInfo);
177pub const TypeId = std.meta.Tag(Type);
178
179/// TODO deprecated, use `Type`
180pub const TypeInfo = Type;
178181
179182/// This data structure is used by the Zig language code generation and
180183/// therefore must be kept in sync with the compiler implementation.
181/// TODO: rename to `Type` because "info" is redundant.
182pub const TypeInfo = union(enum) {
184pub const Type = union(enum) {
183185 Type: void,
184186 Void: void,
185187 Bool: void,
lib/std/enums.zig+3-3
......@@ -3,14 +3,14 @@
33const std = @import("std.zig");
44const assert = std.debug.assert;
55const testing = std.testing;
6const EnumField = std.builtin.TypeInfo.EnumField;
6const EnumField = std.builtin.Type.EnumField;
77
88/// Returns a struct with a field matching each unique named enum element.
99/// If the enum is extern and has multiple names for the same value, only
1010/// the first name is used. Each field is of type Data and has the provided
1111/// default, which may be undefined.
1212pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_default: ?Data) type {
13 const StructField = std.builtin.TypeInfo.StructField;
13 const StructField = std.builtin.Type.StructField;
1414 var fields: []const StructField = &[_]StructField{};
1515 for (std.meta.fields(E)) |field| {
1616 fields = fields ++ &[_]StructField{.{
......@@ -24,7 +24,7 @@ pub fn EnumFieldStruct(comptime E: type, comptime Data: type, comptime field_def
2424 return @Type(.{ .Struct = .{
2525 .layout = .Auto,
2626 .fields = fields,
27 .decls = &[_]std.builtin.TypeInfo.Declaration{},
27 .decls = &.{},
2828 .is_tuple = false,
2929 } });
3030}
lib/std/hash/auto_hash.zig+1-1
......@@ -233,7 +233,7 @@ fn testHashDeepRecursive(key: anytype) u64 {
233233
234234test "typeContainsSlice" {
235235 comptime {
236 try testing.expect(!typeContainsSlice(meta.Tag(std.builtin.TypeInfo)));
236 try testing.expect(!typeContainsSlice(meta.Tag(std.builtin.Type)));
237237
238238 try testing.expect(typeContainsSlice([]const u8));
239239 try testing.expect(!typeContainsSlice(u8));
lib/std/io/fixed_buffer_stream.zig+1-1
......@@ -120,7 +120,7 @@ pub fn fixedBufferStream(buffer: anytype) FixedBufferStream(NonSentinelSpan(@Typ
120120fn NonSentinelSpan(comptime T: type) type {
121121 var ptr_info = @typeInfo(mem.Span(T)).Pointer;
122122 ptr_info.sentinel = null;
123 return @Type(std.builtin.TypeInfo{ .Pointer = ptr_info });
123 return @Type(.{ .Pointer = ptr_info });
124124}
125125
126126test "FixedBufferStream output" {
lib/std/io/reader.zig+1-1
......@@ -314,7 +314,7 @@ pub fn Reader(
314314
315315 pub fn readStruct(self: Self, comptime T: type) !T {
316316 // Only extern and packed structs have defined in-memory layout.
317 comptime assert(@typeInfo(T).Struct.layout != std.builtin.TypeInfo.ContainerLayout.Auto);
317 comptime assert(@typeInfo(T).Struct.layout != .Auto);
318318 var res: [1]T = undefined;
319319 try self.readNoEof(mem.sliceAsBytes(res[0..]));
320320 return res[0];
lib/std/io/writer.zig+1-1
......@@ -84,7 +84,7 @@ pub fn Writer(
8484
8585 pub fn writeStruct(self: Self, value: anytype) Error!void {
8686 // Only extern and packed structs have defined in-memory layout.
87 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != std.builtin.TypeInfo.ContainerLayout.Auto);
87 comptime assert(@typeInfo(@TypeOf(value)).Struct.layout != .Auto);
8888 return self.writeAll(mem.asBytes(&value));
8989 }
9090 };
lib/std/json.zig+1-2
......@@ -138,11 +138,10 @@ const AggregateContainerType = enum(u1) { object, array };
138138fn AggregateContainerStack(comptime n: usize) type {
139139 return struct {
140140 const Self = @This();
141 const TypeInfo = std.builtin.TypeInfo;
142141
143142 const element_bitcount = 8 * @sizeOf(usize);
144143 const element_count = n / element_bitcount;
145 const ElementType = @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .unsigned, .bits = element_bitcount } });
144 const ElementType = @Type(.{ .Int = .{ .signedness = .unsigned, .bits = element_bitcount } });
146145 const ElementShiftAmountType = std.math.Log2Int(ElementType);
147146
148147 comptime {
lib/std/mem.zig+3-3
......@@ -608,7 +608,7 @@ pub fn Span(comptime T: type) type {
608608 .Many, .Slice => {},
609609 }
610610 new_ptr_info.size = .Slice;
611 return @Type(std.builtin.TypeInfo{ .Pointer = new_ptr_info });
611 return @Type(.{ .Pointer = new_ptr_info });
612612 },
613613 else => @compileError("invalid type given to std.mem.Span"),
614614 }
......@@ -720,7 +720,7 @@ fn SliceTo(comptime T: type, comptime end: meta.Elem(T)) type {
720720 new_ptr_info.is_allowzero = false;
721721 },
722722 }
723 return @Type(std.builtin.TypeInfo{ .Pointer = new_ptr_info });
723 return @Type(.{ .Pointer = new_ptr_info });
724724 },
725725 else => {},
726726 }
......@@ -2588,7 +2588,7 @@ test "alignPointer" {
25882588
25892589fn CopyPtrAttrs(
25902590 comptime source: type,
2591 comptime size: std.builtin.TypeInfo.Pointer.Size,
2591 comptime size: std.builtin.Type.Pointer.Size,
25922592 comptime child: type,
25932593) type {
25942594 const info = @typeInfo(source).Pointer;
lib/std/meta.zig+34-34
......@@ -8,7 +8,7 @@ const root = @import("root");
88pub const trait = @import("meta/trait.zig");
99pub const TrailerFlags = @import("meta/trailer_flags.zig").TrailerFlags;
1010
11const TypeInfo = std.builtin.TypeInfo;
11const Type = std.builtin.Type;
1212
1313pub fn tagName(v: anytype) []const u8 {
1414 const T = @TypeOf(v);
......@@ -335,7 +335,7 @@ test "std.meta.assumeSentinel" {
335335 try testing.expect(?[*:0]u8 == @TypeOf(assumeSentinel(@as(?[*]u8, undefined), 0)));
336336}
337337
338pub fn containerLayout(comptime T: type) TypeInfo.ContainerLayout {
338pub fn containerLayout(comptime T: type) Type.ContainerLayout {
339339 return switch (@typeInfo(T)) {
340340 .Struct => |info| info.layout,
341341 .Enum => |info| info.layout,
......@@ -370,9 +370,9 @@ test "std.meta.containerLayout" {
370370 try testing.expect(containerLayout(U3) == .Extern);
371371}
372372
373/// Instead of this function, prefer to use e.g. `@TypeInfo(foo).Struct.decls`
373/// Instead of this function, prefer to use e.g. `@typeInfo(foo).Struct.decls`
374374/// directly when you know what kind of type it is.
375pub fn declarations(comptime T: type) []const TypeInfo.Declaration {
375pub fn declarations(comptime T: type) []const Type.Declaration {
376376 return switch (@typeInfo(T)) {
377377 .Struct => |info| info.decls,
378378 .Enum => |info| info.decls,
......@@ -400,7 +400,7 @@ test "std.meta.declarations" {
400400 fn a() void {}
401401 };
402402
403 const decls = comptime [_][]const TypeInfo.Declaration{
403 const decls = comptime [_][]const Type.Declaration{
404404 declarations(E1),
405405 declarations(S1),
406406 declarations(U1),
......@@ -413,7 +413,7 @@ test "std.meta.declarations" {
413413 }
414414}
415415
416pub fn declarationInfo(comptime T: type, comptime decl_name: []const u8) TypeInfo.Declaration {
416pub fn declarationInfo(comptime T: type, comptime decl_name: []const u8) Type.Declaration {
417417 inline for (comptime declarations(T)) |decl| {
418418 if (comptime mem.eql(u8, decl.name, decl_name))
419419 return decl;
......@@ -437,7 +437,7 @@ test "std.meta.declarationInfo" {
437437 fn a() void {}
438438 };
439439
440 const infos = comptime [_]TypeInfo.Declaration{
440 const infos = comptime [_]Type.Declaration{
441441 declarationInfo(E1, "a"),
442442 declarationInfo(S1, "a"),
443443 declarationInfo(U1, "a"),
......@@ -450,10 +450,10 @@ test "std.meta.declarationInfo" {
450450}
451451
452452pub fn fields(comptime T: type) switch (@typeInfo(T)) {
453 .Struct => []const TypeInfo.StructField,
454 .Union => []const TypeInfo.UnionField,
455 .ErrorSet => []const TypeInfo.Error,
456 .Enum => []const TypeInfo.EnumField,
453 .Struct => []const Type.StructField,
454 .Union => []const Type.UnionField,
455 .ErrorSet => []const Type.Error,
456 .Enum => []const Type.EnumField,
457457 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
458458} {
459459 return switch (@typeInfo(T)) {
......@@ -495,10 +495,10 @@ test "std.meta.fields" {
495495}
496496
497497pub fn fieldInfo(comptime T: type, comptime field: FieldEnum(T)) switch (@typeInfo(T)) {
498 .Struct => TypeInfo.StructField,
499 .Union => TypeInfo.UnionField,
500 .ErrorSet => TypeInfo.Error,
501 .Enum => TypeInfo.EnumField,
498 .Struct => Type.StructField,
499 .Union => Type.UnionField,
500 .ErrorSet => Type.Error,
501 .Enum => Type.EnumField,
502502 else => @compileError("Expected struct, union, error set or enum type, found '" ++ @typeName(T) ++ "'"),
503503} {
504504 return fields(T)[@enumToInt(field)];
......@@ -570,8 +570,8 @@ test "std.meta.fieldNames" {
570570
571571pub fn FieldEnum(comptime T: type) type {
572572 const fieldInfos = fields(T);
573 var enumFields: [fieldInfos.len]std.builtin.TypeInfo.EnumField = undefined;
574 var decls = [_]std.builtin.TypeInfo.Declaration{};
573 var enumFields: [fieldInfos.len]std.builtin.Type.EnumField = undefined;
574 var decls = [_]std.builtin.Type.Declaration{};
575575 inline for (fieldInfos) |field, i| {
576576 enumFields[i] = .{
577577 .name = field.name,
......@@ -594,8 +594,8 @@ fn expectEqualEnum(expected: anytype, actual: @TypeOf(expected)) !void {
594594 // testing.expectEqual(@typeInfo(expected).Enum, @typeInfo(actual).Enum);
595595 try testing.expectEqual(@typeInfo(expected).Enum.layout, @typeInfo(actual).Enum.layout);
596596 try testing.expectEqual(@typeInfo(expected).Enum.tag_type, @typeInfo(actual).Enum.tag_type);
597 comptime try testing.expectEqualSlices(std.builtin.TypeInfo.EnumField, @typeInfo(expected).Enum.fields, @typeInfo(actual).Enum.fields);
598 comptime try testing.expectEqualSlices(std.builtin.TypeInfo.Declaration, @typeInfo(expected).Enum.decls, @typeInfo(actual).Enum.decls);
597 comptime try testing.expectEqualSlices(std.builtin.Type.EnumField, @typeInfo(expected).Enum.fields, @typeInfo(actual).Enum.fields);
598 comptime try testing.expectEqualSlices(std.builtin.Type.Declaration, @typeInfo(expected).Enum.decls, @typeInfo(actual).Enum.decls);
599599 try testing.expectEqual(@typeInfo(expected).Enum.is_exhaustive, @typeInfo(actual).Enum.is_exhaustive);
600600}
601601
......@@ -607,8 +607,8 @@ test "std.meta.FieldEnum" {
607607
608608pub fn DeclEnum(comptime T: type) type {
609609 const fieldInfos = std.meta.declarations(T);
610 var enumDecls: [fieldInfos.len]std.builtin.TypeInfo.EnumField = undefined;
611 var decls = [_]std.builtin.TypeInfo.Declaration{};
610 var enumDecls: [fieldInfos.len]std.builtin.Type.EnumField = undefined;
611 var decls = [_]std.builtin.Type.Declaration{};
612612 inline for (fieldInfos) |field, i| {
613613 enumDecls[i] = .{ .name = field.name, .value = i };
614614 }
......@@ -909,7 +909,7 @@ pub fn declList(comptime Namespace: type, comptime Decl: type) []const *const De
909909pub const IntType = @compileError("replaced by std.meta.Int");
910910
911911pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16) type {
912 return @Type(TypeInfo{
912 return @Type(.{
913913 .Int = .{
914914 .signedness = signedness,
915915 .bits = bit_count,
......@@ -918,7 +918,7 @@ pub fn Int(comptime signedness: std.builtin.Signedness, comptime bit_count: u16)
918918}
919919
920920pub fn Float(comptime bit_count: u8) type {
921 return @Type(TypeInfo{
921 return @Type(.{
922922 .Float = .{ .bits = bit_count },
923923 });
924924}
......@@ -931,7 +931,7 @@ test "std.meta.Float" {
931931}
932932
933933pub fn Vector(comptime len: u32, comptime child: type) type {
934 return @Type(TypeInfo{
934 return @Type(.{
935935 .Vector = .{
936936 .len = len,
937937 .child = child,
......@@ -957,12 +957,12 @@ pub fn ArgsTuple(comptime Function: type) type {
957957 if (function_info.is_var_args)
958958 @compileError("Cannot create ArgsTuple for variadic function");
959959
960 var argument_field_list: [function_info.args.len]std.builtin.TypeInfo.StructField = undefined;
960 var argument_field_list: [function_info.args.len]std.builtin.Type.StructField = undefined;
961961 inline for (function_info.args) |arg, i| {
962962 const T = arg.arg_type.?;
963963 @setEvalBranchQuota(10_000);
964964 var num_buf: [128]u8 = undefined;
965 argument_field_list[i] = std.builtin.TypeInfo.StructField{
965 argument_field_list[i] = .{
966966 .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable,
967967 .field_type = T,
968968 .default_value = @as(?T, null),
......@@ -971,11 +971,11 @@ pub fn ArgsTuple(comptime Function: type) type {
971971 };
972972 }
973973
974 return @Type(std.builtin.TypeInfo{
975 .Struct = std.builtin.TypeInfo.Struct{
974 return @Type(.{
975 .Struct = .{
976976 .is_tuple = true,
977977 .layout = .Auto,
978 .decls = &[_]std.builtin.TypeInfo.Declaration{},
978 .decls = &.{},
979979 .fields = &argument_field_list,
980980 },
981981 });
......@@ -989,11 +989,11 @@ pub fn ArgsTuple(comptime Function: type) type {
989989/// - `Tuple(&[_]type {f32})` ⇒ `tuple { f32 }`
990990/// - `Tuple(&[_]type {f32,u32})` ⇒ `tuple { f32, u32 }`
991991pub fn Tuple(comptime types: []const type) type {
992 var tuple_fields: [types.len]std.builtin.TypeInfo.StructField = undefined;
992 var tuple_fields: [types.len]std.builtin.Type.StructField = undefined;
993993 inline for (types) |T, i| {
994994 @setEvalBranchQuota(10_000);
995995 var num_buf: [128]u8 = undefined;
996 tuple_fields[i] = std.builtin.TypeInfo.StructField{
996 tuple_fields[i] = .{
997997 .name = std.fmt.bufPrint(&num_buf, "{d}", .{i}) catch unreachable,
998998 .field_type = T,
999999 .default_value = @as(?T, null),
......@@ -1002,11 +1002,11 @@ pub fn Tuple(comptime types: []const type) type {
10021002 };
10031003 }
10041004
1005 return @Type(std.builtin.TypeInfo{
1006 .Struct = std.builtin.TypeInfo.Struct{
1005 return @Type(.{
1006 .Struct = .{
10071007 .is_tuple = true,
10081008 .layout = .Auto,
1009 .decls = &[_]std.builtin.TypeInfo.Declaration{},
1009 .decls = &.{},
10101010 .fields = &tuple_fields,
10111011 },
10121012 });
lib/std/meta/trailer_flags.zig+4-4
......@@ -3,7 +3,7 @@ const meta = std.meta;
33const testing = std.testing;
44const mem = std.mem;
55const assert = std.debug.assert;
6const TypeInfo = std.builtin.TypeInfo;
6const Type = std.builtin.Type;
77
88/// This is useful for saving memory when allocating an object that has many
99/// optional components. The optional objects are allocated sequentially in
......@@ -19,9 +19,9 @@ pub fn TrailerFlags(comptime Fields: type) type {
1919 pub const FieldEnum = std.meta.FieldEnum(Fields);
2020
2121 pub const InitStruct = blk: {
22 comptime var fields: [bit_count]TypeInfo.StructField = undefined;
22 comptime var fields: [bit_count]Type.StructField = undefined;
2323 inline for (@typeInfo(Fields).Struct.fields) |struct_field, i| {
24 fields[i] = TypeInfo.StructField{
24 fields[i] = Type.StructField{
2525 .name = struct_field.name,
2626 .field_type = ?struct_field.field_type,
2727 .default_value = @as(
......@@ -36,7 +36,7 @@ pub fn TrailerFlags(comptime Fields: type) type {
3636 .Struct = .{
3737 .layout = .Auto,
3838 .fields = &fields,
39 .decls = &[_]TypeInfo.Declaration{},
39 .decls = &.{},
4040 .is_tuple = false,
4141 },
4242 });
lib/std/zig/Ast.zig+2-2
......@@ -1961,7 +1961,7 @@ fn fullPtrType(tree: Ast, info: full.PtrType.Components) full.PtrType {
19611961 const token_tags = tree.tokens.items(.tag);
19621962 // TODO: looks like stage1 isn't quite smart enough to handle enum
19631963 // literals in some places here
1964 const Size = std.builtin.TypeInfo.Pointer.Size;
1964 const Size = std.builtin.Type.Pointer.Size;
19651965 const size: Size = switch (token_tags[info.main_token]) {
19661966 .asterisk,
19671967 .asterisk_asterisk,
......@@ -2392,7 +2392,7 @@ pub const full = struct {
23922392 };
23932393
23942394 pub const PtrType = struct {
2395 size: std.builtin.TypeInfo.Pointer.Size,
2395 size: std.builtin.Type.Pointer.Size,
23962396 allowzero_token: ?TokenIndex,
23972397 const_token: ?TokenIndex,
23982398 volatile_token: ?TokenIndex,
lib/std/zig/c_translation.zig+1-1
......@@ -88,7 +88,7 @@ fn castToPtr(comptime DestType: type, comptime SourceType: type, target: anytype
8888 return @as(DestType, target);
8989}
9090
91fn ptrInfo(comptime PtrType: type) std.builtin.TypeInfo.Pointer {
91fn ptrInfo(comptime PtrType: type) std.builtin.Type.Pointer {
9292 return switch (@typeInfo(PtrType)) {
9393 .Optional => |opt_info| @typeInfo(opt_info.child).Pointer,
9494 .Pointer => |ptr_info| ptr_info,
src/AstGen.zig+10-10
......@@ -3940,7 +3940,7 @@ fn structDeclInner(
39403940 scope: *Scope,
39413941 node: Ast.Node.Index,
39423942 container_decl: Ast.full.ContainerDecl,
3943 layout: std.builtin.TypeInfo.ContainerLayout,
3943 layout: std.builtin.Type.ContainerLayout,
39443944) InnerError!Zir.Inst.Ref {
39453945 const decl_inst = try gz.reserveInstructionIndex();
39463946
......@@ -4076,7 +4076,7 @@ fn unionDeclInner(
40764076 scope: *Scope,
40774077 node: Ast.Node.Index,
40784078 members: []const Ast.Node.Index,
4079 layout: std.builtin.TypeInfo.ContainerLayout,
4079 layout: std.builtin.Type.ContainerLayout,
40804080 arg_node: Ast.Node.Index,
40814081 have_auto_enum: bool,
40824082) InnerError!Zir.Inst.Ref {
......@@ -4242,10 +4242,10 @@ fn containerDecl(
42424242 switch (token_tags[container_decl.ast.main_token]) {
42434243 .keyword_struct => {
42444244 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
4245 .keyword_packed => std.builtin.TypeInfo.ContainerLayout.Packed,
4246 .keyword_extern => std.builtin.TypeInfo.ContainerLayout.Extern,
4245 .keyword_packed => std.builtin.Type.ContainerLayout.Packed,
4246 .keyword_extern => std.builtin.Type.ContainerLayout.Extern,
42474247 else => unreachable,
4248 } else std.builtin.TypeInfo.ContainerLayout.Auto;
4248 } else std.builtin.Type.ContainerLayout.Auto;
42494249
42504250 assert(container_decl.ast.arg == 0);
42514251
......@@ -4254,10 +4254,10 @@ fn containerDecl(
42544254 },
42554255 .keyword_union => {
42564256 const layout = if (container_decl.layout_token) |t| switch (token_tags[t]) {
4257 .keyword_packed => std.builtin.TypeInfo.ContainerLayout.Packed,
4258 .keyword_extern => std.builtin.TypeInfo.ContainerLayout.Extern,
4257 .keyword_packed => std.builtin.Type.ContainerLayout.Packed,
4258 .keyword_extern => std.builtin.Type.ContainerLayout.Extern,
42594259 else => unreachable,
4260 } else std.builtin.TypeInfo.ContainerLayout.Auto;
4260 } else std.builtin.Type.ContainerLayout.Auto;
42614261
42624262 const have_auto_enum = container_decl.ast.enum_token != null;
42634263
......@@ -10495,7 +10495,7 @@ const GenZir = struct {
1049510495 body_len: u32,
1049610496 fields_len: u32,
1049710497 decls_len: u32,
10498 layout: std.builtin.TypeInfo.ContainerLayout,
10498 layout: std.builtin.Type.ContainerLayout,
1049910499 known_non_opv: bool,
1050010500 known_comptime_only: bool,
1050110501 }) !void {
......@@ -10543,7 +10543,7 @@ const GenZir = struct {
1054310543 body_len: u32,
1054410544 fields_len: u32,
1054510545 decls_len: u32,
10546 layout: std.builtin.TypeInfo.ContainerLayout,
10546 layout: std.builtin.Type.ContainerLayout,
1054710547 auto_enum_tag: bool,
1054810548 }) !void {
1054910549 const astgen = gz.astgen;
src/InternArena.zig+1-1
......@@ -30,7 +30,7 @@ pub const Key = union(enum) {
3030 elem_type: Index,
3131 sentinel: Index,
3232 alignment: u16,
33 size: std.builtin.TypeInfo.Pointer.Size,
33 size: std.builtin.Type.Pointer.Size,
3434 is_const: bool,
3535 is_volatile: bool,
3636 is_allowzero: bool,
src/Module.zig+2-2
......@@ -853,7 +853,7 @@ pub const Struct = struct {
853853 /// Index of the struct_decl ZIR instruction.
854854 zir_index: Zir.Inst.Index,
855855
856 layout: std.builtin.TypeInfo.ContainerLayout,
856 layout: std.builtin.Type.ContainerLayout,
857857 status: enum {
858858 none,
859859 field_types_wip,
......@@ -1105,7 +1105,7 @@ pub const Union = struct {
11051105 /// Index of the union_decl ZIR instruction.
11061106 zir_index: Zir.Inst.Index,
11071107
1108 layout: std.builtin.TypeInfo.ContainerLayout,
1108 layout: std.builtin.Type.ContainerLayout,
11091109 status: enum {
11101110 none,
11111111 field_types_wip,
src/Sema.zig+6-6
......@@ -10068,7 +10068,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1006810068 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1006910069 const src = inst_data.src();
1007010070 const ty = try sema.resolveType(block, src, inst_data.operand);
10071 const type_info_ty = try sema.getBuiltinType(block, src, "TypeInfo");
10071 const type_info_ty = try sema.getBuiltinType(block, src, "Type");
1007210072 const target = sema.mod.getTarget();
1007310073
1007410074 switch (ty.zigTypeTag()) {
......@@ -10413,7 +10413,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1041310413 break :v try Value.Tag.opt_payload.create(sema.arena, slice_val);
1041410414 } else Value.@"null";
1041510415
10416 // Construct TypeInfo{ .ErrorSet = errors_val }
10416 // Construct Type{ .ErrorSet = errors_val }
1041710417 return sema.addConstant(
1041810418 type_info_ty,
1041910419 try Value.Tag.@"union".create(sema.arena, .{
......@@ -10516,7 +10516,7 @@ fn zirTypeInfo(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Ai
1051610516 // layout: ContainerLayout,
1051710517 try Value.Tag.enum_field_index.create(
1051810518 sema.arena,
10519 @enumToInt(std.builtin.TypeInfo.ContainerLayout.Auto),
10519 @enumToInt(std.builtin.Type.ContainerLayout.Auto),
1052010520 ),
1052110521
1052210522 // tag_type: type,
......@@ -12186,7 +12186,7 @@ fn zirTagName(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air
1218612186fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.Inst.Ref {
1218712187 const inst_data = sema.code.instructions.items(.data)[inst].un_node;
1218812188 const src = inst_data.src();
12189 const type_info_ty = try sema.resolveBuiltinTypeFields(block, src, "TypeInfo");
12189 const type_info_ty = try sema.resolveBuiltinTypeFields(block, src, "Type");
1219012190 const uncasted_operand = sema.resolveInst(inst_data.operand);
1219112191 const operand_src: LazySrcLoc = .{ .node_offset_builtin_call_arg0 = inst_data.src_node };
1219212192 const type_info = try sema.coerce(block, type_info_ty, uncasted_operand, operand_src);
......@@ -12265,7 +12265,7 @@ fn zirReify(sema: *Sema, block: *Block, inst: Zir.Inst.Index) CompileError!Air.I
1226512265 var buffer: Value.ToTypeBuffer = undefined;
1226612266 const child_ty = child_val.toType(&buffer);
1226712267
12268 const ptr_size = size_val.toEnum(std.builtin.TypeInfo.Pointer.Size);
12268 const ptr_size = size_val.toEnum(std.builtin.Type.Pointer.Size);
1226912269
1227012270 var actual_sentinel: ?Value = null;
1227112271 if (!sentinel_val.isNull()) {
......@@ -18850,7 +18850,7 @@ fn resolveTypeFields(sema: *Sema, block: *Block, src: LazySrcLoc, ty: Type) Comp
1885018850 try sema.resolveTypeFieldsUnion(block, src, ty, union_obj);
1885118851 return ty;
1885218852 },
18853 .type_info => return sema.resolveBuiltinTypeFields(block, src, "TypeInfo"),
18853 .type_info => return sema.resolveBuiltinTypeFields(block, src, "Type"),
1885418854 .extern_options => return sema.resolveBuiltinTypeFields(block, src, "ExternOptions"),
1885518855 .export_options => return sema.resolveBuiltinTypeFields(block, src, "ExportOptions"),
1885618856 .atomic_order => return sema.resolveBuiltinTypeFields(block, src, "AtomicOrder"),
src/Zir.zig+4-4
......@@ -2157,7 +2157,7 @@ pub const Inst = struct {
21572157 is_allowzero: bool,
21582158 is_mutable: bool,
21592159 is_volatile: bool,
2160 size: std.builtin.TypeInfo.Pointer.Size,
2160 size: std.builtin.Type.Pointer.Size,
21612161 elem_type: Ref,
21622162 },
21632163 ptr_type: struct {
......@@ -2171,7 +2171,7 @@ pub const Inst = struct {
21712171 has_bit_range: bool,
21722172 _: u1 = undefined,
21732173 },
2174 size: std.builtin.TypeInfo.Pointer.Size,
2174 size: std.builtin.Type.Pointer.Size,
21752175 /// Index into extra. See `PtrType`.
21762176 payload_index: u32,
21772177 },
......@@ -2659,7 +2659,7 @@ pub const Inst = struct {
26592659 known_non_opv: bool,
26602660 known_comptime_only: bool,
26612661 name_strategy: NameStrategy,
2662 layout: std.builtin.TypeInfo.ContainerLayout,
2662 layout: std.builtin.Type.ContainerLayout,
26632663 _: u6 = undefined,
26642664 };
26652665 };
......@@ -2778,7 +2778,7 @@ pub const Inst = struct {
27782778 has_fields_len: bool,
27792779 has_decls_len: bool,
27802780 name_strategy: NameStrategy,
2781 layout: std.builtin.TypeInfo.ContainerLayout,
2781 layout: std.builtin.Type.ContainerLayout,
27822782 /// has_tag_type | auto_enum_tag | result
27832783 /// -------------------------------------
27842784 /// false | false | union { }
src/stage1/ir.cpp+19-19
......@@ -17971,7 +17971,7 @@ static void ensure_field_index(ZigType *type, const char *field_name, size_t ind
1797117971
1797217972static ZigType *ir_type_info_get_type(IrAnalyze *ira, const char *type_name, ZigType *root) {
1797317973 Error err;
17974 ZigType *type_info_type = get_builtin_type(ira->codegen, "TypeInfo");
17974 ZigType *type_info_type = get_builtin_type(ira->codegen, "Type");
1797517975 assert(type_info_type->id == ZigTypeIdUnion);
1797617976 if ((err = type_resolve(ira->codegen, type_info_type, ResolveStatusSizeKnown))) {
1797717977 zig_unreachable();
......@@ -18403,7 +18403,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1840318403 fields[1]->special = ConstValSpecialStatic;
1840418404 fields[1]->type = g->builtin_types.entry_type;
1840518405 fields[1]->data.x_type = type_entry->data.enumeration.tag_int_type;
18406 // fields: []TypeInfo.EnumField
18406 // fields: []Type.EnumField
1840718407 ensure_field_index(result->type, "fields", 2);
1840818408
1840918409 ZigType *type_info_enum_field_type = ir_type_info_get_type(ira, "EnumField", nullptr);
......@@ -18429,7 +18429,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1842918429 enum_field_val->parent.data.p_array.array_val = enum_field_array;
1843018430 enum_field_val->parent.data.p_array.elem_index = enum_field_index;
1843118431 }
18432 // decls: []TypeInfo.Declaration
18432 // decls: []Type.Declaration
1843318433 ensure_field_index(result->type, "decls", 3);
1843418434 if ((err = ir_make_type_info_decls(ira, source_node, fields[3],
1843518435 type_entry->data.enumeration.decls_scope, false)))
......@@ -18553,7 +18553,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1855318553 } else {
1855418554 fields[1]->data.x_optional = nullptr;
1855518555 }
18556 // fields: []TypeInfo.UnionField
18556 // fields: []Type.UnionField
1855718557 ensure_field_index(result->type, "fields", 2);
1855818558
1855918559 ZigType *type_info_union_field_type = ir_type_info_get_type(ira, "UnionField", nullptr);
......@@ -18595,7 +18595,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1859518595 union_field_val->parent.data.p_array.array_val = union_field_array;
1859618596 union_field_val->parent.data.p_array.elem_index = union_field_index;
1859718597 }
18598 // decls: []TypeInfo.Declaration
18598 // decls: []Type.Declaration
1859918599 ensure_field_index(result->type, "decls", 3);
1860018600 if ((err = ir_make_type_info_decls(ira, source_node, fields[3],
1860118601 type_entry->data.unionation.decls_scope, false)))
......@@ -18629,7 +18629,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1862918629 fields[0]->special = ConstValSpecialStatic;
1863018630 fields[0]->type = ir_type_info_get_type(ira, "ContainerLayout", nullptr);
1863118631 bigint_init_unsigned(&fields[0]->data.x_enum_tag, type_entry->data.structure.layout);
18632 // fields: []TypeInfo.StructField
18632 // fields: []Type.StructField
1863318633 ensure_field_index(result->type, "fields", 1);
1863418634
1863518635 ZigType *type_info_struct_field_type = ir_type_info_get_type(ira, "StructField", nullptr);
......@@ -18690,7 +18690,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1869018690 struct_field_val->parent.data.p_array.array_val = struct_field_array;
1869118691 struct_field_val->parent.data.p_array.elem_index = struct_field_index;
1869218692 }
18693 // decls: []TypeInfo.Declaration
18693 // decls: []Type.Declaration
1869418694 ensure_field_index(result->type, "decls", 2);
1869518695 if ((err = ir_make_type_info_decls(ira, source_node, fields[2],
1869618696 type_entry->data.structure.decls_scope, false)))
......@@ -18715,7 +18715,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1871518715 ZigValue **fields = alloc_const_vals_ptrs(g, 7);
1871618716 result->data.x_struct.fields = fields;
1871718717
18718 // calling_convention: TypeInfo.CallingConvention
18718 // calling_convention: Type.CallingConvention
1871918719 ensure_field_index(result->type, "calling_convention", 0);
1872018720 fields[0]->special = ConstValSpecialStatic;
1872118721 fields[0]->type = get_builtin_type(g, "CallingConvention");
......@@ -18750,7 +18750,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1875018750 return_type->data.x_type = type_entry->data.fn.fn_type_id.return_type;
1875118751 fields[4]->data.x_optional = return_type;
1875218752 }
18753 // args: []TypeInfo.Fn.Param
18753 // args: []Type.Fn.Param
1875418754 ZigType *type_info_fn_arg_type = ir_type_info_get_type(ira, "Param", result->type);
1875518755 if ((err = type_resolve(g, type_info_fn_arg_type, ResolveStatusSizeKnown))) {
1875618756 zig_unreachable();
......@@ -18821,7 +18821,7 @@ static Error ir_make_type_info_value(IrAnalyze *ira, Scope *scope, AstNode *sour
1882118821 ZigValue **fields = alloc_const_vals_ptrs(g, 1);
1882218822 result->data.x_struct.fields = fields;
1882318823
18824 // decls: []TypeInfo.Declaration
18824 // decls: []Type.Declaration
1882518825 ensure_field_index(result->type, "decls", 0);
1882618826 if ((err = ir_make_type_info_decls(ira, source_node, fields[0],
1882718827 type_entry->data.opaque.decls_scope, false)))
......@@ -19194,7 +19194,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1919419194 ZigValue *decls_len_value = decls_value->data.x_struct.fields[slice_len_index];
1919519195 size_t decls_len = bigint_as_usize(&decls_len_value->data.x_bigint);
1919619196 if (decls_len != 0) {
19197 ir_add_error_node(ira, source_node, buf_create_from_str("TypeInfo.Struct.decls must be empty for @Type"));
19197 ir_add_error_node(ira, source_node, buf_create_from_str("Type.Struct.decls must be empty for @Type"));
1919819198 return ira->codegen->invalid_inst_gen->value->type;
1919919199 }
1920019200
......@@ -19311,7 +19311,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1931119311 ZigValue *decls_len_value = decls_value->data.x_struct.fields[slice_len_index];
1931219312 size_t decls_len = bigint_as_usize(&decls_len_value->data.x_bigint);
1931319313 if (decls_len != 0) {
19314 ir_add_error_node(ira, source_node, buf_create_from_str("TypeInfo.Struct.decls must be empty for @Type"));
19314 ir_add_error_node(ira, source_node, buf_create_from_str("Type.Struct.decls must be empty for @Type"));
1931519315 return ira->codegen->invalid_inst_gen->value->type;
1931619316 }
1931719317
......@@ -19395,7 +19395,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1939519395 return ira->codegen->invalid_inst_gen->value->type;
1939619396 if (tag_type->id != ZigTypeIdInt) {
1939719397 ir_add_error_node(ira, source_node, buf_sprintf(
19398 "TypeInfo.Enum.tag_type must be an integer type, not '%s'", buf_ptr(&tag_type->name)));
19398 "Type.Enum.tag_type must be an integer type, not '%s'", buf_ptr(&tag_type->name)));
1939919399 return ira->codegen->invalid_inst_gen->value->type;
1940019400 }
1940119401
......@@ -19418,7 +19418,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1941819418 ZigValue *decls_len_value = decls_value->data.x_struct.fields[slice_len_index];
1941919419 size_t decls_len = bigint_as_usize(&decls_len_value->data.x_bigint);
1942019420 if (decls_len != 0) {
19421 ir_add_error_node(ira, source_node, buf_create_from_str("TypeInfo.Enum.decls must be empty for @Type"));
19421 ir_add_error_node(ira, source_node, buf_create_from_str("Type.Enum.decls must be empty for @Type"));
1942219422 return ira->codegen->invalid_inst_gen->value->type;
1942319423 }
1942419424
......@@ -19505,7 +19505,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1950519505 ZigValue *decls_len_value = decls_value->data.x_struct.fields[slice_len_index];
1950619506 size_t decls_len = bigint_as_usize(&decls_len_value->data.x_bigint);
1950719507 if (decls_len != 0) {
19508 ir_add_error_node(ira, source_node, buf_create_from_str("TypeInfo.Union.decls must be empty for @Type"));
19508 ir_add_error_node(ira, source_node, buf_create_from_str("Type.Union.decls must be empty for @Type"));
1950919509 return ira->codegen->invalid_inst_gen->value->type;
1951019510 }
1951119511
......@@ -19571,7 +19571,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1957119571 if ((err = get_const_field_bool(ira, source_node, payload, "is_generic", 2, &is_generic)))
1957219572 return ira->codegen->invalid_inst_gen->value->type;
1957319573 if (is_generic) {
19574 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.is_generic must be false for @Type"));
19574 ir_add_error_node(ira, source_node, buf_sprintf("Type.Fn.is_generic must be false for @Type"));
1957519575 return ira->codegen->invalid_inst_gen->value->type;
1957619576 }
1957719577
......@@ -19585,7 +19585,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1958519585
1958619586 ZigType *return_type = get_const_field_meta_type_optional(ira, source_node, payload, "return_type", 4);
1958719587 if (return_type == nullptr) {
19588 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.return_type must be non-null for @Type"));
19588 ir_add_error_node(ira, source_node, buf_sprintf("Type.Fn.return_type must be non-null for @Type"));
1958919589 return ira->codegen->invalid_inst_gen->value->type;
1959019590 }
1959119591
......@@ -19620,7 +19620,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1962019620 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_generic", 0, &is_generic)))
1962119621 return ira->codegen->invalid_inst_gen->value->type;
1962219622 if (is_generic) {
19623 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.is_generic must be false for @Type"));
19623 ir_add_error_node(ira, source_node, buf_sprintf("Type.Fn.Param.is_generic must be false for @Type"));
1962419624 return ira->codegen->invalid_inst_gen->value->type;
1962519625 }
1962619626 if ((err = get_const_field_bool(ira, source_node, arg_value, "is_noalias", 1, &info->is_noalias)))
......@@ -19628,7 +19628,7 @@ static ZigType *type_info_to_type(IrAnalyze *ira, Scope *scope, AstNode *source_
1962819628 ZigType *type = get_const_field_meta_type_optional(
1962919629 ira, source_node, arg_value, "arg_type", 2);
1963019630 if (type == nullptr) {
19631 ir_add_error_node(ira, source_node, buf_sprintf("TypeInfo.Fn.Param.arg_type must be non-null for @Type"));
19631 ir_add_error_node(ira, source_node, buf_sprintf("Type.Fn.Param.arg_type must be non-null for @Type"));
1963219632 return ira->codegen->invalid_inst_gen->value->type;
1963319633 }
1963419634 info->type = type;
src/type.zig+5-5
......@@ -1527,7 +1527,7 @@ pub const Type = extern union {
15271527 .prefetch_options => return writer.writeAll("std.builtin.PrefetchOptions"),
15281528 .export_options => return writer.writeAll("std.builtin.ExportOptions"),
15291529 .extern_options => return writer.writeAll("std.builtin.ExternOptions"),
1530 .type_info => return writer.writeAll("std.builtin.TypeInfo"),
1530 .type_info => return writer.writeAll("std.builtin.Type"),
15311531 .function => {
15321532 const payload = ty.castTag(.function).?.data;
15331533 try writer.writeAll("fn(");
......@@ -1866,7 +1866,7 @@ pub const Type = extern union {
18661866 .prefetch_options => return "PrefetchOptions",
18671867 .export_options => return "ExportOptions",
18681868 .extern_options => return "ExternOptions",
1869 .type_info => return "TypeInfo",
1869 .type_info => return "Type",
18701870
18711871 else => {
18721872 // TODO this is wasteful and also an incorrect implementation of `@typeName`
......@@ -2856,7 +2856,7 @@ pub const Type = extern union {
28562856 }
28572857
28582858 /// Asserts the `Type` is a pointer.
2859 pub fn ptrSize(self: Type) std.builtin.TypeInfo.Pointer.Size {
2859 pub fn ptrSize(self: Type) std.builtin.Type.Pointer.Size {
28602860 return switch (self.tag()) {
28612861 .const_slice,
28622862 .mut_slice,
......@@ -3392,7 +3392,7 @@ pub const Type = extern union {
33923392 }
33933393 }
33943394
3395 pub fn containerLayout(ty: Type) std.builtin.TypeInfo.ContainerLayout {
3395 pub fn containerLayout(ty: Type) std.builtin.Type.ContainerLayout {
33963396 return switch (ty.tag()) {
33973397 .tuple, .empty_struct_literal, .anon_struct => .Auto,
33983398 .@"struct" => ty.castTag(.@"struct").?.data.layout,
......@@ -5165,7 +5165,7 @@ pub const Type = extern union {
51655165 @"allowzero": bool = false,
51665166 mutable: bool = true, // TODO rename this to const, not mutable
51675167 @"volatile": bool = false,
5168 size: std.builtin.TypeInfo.Pointer.Size = .One,
5168 size: std.builtin.Type.Pointer.Size = .One,
51695169 };
51705170 };
51715171
src/value.zig+1-1
......@@ -673,7 +673,7 @@ pub const Value = extern union {
673673 .prefetch_options_type => return out_stream.writeAll("std.builtin.PrefetchOptions"),
674674 .export_options_type => return out_stream.writeAll("std.builtin.ExportOptions"),
675675 .extern_options_type => return out_stream.writeAll("std.builtin.ExternOptions"),
676 .type_info_type => return out_stream.writeAll("std.builtin.TypeInfo"),
676 .type_info_type => return out_stream.writeAll("std.builtin.Type"),
677677 .abi_align_default => return out_stream.writeAll("(default ABI alignment)"),
678678
679679 .empty_struct_value => return out_stream.writeAll("struct {}{}"),
test/behavior/bugs/1421.zig+1-1
......@@ -2,7 +2,7 @@ const std = @import("std");
22const expect = std.testing.expect;
33
44const S = struct {
5 fn method() std.builtin.TypeInfo {
5 fn method() std.builtin.Type {
66 return @typeInfo(S);
77 }
88};
test/behavior/bugs/6456.zig+2-2
......@@ -1,7 +1,7 @@
11const std = @import("std");
22const testing = std.testing;
3const StructField = std.builtin.TypeInfo.StructField;
4const Declaration = std.builtin.TypeInfo.Declaration;
3const StructField = std.builtin.Type.StructField;
4const Declaration = std.builtin.Type.Declaration;
55
66const text =
77 \\f1
test/behavior/tuple.zig+6-6
......@@ -125,23 +125,23 @@ test "tuple initializer for var" {
125125test "array-like initializer for tuple types" {
126126 if (builtin.zig_backend != .stage1) return error.SkipZigTest; // TODO
127127
128 const T = @Type(std.builtin.TypeInfo{
129 .Struct = std.builtin.TypeInfo.Struct{
128 const T = @Type(.{
129 .Struct = .{
130130 .is_tuple = true,
131131 .layout = .Auto,
132 .decls = &[_]std.builtin.TypeInfo.Declaration{},
133 .fields = &[_]std.builtin.TypeInfo.StructField{
132 .decls = &.{},
133 .fields = &.{
134134 .{
135135 .name = "0",
136136 .field_type = i32,
137 .default_value = @as(?i32, null),
137 .default_value = null,
138138 .is_comptime = false,
139139 .alignment = @alignOf(i32),
140140 },
141141 .{
142142 .name = "1",
143143 .field_type = u8,
144 .default_value = @as(?i32, null),
144 .default_value = null,
145145 .is_comptime = false,
146146 .alignment = @alignOf(i32),
147147 },
test/behavior/type.zig+52-52
......@@ -1,6 +1,6 @@
11const std = @import("std");
22const builtin = @import("builtin");
3const TypeInfo = std.builtin.TypeInfo;
3const Type = std.builtin.Type;
44const testing = std.testing;
55
66fn testTypes(comptime types: []const type) !void {
......@@ -10,32 +10,32 @@ fn testTypes(comptime types: []const type) !void {
1010}
1111
1212test "Type.MetaType" {
13 try testing.expect(type == @Type(TypeInfo{ .Type = undefined }));
13 try testing.expect(type == @Type(.{ .Type = {} }));
1414 try testTypes(&[_]type{type});
1515}
1616
1717test "Type.Void" {
18 try testing.expect(void == @Type(TypeInfo{ .Void = undefined }));
18 try testing.expect(void == @Type(.{ .Void = {} }));
1919 try testTypes(&[_]type{void});
2020}
2121
2222test "Type.Bool" {
23 try testing.expect(bool == @Type(TypeInfo{ .Bool = undefined }));
23 try testing.expect(bool == @Type(.{ .Bool = {} }));
2424 try testTypes(&[_]type{bool});
2525}
2626
2727test "Type.NoReturn" {
28 try testing.expect(noreturn == @Type(TypeInfo{ .NoReturn = undefined }));
28 try testing.expect(noreturn == @Type(.{ .NoReturn = {} }));
2929 try testTypes(&[_]type{noreturn});
3030}
3131
3232test "Type.Int" {
33 try testing.expect(u1 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .unsigned, .bits = 1 } }));
34 try testing.expect(i1 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .signed, .bits = 1 } }));
35 try testing.expect(u8 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .unsigned, .bits = 8 } }));
36 try testing.expect(i8 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .signed, .bits = 8 } }));
37 try testing.expect(u64 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .unsigned, .bits = 64 } }));
38 try testing.expect(i64 == @Type(TypeInfo{ .Int = TypeInfo.Int{ .signedness = .signed, .bits = 64 } }));
33 try testing.expect(u1 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 1 } }));
34 try testing.expect(i1 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 1 } }));
35 try testing.expect(u8 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 8 } }));
36 try testing.expect(i8 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 8 } }));
37 try testing.expect(u64 == @Type(.{ .Int = .{ .signedness = .unsigned, .bits = 64 } }));
38 try testing.expect(i64 == @Type(.{ .Int = .{ .signedness = .signed, .bits = 64 } }));
3939 try testTypes(&[_]type{ u8, u32, i64 });
4040}
4141
......@@ -104,31 +104,31 @@ test "Type.Pointer" {
104104}
105105
106106test "Type.Float" {
107 try testing.expect(f16 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 16 } }));
108 try testing.expect(f32 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 32 } }));
109 try testing.expect(f64 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 64 } }));
110 try testing.expect(f80 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 80 } }));
111 try testing.expect(f128 == @Type(TypeInfo{ .Float = TypeInfo.Float{ .bits = 128 } }));
107 try testing.expect(f16 == @Type(.{ .Float = .{ .bits = 16 } }));
108 try testing.expect(f32 == @Type(.{ .Float = .{ .bits = 32 } }));
109 try testing.expect(f64 == @Type(.{ .Float = .{ .bits = 64 } }));
110 try testing.expect(f80 == @Type(.{ .Float = .{ .bits = 80 } }));
111 try testing.expect(f128 == @Type(.{ .Float = .{ .bits = 128 } }));
112112 try testTypes(&[_]type{ f16, f32, f64, f80, f128 });
113113}
114114
115115test "Type.Array" {
116 try testing.expect([123]u8 == @Type(TypeInfo{
117 .Array = TypeInfo.Array{
116 try testing.expect([123]u8 == @Type(.{
117 .Array = .{
118118 .len = 123,
119119 .child = u8,
120120 .sentinel = null,
121121 },
122122 }));
123 try testing.expect([2]u32 == @Type(TypeInfo{
124 .Array = TypeInfo.Array{
123 try testing.expect([2]u32 == @Type(.{
124 .Array = .{
125125 .len = 2,
126126 .child = u32,
127127 .sentinel = null,
128128 },
129129 }));
130 try testing.expect([2:0]u32 == @Type(TypeInfo{
131 .Array = TypeInfo.Array{
130 try testing.expect([2:0]u32 == @Type(.{
131 .Array = .{
132132 .len = 2,
133133 .child = u32,
134134 .sentinel = &@as(u32, 0),
......@@ -138,7 +138,7 @@ test "Type.Array" {
138138}
139139
140140test "@Type create slice with null sentinel" {
141 const Slice = @Type(TypeInfo{
141 const Slice = @Type(.{
142142 .Pointer = .{
143143 .size = .Slice,
144144 .is_const = true,
......@@ -153,7 +153,7 @@ test "@Type create slice with null sentinel" {
153153 try testing.expect(Slice == []align(8) const *i32);
154154}
155155
156test "@Type picks up the sentinel value from TypeInfo" {
156test "@Type picks up the sentinel value from Type" {
157157 try testTypes(&[_]type{
158158 [11:0]u8, [4:10]u8,
159159 [*:0]u8, [*:0]const u8,
......@@ -203,13 +203,13 @@ test "Type.Opaque" {
203203
204204 const Opaque = @Type(.{
205205 .Opaque = .{
206 .decls = &[_]TypeInfo.Declaration{},
206 .decls = &.{},
207207 },
208208 });
209209 try testing.expect(Opaque != opaque {});
210210 try testing.expectEqualSlices(
211 TypeInfo.Declaration,
212 &[_]TypeInfo.Declaration{},
211 Type.Declaration,
212 &.{},
213213 @typeInfo(Opaque).Opaque.decls,
214214 );
215215}
......@@ -240,14 +240,14 @@ fn add(a: i32, b: i32) i32 {
240240}
241241
242242test "Type.ErrorSet" {
243 try testing.expect(@Type(TypeInfo{ .ErrorSet = null }) == anyerror);
243 try testing.expect(@Type(.{ .ErrorSet = null }) == anyerror);
244244
245245 // error sets don't compare equal so just check if they compile
246246 _ = @Type(@typeInfo(error{}));
247247 _ = @Type(@typeInfo(error{A}));
248248 _ = @Type(@typeInfo(error{ A, B, C }));
249 _ = @Type(TypeInfo{
250 .ErrorSet = &[_]TypeInfo.Error{
249 _ = @Type(.{
250 .ErrorSet = &[_]Type.Error{
251251 .{ .name = "A" },
252252 .{ .name = "B" },
253253 .{ .name = "C" },
......@@ -260,14 +260,14 @@ test "Type.Struct" {
260260
261261 const A = @Type(@typeInfo(struct { x: u8, y: u32 }));
262262 const infoA = @typeInfo(A).Struct;
263 try testing.expectEqual(TypeInfo.ContainerLayout.Auto, infoA.layout);
263 try testing.expectEqual(Type.ContainerLayout.Auto, infoA.layout);
264264 try testing.expectEqualSlices(u8, "x", infoA.fields[0].name);
265265 try testing.expectEqual(u8, infoA.fields[0].field_type);
266266 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[0].default_value);
267267 try testing.expectEqualSlices(u8, "y", infoA.fields[1].name);
268268 try testing.expectEqual(u32, infoA.fields[1].field_type);
269269 try testing.expectEqual(@as(?*const anyopaque, null), infoA.fields[1].default_value);
270 try testing.expectEqualSlices(TypeInfo.Declaration, &[_]TypeInfo.Declaration{}, infoA.decls);
270 try testing.expectEqualSlices(Type.Declaration, &.{}, infoA.decls);
271271 try testing.expectEqual(@as(bool, false), infoA.is_tuple);
272272
273273 var a = A{ .x = 0, .y = 1 };
......@@ -278,7 +278,7 @@ test "Type.Struct" {
278278
279279 const B = @Type(@typeInfo(extern struct { x: u8, y: u32 = 5 }));
280280 const infoB = @typeInfo(B).Struct;
281 try testing.expectEqual(TypeInfo.ContainerLayout.Extern, infoB.layout);
281 try testing.expectEqual(Type.ContainerLayout.Extern, infoB.layout);
282282 try testing.expectEqualSlices(u8, "x", infoB.fields[0].name);
283283 try testing.expectEqual(u8, infoB.fields[0].field_type);
284284 try testing.expectEqual(@as(?*const anyopaque, null), infoB.fields[0].default_value);
......@@ -290,7 +290,7 @@ test "Type.Struct" {
290290
291291 const C = @Type(@typeInfo(packed struct { x: u8 = 3, y: u32 = 5 }));
292292 const infoC = @typeInfo(C).Struct;
293 try testing.expectEqual(TypeInfo.ContainerLayout.Packed, infoC.layout);
293 try testing.expectEqual(Type.ContainerLayout.Packed, infoC.layout);
294294 try testing.expectEqualSlices(u8, "x", infoC.fields[0].name);
295295 try testing.expectEqual(u8, infoC.fields[0].field_type);
296296 try testing.expectEqual(@as(u8, 3), @ptrCast(*const u8, infoC.fields[0].default_value.?).*);
......@@ -308,11 +308,11 @@ test "Type.Enum" {
308308 .Enum = .{
309309 .layout = .Auto,
310310 .tag_type = u8,
311 .fields = &[_]TypeInfo.EnumField{
311 .fields = &.{
312312 .{ .name = "a", .value = 1 },
313313 .{ .name = "b", .value = 5 },
314314 },
315 .decls = &[_]TypeInfo.Declaration{},
315 .decls = &.{},
316316 .is_exhaustive = true,
317317 },
318318 });
......@@ -323,11 +323,11 @@ test "Type.Enum" {
323323 .Enum = .{
324324 .layout = .Extern,
325325 .tag_type = u32,
326 .fields = &[_]TypeInfo.EnumField{
326 .fields = &.{
327327 .{ .name = "a", .value = 1 },
328328 .{ .name = "b", .value = 5 },
329329 },
330 .decls = &[_]TypeInfo.Declaration{},
330 .decls = &.{},
331331 .is_exhaustive = false,
332332 },
333333 });
......@@ -344,11 +344,11 @@ test "Type.Union" {
344344 .Union = .{
345345 .layout = .Auto,
346346 .tag_type = null,
347 .fields = &[_]TypeInfo.UnionField{
347 .fields = &.{
348348 .{ .name = "int", .field_type = i32, .alignment = @alignOf(f32) },
349349 .{ .name = "float", .field_type = f32, .alignment = @alignOf(f32) },
350350 },
351 .decls = &[_]TypeInfo.Declaration{},
351 .decls = &.{},
352352 },
353353 });
354354 var untagged = Untagged{ .int = 1 };
......@@ -360,11 +360,11 @@ test "Type.Union" {
360360 .Union = .{
361361 .layout = .Packed,
362362 .tag_type = null,
363 .fields = &[_]TypeInfo.UnionField{
363 .fields = &.{
364364 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },
365365 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },
366366 },
367 .decls = &[_]TypeInfo.Declaration{},
367 .decls = &.{},
368368 },
369369 });
370370 var packed_untagged = PackedUntagged{ .signed = -1 };
......@@ -375,11 +375,11 @@ test "Type.Union" {
375375 .Enum = .{
376376 .layout = .Auto,
377377 .tag_type = u1,
378 .fields = &[_]TypeInfo.EnumField{
378 .fields = &.{
379379 .{ .name = "signed", .value = 0 },
380380 .{ .name = "unsigned", .value = 1 },
381381 },
382 .decls = &[_]TypeInfo.Declaration{},
382 .decls = &.{},
383383 .is_exhaustive = true,
384384 },
385385 });
......@@ -387,11 +387,11 @@ test "Type.Union" {
387387 .Union = .{
388388 .layout = .Auto,
389389 .tag_type = Tag,
390 .fields = &[_]TypeInfo.UnionField{
390 .fields = &.{
391391 .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },
392392 .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },
393393 },
394 .decls = &[_]TypeInfo.Declaration{},
394 .decls = &.{},
395395 },
396396 });
397397 var tagged = Tagged{ .signed = -1 };
......@@ -407,10 +407,10 @@ test "Type.Union from Type.Enum" {
407407 .Enum = .{
408408 .layout = .Auto,
409409 .tag_type = u0,
410 .fields = &[_]TypeInfo.EnumField{
410 .fields = &.{
411411 .{ .name = "working_as_expected", .value = 0 },
412412 },
413 .decls = &[_]TypeInfo.Declaration{},
413 .decls = &.{},
414414 .is_exhaustive = true,
415415 },
416416 });
......@@ -418,10 +418,10 @@ test "Type.Union from Type.Enum" {
418418 .Union = .{
419419 .layout = .Auto,
420420 .tag_type = Tag,
421 .fields = &[_]TypeInfo.UnionField{
421 .fields = &.{
422422 .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) },
423423 },
424 .decls = &[_]TypeInfo.Declaration{},
424 .decls = &.{},
425425 },
426426 });
427427 _ = T;
......@@ -436,10 +436,10 @@ test "Type.Union from regular enum" {
436436 .Union = .{
437437 .layout = .Auto,
438438 .tag_type = E,
439 .fields = &[_]TypeInfo.UnionField{
439 .fields = &.{
440440 .{ .name = "working_as_expected", .field_type = u32, .alignment = @alignOf(u32) },
441441 },
442 .decls = &[_]TypeInfo.Declaration{},
442 .decls = &.{},
443443 },
444444 });
445445 _ = T;
test/behavior/type_info.zig+8-8
......@@ -2,7 +2,7 @@ const std = @import("std");
22const builtin = @import("builtin");
33const mem = std.mem;
44
5const TypeInfo = std.builtin.TypeInfo;
5const Type = std.builtin.Type;
66const TypeId = std.builtin.TypeId;
77
88const expect = std.testing.expect;
......@@ -64,7 +64,7 @@ test "type info: tag type, void info" {
6464}
6565
6666fn testBasic() !void {
67 try expect(@typeInfo(TypeInfo).Union.tag_type == TypeId);
67 try expect(@typeInfo(Type).Union.tag_type == TypeId);
6868 const void_info = @typeInfo(void);
6969 try expect(void_info == TypeId.Void);
7070 try expect(void_info.Void == {});
......@@ -78,7 +78,7 @@ test "type info: pointer type info" {
7878fn testPointer() !void {
7979 const u32_ptr_info = @typeInfo(*u32);
8080 try expect(u32_ptr_info == .Pointer);
81 try expect(u32_ptr_info.Pointer.size == TypeInfo.Pointer.Size.One);
81 try expect(u32_ptr_info.Pointer.size == .One);
8282 try expect(u32_ptr_info.Pointer.is_const == false);
8383 try expect(u32_ptr_info.Pointer.is_volatile == false);
8484 try expect(u32_ptr_info.Pointer.alignment == @alignOf(u32));
......@@ -94,7 +94,7 @@ test "type info: unknown length pointer type info" {
9494fn testUnknownLenPtr() !void {
9595 const u32_ptr_info = @typeInfo([*]const volatile f64);
9696 try expect(u32_ptr_info == .Pointer);
97 try expect(u32_ptr_info.Pointer.size == TypeInfo.Pointer.Size.Many);
97 try expect(u32_ptr_info.Pointer.size == .Many);
9898 try expect(u32_ptr_info.Pointer.is_const == true);
9999 try expect(u32_ptr_info.Pointer.is_volatile == true);
100100 try expect(u32_ptr_info.Pointer.sentinel == null);
......@@ -110,7 +110,7 @@ test "type info: null terminated pointer type info" {
110110fn testNullTerminatedPtr() !void {
111111 const ptr_info = @typeInfo([*:0]u8);
112112 try expect(ptr_info == .Pointer);
113 try expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.Many);
113 try expect(ptr_info.Pointer.size == .Many);
114114 try expect(ptr_info.Pointer.is_const == false);
115115 try expect(ptr_info.Pointer.is_volatile == false);
116116 try expect(@ptrCast(*const u8, ptr_info.Pointer.sentinel.?).* == 0);
......@@ -254,7 +254,7 @@ test "type info: union info" {
254254}
255255
256256fn testUnion() !void {
257 const typeinfo_info = @typeInfo(TypeInfo);
257 const typeinfo_info = @typeInfo(Type);
258258 try expect(typeinfo_info == .Union);
259259 try expect(typeinfo_info.Union.layout == .Auto);
260260 try expect(typeinfo_info.Union.tag_type.? == TypeId);
......@@ -437,12 +437,12 @@ test "type info: pass to function" {
437437 _ = comptime passTypeInfo(@typeInfo(void));
438438}
439439
440fn passTypeInfo(comptime info: TypeInfo) type {
440fn passTypeInfo(comptime info: Type) type {
441441 _ = info;
442442 return void;
443443}
444444
445test "type info: TypeId -> TypeInfo impl cast" {
445test "type info: TypeId -> Type impl cast" {
446446 _ = passTypeInfo(TypeId.Void);
447447 _ = comptime passTypeInfo(TypeId.Void);
448448}
test/compile_errors.zig+44-51
......@@ -95,12 +95,12 @@ pub fn addCases(ctx: *TestContext) !void {
9595 });
9696
9797 ctx.objErrStage1("@Type() union payload is undefined",
98 \\const Foo = @Type(@import("std").builtin.TypeInfo{
98 \\const Foo = @Type(.{
9999 \\ .Struct = undefined,
100100 \\});
101101 \\comptime { _ = Foo; }
102102 , &[_][]const u8{
103 "tmp.zig:1:50: error: use of undefined value here causes undefined behavior",
103 "tmp.zig:1:20: error: use of undefined value here causes undefined behavior",
104104 });
105105
106106 ctx.objErrStage1("wrong initializer for union payload of type 'type'",
......@@ -258,16 +258,16 @@ pub fn addCases(ctx: *TestContext) !void {
258258 "tmp.zig:8:12: note: called from here",
259259 });
260260
261 ctx.objErrStage1("@Type with TypeInfo.Int",
261 ctx.objErrStage1("@Type with Type.Int",
262262 \\const builtin = @import("std").builtin;
263263 \\export fn entry() void {
264 \\ _ = @Type(builtin.TypeInfo.Int {
264 \\ _ = @Type(builtin.Type.Int{
265265 \\ .signedness = .signed,
266266 \\ .bits = 8,
267267 \\ });
268268 \\}
269269 , &[_][]const u8{
270 "tmp.zig:3:36: error: expected type 'std.builtin.TypeInfo', found 'std.builtin.Int'",
270 "tmp.zig:3:31: error: expected type 'std.builtin.Type', found 'std.builtin.Int'",
271271 });
272272
273273 ctx.objErrStage1("indexing a undefined slice at comptime",
......@@ -293,13 +293,12 @@ pub fn addCases(ctx: *TestContext) !void {
293293 });
294294
295295 ctx.objErrStage1("@Type for exhaustive enum with undefined tag type",
296 \\const TypeInfo = @import("std").builtin.TypeInfo;
297296 \\const Tag = @Type(.{
298297 \\ .Enum = .{
299298 \\ .layout = .Auto,
300299 \\ .tag_type = undefined,
301 \\ .fields = &[_]TypeInfo.EnumField{},
302 \\ .decls = &[_]TypeInfo.Declaration{},
300 \\ .fields = &.{},
301 \\ .decls = &.{},
303302 \\ .is_exhaustive = false,
304303 \\ },
305304 \\});
......@@ -307,7 +306,7 @@ pub fn addCases(ctx: *TestContext) !void {
307306 \\ _ = @intToEnum(Tag, 0);
308307 \\}
309308 , &[_][]const u8{
310 "tmp.zig:2:20: error: use of undefined value here causes undefined behavior",
309 "tmp.zig:1:20: error: use of undefined value here causes undefined behavior",
311310 });
312311
313312 ctx.objErrStage1("extern struct with non-extern-compatible integer tag type",
......@@ -324,13 +323,12 @@ pub fn addCases(ctx: *TestContext) !void {
324323 });
325324
326325 ctx.objErrStage1("@Type for exhaustive enum with non-integer tag type",
327 \\const TypeInfo = @import("std").builtin.TypeInfo;
328326 \\const Tag = @Type(.{
329327 \\ .Enum = .{
330328 \\ .layout = .Auto,
331329 \\ .tag_type = bool,
332 \\ .fields = &[_]TypeInfo.EnumField{},
333 \\ .decls = &[_]TypeInfo.Declaration{},
330 \\ .fields = &.{},
331 \\ .decls = &.{},
334332 \\ .is_exhaustive = false,
335333 \\ },
336334 \\});
......@@ -338,7 +336,7 @@ pub fn addCases(ctx: *TestContext) !void {
338336 \\ _ = @intToEnum(Tag, 0);
339337 \\}
340338 , &[_][]const u8{
341 "tmp.zig:2:20: error: TypeInfo.Enum.tag_type must be an integer type, not 'bool'",
339 "tmp.zig:1:20: error: Type.Enum.tag_type must be an integer type, not 'bool'",
342340 });
343341
344342 ctx.objErrStage1("extern struct with extern-compatible but inferred integer tag type",
......@@ -384,17 +382,16 @@ pub fn addCases(ctx: *TestContext) !void {
384382 });
385383
386384 ctx.objErrStage1("@Type for tagged union with extra enum field",
387 \\const TypeInfo = @import("std").builtin.TypeInfo;
388385 \\const Tag = @Type(.{
389386 \\ .Enum = .{
390387 \\ .layout = .Auto,
391388 \\ .tag_type = u2,
392 \\ .fields = &[_]TypeInfo.EnumField{
389 \\ .fields = &.{
393390 \\ .{ .name = "signed", .value = 0 },
394391 \\ .{ .name = "unsigned", .value = 1 },
395392 \\ .{ .name = "arst", .value = 2 },
396393 \\ },
397 \\ .decls = &[_]TypeInfo.Declaration{},
394 \\ .decls = &.{},
398395 \\ .is_exhaustive = true,
399396 \\ },
400397 \\});
......@@ -402,11 +399,11 @@ pub fn addCases(ctx: *TestContext) !void {
402399 \\ .Union = .{
403400 \\ .layout = .Auto,
404401 \\ .tag_type = Tag,
405 \\ .fields = &[_]TypeInfo.UnionField{
402 \\ .fields = &.{
406403 \\ .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },
407404 \\ .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },
408405 \\ },
409 \\ .decls = &[_]TypeInfo.Declaration{},
406 \\ .decls = &.{},
410407 \\ },
411408 \\});
412409 \\export fn entry() void {
......@@ -414,7 +411,7 @@ pub fn addCases(ctx: *TestContext) !void {
414411 \\ tagged = .{ .unsigned = 1 };
415412 \\}
416413 , &[_][]const u8{
417 "tmp.zig:15:23: error: enum field missing: 'arst'",
414 "tmp.zig:14:23: error: enum field missing: 'arst'",
418415 });
419416
420417 ctx.objErrStage1("field access of opaque type",
......@@ -450,12 +447,12 @@ pub fn addCases(ctx: *TestContext) !void {
450447 \\ .is_generic = true,
451448 \\ .is_var_args = false,
452449 \\ .return_type = u0,
453 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
450 \\ .args = &.{},
454451 \\ },
455452 \\});
456453 \\comptime { _ = Foo; }
457454 , &[_][]const u8{
458 "tmp.zig:1:20: error: TypeInfo.Fn.is_generic must be false for @Type",
455 "tmp.zig:1:20: error: Type.Fn.is_generic must be false for @Type",
459456 });
460457
461458 ctx.objErrStage1("@Type(.Fn) with is_var_args = true and non-C callconv",
......@@ -466,7 +463,7 @@ pub fn addCases(ctx: *TestContext) !void {
466463 \\ .is_generic = false,
467464 \\ .is_var_args = true,
468465 \\ .return_type = u0,
469 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
466 \\ .args = &.{},
470467 \\ },
471468 \\});
472469 \\comptime { _ = Foo; }
......@@ -482,31 +479,30 @@ pub fn addCases(ctx: *TestContext) !void {
482479 \\ .is_generic = false,
483480 \\ .is_var_args = false,
484481 \\ .return_type = null,
485 \\ .args = &[_]@import("std").builtin.TypeInfo.Fn.Param{},
482 \\ .args = &.{},
486483 \\ },
487484 \\});
488485 \\comptime { _ = Foo; }
489486 , &[_][]const u8{
490 "tmp.zig:1:20: error: TypeInfo.Fn.return_type must be non-null for @Type",
487 "tmp.zig:1:20: error: Type.Fn.return_type must be non-null for @Type",
491488 });
492489
493490 ctx.objErrStage1("@Type for union with opaque field",
494 \\const TypeInfo = @import("std").builtin.TypeInfo;
495491 \\const Untagged = @Type(.{
496492 \\ .Union = .{
497493 \\ .layout = .Auto,
498494 \\ .tag_type = null,
499 \\ .fields = &[_]TypeInfo.UnionField{
495 \\ .fields = &.{
500496 \\ .{ .name = "foo", .field_type = opaque {}, .alignment = 1 },
501497 \\ },
502 \\ .decls = &[_]TypeInfo.Declaration{},
498 \\ .decls = &.{},
503499 \\ },
504500 \\});
505501 \\export fn entry() void {
506502 \\ _ = Untagged{};
507503 \\}
508504 , &[_][]const u8{
509 "tmp.zig:2:25: error: opaque types have unknown size and therefore cannot be directly embedded in unions",
505 "tmp.zig:1:25: error: opaque types have unknown size and therefore cannot be directly embedded in unions",
510506 });
511507
512508 ctx.objErrStage1("slice sentinel mismatch",
......@@ -528,30 +524,28 @@ pub fn addCases(ctx: *TestContext) !void {
528524 });
529525
530526 ctx.objErrStage1("@Type for union with zero fields",
531 \\const TypeInfo = @import("std").builtin.TypeInfo;
532527 \\const Untagged = @Type(.{
533528 \\ .Union = .{
534529 \\ .layout = .Auto,
535530 \\ .tag_type = null,
536 \\ .fields = &[_]TypeInfo.UnionField{},
537 \\ .decls = &[_]TypeInfo.Declaration{},
531 \\ .fields = &.{},
532 \\ .decls = &.{},
538533 \\ },
539534 \\});
540535 \\export fn entry() void {
541536 \\ _ = Untagged{};
542537 \\}
543538 , &[_][]const u8{
544 "tmp.zig:2:25: error: unions must have 1 or more fields",
539 "tmp.zig:1:25: error: unions must have 1 or more fields",
545540 });
546541
547542 ctx.objErrStage1("@Type for exhaustive enum with zero fields",
548 \\const TypeInfo = @import("std").builtin.TypeInfo;
549543 \\const Tag = @Type(.{
550544 \\ .Enum = .{
551545 \\ .layout = .Auto,
552546 \\ .tag_type = u1,
553 \\ .fields = &[_]TypeInfo.EnumField{},
554 \\ .decls = &[_]TypeInfo.Declaration{},
547 \\ .fields = &.{},
548 \\ .decls = &.{},
555549 \\ .is_exhaustive = true,
556550 \\ },
557551 \\});
......@@ -559,20 +553,19 @@ pub fn addCases(ctx: *TestContext) !void {
559553 \\ _ = @intToEnum(Tag, 0);
560554 \\}
561555 , &[_][]const u8{
562 "tmp.zig:2:20: error: enums must have 1 or more fields",
556 "tmp.zig:1:20: error: enums must have 1 or more fields",
563557 });
564558
565559 ctx.objErrStage1("@Type for tagged union with extra union field",
566 \\const TypeInfo = @import("std").builtin.TypeInfo;
567560 \\const Tag = @Type(.{
568561 \\ .Enum = .{
569562 \\ .layout = .Auto,
570563 \\ .tag_type = u1,
571 \\ .fields = &[_]TypeInfo.EnumField{
564 \\ .fields = &.{
572565 \\ .{ .name = "signed", .value = 0 },
573566 \\ .{ .name = "unsigned", .value = 1 },
574567 \\ },
575 \\ .decls = &[_]TypeInfo.Declaration{},
568 \\ .decls = &.{},
576569 \\ .is_exhaustive = true,
577570 \\ },
578571 \\});
......@@ -580,12 +573,12 @@ pub fn addCases(ctx: *TestContext) !void {
580573 \\ .Union = .{
581574 \\ .layout = .Auto,
582575 \\ .tag_type = Tag,
583 \\ .fields = &[_]TypeInfo.UnionField{
576 \\ .fields = &.{
584577 \\ .{ .name = "signed", .field_type = i32, .alignment = @alignOf(i32) },
585578 \\ .{ .name = "unsigned", .field_type = u32, .alignment = @alignOf(u32) },
586579 \\ .{ .name = "arst", .field_type = f32, .alignment = @alignOf(f32) },
587580 \\ },
588 \\ .decls = &[_]TypeInfo.Declaration{},
581 \\ .decls = &.{},
589582 \\ },
590583 \\});
591584 \\export fn entry() void {
......@@ -593,8 +586,8 @@ pub fn addCases(ctx: *TestContext) !void {
593586 \\ tagged = .{ .unsigned = 1 };
594587 \\}
595588 , &[_][]const u8{
596 "tmp.zig:14:23: error: enum field not found: 'arst'",
597 "tmp.zig:2:20: note: enum declared here",
589 "tmp.zig:13:23: error: enum field not found: 'arst'",
590 "tmp.zig:1:20: note: enum declared here",
598591 });
599592
600593 ctx.objErrStage1("@Type with undefined",
......@@ -621,7 +614,7 @@ pub fn addCases(ctx: *TestContext) !void {
621614 \\ _ = @Type(@typeInfo(struct { const foo = 1; }));
622615 \\}
623616 , &[_][]const u8{
624 "tmp.zig:2:15: error: TypeInfo.Struct.decls must be empty for @Type",
617 "tmp.zig:2:15: error: Type.Struct.decls must be empty for @Type",
625618 });
626619
627620 ctx.objErrStage1("enum with declarations unavailable for @Type",
......@@ -629,7 +622,7 @@ pub fn addCases(ctx: *TestContext) !void {
629622 \\ _ = @Type(@typeInfo(enum { foo, const bar = 1; }));
630623 \\}
631624 , &[_][]const u8{
632 "tmp.zig:2:15: error: TypeInfo.Enum.decls must be empty for @Type",
625 "tmp.zig:2:15: error: Type.Enum.decls must be empty for @Type",
633626 });
634627
635628 ctx.testErrStage1("reject extern variables with initializers",
......@@ -2081,10 +2074,10 @@ pub fn addCases(ctx: *TestContext) !void {
20812074 ctx.objErrStage1("attempt to create 17 bit float type",
20822075 \\const builtin = @import("std").builtin;
20832076 \\comptime {
2084 \\ _ = @Type(builtin.TypeInfo { .Float = builtin.TypeInfo.Float { .bits = 17 } });
2077 \\ _ = @Type(.{ .Float = .{ .bits = 17 } });
20852078 \\}
20862079 , &[_][]const u8{
2087 "tmp.zig:3:32: error: 17-bit float unsupported",
2080 "tmp.zig:3:16: error: 17-bit float unsupported",
20882081 });
20892082
20902083 ctx.objErrStage1("wrong type for @Type",
......@@ -2092,12 +2085,12 @@ pub fn addCases(ctx: *TestContext) !void {
20922085 \\ _ = @Type(0);
20932086 \\}
20942087 , &[_][]const u8{
2095 "tmp.zig:2:15: error: expected type 'std.builtin.TypeInfo', found 'comptime_int'",
2088 "tmp.zig:2:15: error: expected type 'std.builtin.Type', found 'comptime_int'",
20962089 });
20972090
20982091 ctx.objErrStage1("@Type with non-constant expression",
20992092 \\const builtin = @import("std").builtin;
2100 \\var globalTypeInfo : builtin.TypeInfo = undefined;
2093 \\var globalTypeInfo : builtin.Type = undefined;
21012094 \\export fn entry() void {
21022095 \\ _ = @Type(globalTypeInfo);
21032096 \\}
......@@ -8156,12 +8149,12 @@ pub fn addCases(ctx: *TestContext) !void {
81568149 ctx.testErrStage1("nested vectors",
81578150 \\export fn entry() void {
81588151 \\ const V1 = @import("std").meta.Vector(4, u8);
8159 \\ const V2 = @Type(@import("std").builtin.TypeInfo{ .Vector = .{ .len = 4, .child = V1 } });
8152 \\ const V2 = @Type(.{ .Vector = .{ .len = 4, .child = V1 } });
81608153 \\ var v: V2 = undefined;
81618154 \\ _ = v;
81628155 \\}
81638156 , &[_][]const u8{
8164 "tmp.zig:3:53: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid",
8157 "tmp.zig:3:23: error: vector element type must be integer, float, bool, or pointer; '@Vector(4, u8)' is invalid",
81658158 });
81668159
81678160 ctx.testErrStage1("bad @splat type",