Skip to content

Commit dec1163

Browse files
alichraghimlugg
andcommitted
all: replace all @Type usages
Co-authored-by: Matthew Lugg <[email protected]>
1 parent ce0df03 commit dec1163

File tree

108 files changed

+631
-1893
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+631
-1893
lines changed

doc/langref/std_options.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub const std_options: std.Options = .{
1111

1212
fn myLogFn(
1313
comptime level: std.log.Level,
14-
comptime scope: @Type(.enum_literal),
14+
comptime scope: @EnumLiteral(),
1515
comptime format: []const u8,
1616
args: anytype,
1717
) void {

doc/langref/test_coerce_unions_enums.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test "coercion between unions and enums" {
4141
try expect(u_4.tag() == 1);
4242

4343
// The following example is invalid.
44-
// error: coercion from enum '@TypeOf(.enum_literal)' to union 'test_coerce_unions_enum.U2' must initialize 'f32' field 'b'
44+
// error: coercion from enum '@EnumLiteral()' to union 'test_coerce_unions_enum.U2' must initialize 'f32' field 'b'
4545
//var u_5: U2 = .b;
4646
//try expect(u_5.tag() == 2);
4747
}

lib/build-web/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn panic(msg: []const u8, st: ?*std.builtin.StackTrace, addr: ?usize) noretu
4949

5050
fn logFn(
5151
comptime message_level: log.Level,
52-
comptime scope: @TypeOf(.enum_literal),
52+
comptime scope: @EnumLiteral(),
5353
comptime format: []const u8,
5454
args: anytype,
5555
) void {

lib/compiler/aro/aro/Attribute.zig

Lines changed: 6 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -717,23 +717,13 @@ pub const Tag = std.meta.DeclEnum(attributes);
717717

718718
pub const Arguments = blk: {
719719
const decls = @typeInfo(attributes).@"struct".decls;
720-
var union_fields: [decls.len]ZigType.UnionField = undefined;
721-
for (decls, &union_fields) |decl, *field| {
722-
field.* = .{
723-
.name = decl.name,
724-
.type = @field(attributes, decl.name),
725-
.alignment = @alignOf(@field(attributes, decl.name)),
726-
};
720+
var names: [decls.len][]const u8 = undefined;
721+
var types: [decls.len]type = undefined;
722+
for (decls, &names, &types) |decl, *name, *T| {
723+
name.* = decl.name;
724+
T.* = @field(attributes, decl.name);
727725
}
728-
729-
break :blk @Type(.{
730-
.@"union" = .{
731-
.layout = .auto,
732-
.tag_type = null,
733-
.fields = &union_fields,
734-
.decls = &.{},
735-
},
736-
});
726+
break :blk @Union(.auto, null, &names, &types, &@splat(.{}));
737727
};
738728

739729
pub fn ArgumentsForTag(comptime tag: Tag) type {

lib/compiler/aro/assembly_backend/x86_64.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fn serializeFloat(comptime T: type, value: T, w: *std.Io.Writer) !void {
5959
else => {
6060
const size = @bitSizeOf(T);
6161
const storage_unit = std.meta.intToEnum(StorageUnit, size) catch unreachable;
62-
const IntTy = @Type(.{ .int = .{ .signedness = .unsigned, .bits = size } });
62+
const IntTy = @Int(.unsigned, size);
6363
const int_val: IntTy = @bitCast(value);
6464
return serializeInt(int_val, storage_unit, w);
6565
},

lib/compiler/resinator/code_pages.zig

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -179,12 +179,13 @@ pub const UnsupportedCodePage = enum(u16) {
179179

180180
pub const CodePage = blk: {
181181
const fields = @typeInfo(SupportedCodePage).@"enum".fields ++ @typeInfo(UnsupportedCodePage).@"enum".fields;
182-
break :blk @Type(.{ .@"enum" = .{
183-
.tag_type = u16,
184-
.decls = &.{},
185-
.fields = fields,
186-
.is_exhaustive = true,
187-
} });
182+
var field_names: [fields.len][]const u8 = undefined;
183+
var field_values: [fields.len]u16 = undefined;
184+
for (fields, &field_names, &field_values) |field, *name, *val| {
185+
name.* = field.name;
186+
val.* = field.value;
187+
}
188+
break :blk @Enum(u16, .exhaustive, &field_names, &field_values);
188189
};
189190

190191
pub fn isSupported(code_page: CodePage) bool {

lib/compiler/resinator/errors.zig

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -862,20 +862,23 @@ pub const ErrorDetails = struct {
862862
pub const ErrorDetailsWithoutCodePage = blk: {
863863
const details_info = @typeInfo(ErrorDetails);
864864
const fields = details_info.@"struct".fields;
865-
var fields_without_codepage: [fields.len - 1]std.builtin.Type.StructField = undefined;
865+
var field_names: [fields.len - 1][]const u8 = undefined;
866+
var field_types: [fields.len - 1]type = undefined;
867+
var field_attrs: [fields.len - 1]std.builtin.Type.StructField.Attributes = undefined;
866868
var i: usize = 0;
867869
for (fields) |field| {
868870
if (std.mem.eql(u8, field.name, "code_page")) continue;
869-
fields_without_codepage[i] = field;
871+
field_names[i] = field.name;
872+
field_types[i] = field.type;
873+
field_attrs[i] = .{
874+
.@"comptime" = field.is_comptime,
875+
.@"align" = field.alignment,
876+
.default_value_ptr = field.default_value_ptr,
877+
};
870878
i += 1;
871879
}
872-
std.debug.assert(i == fields_without_codepage.len);
873-
break :blk @Type(.{ .@"struct" = .{
874-
.layout = .auto,
875-
.fields = &fields_without_codepage,
876-
.decls = &.{},
877-
.is_tuple = false,
878-
} });
880+
std.debug.assert(i == fields.len - 1);
881+
break :blk @Struct(.auto, null, &field_names, &field_types, &field_attrs);
879882
};
880883

881884
fn cellCount(code_page: SupportedCodePage, source: []const u8, start_index: usize, end_index: usize) usize {

lib/compiler/test_runner.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ fn mainTerminal() void {
298298

299299
pub fn log(
300300
comptime message_level: std.log.Level,
301-
comptime scope: @Type(.enum_literal),
301+
comptime scope: @EnumLiteral(),
302302
comptime format: []const u8,
303303
args: anytype,
304304
) void {

lib/compiler_rt/common.zig

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,7 @@ pub fn normalize(comptime T: type, significand: *std.meta.Int(.unsigned, @typeIn
290290
pub inline fn fneg(a: anytype) @TypeOf(a) {
291291
const F = @TypeOf(a);
292292
const bits = @typeInfo(F).float.bits;
293-
const U = @Type(.{ .int = .{
294-
.signedness = .unsigned,
295-
.bits = bits,
296-
} });
293+
const U = @Int(.unsigned, bits);
297294
const sign_bit_mask = @as(U, 1) << (bits - 1);
298295
const negated = @as(U, @bitCast(a)) ^ sign_bit_mask;
299296
return @bitCast(negated);

lib/compiler_rt/float_from_int.zig

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,17 @@ pub inline fn floatFromBigInt(comptime T: type, comptime signedness: std.builtin
6666
switch (x.len) {
6767
0 => return 0,
6868
inline 1...4 => |limbs_len| return @floatFromInt(@as(
69-
@Type(.{ .int = .{ .signedness = signedness, .bits = 32 * limbs_len } }),
69+
@Int(signedness, 32 * limbs_len),
7070
@bitCast(x[0..limbs_len].*),
7171
)),
7272
else => {},
7373
}
7474

7575
// sign implicit fraction round sticky
76-
const I = comptime @Type(.{ .int = .{
77-
.signedness = signedness,
78-
.bits = @as(u16, @intFromBool(signedness == .signed)) + 1 + math.floatFractionalBits(T) + 1 + 1,
79-
} });
76+
const I = comptime @Int(
77+
signedness,
78+
@as(u16, @intFromBool(signedness == .signed)) + 1 + math.floatFractionalBits(T) + 1 + 1,
79+
);
8080

8181
const clrsb = clrsb: {
8282
var clsb: usize = 0;

0 commit comments

Comments
 (0)