Skip to content

Commit ea9c72f

Browse files
committed
Update std.builtin.Type field names
See: ziglang/zig#21225
1 parent 3c1cf40 commit ea9c72f

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

args.zig

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -294,19 +294,19 @@ fn parseInternal(comptime Generic: type, comptime MaybeVerb: ?type, args_iterato
294294

295295
fn canHaveFieldsAndIsNotZeroSized(comptime T: type) bool {
296296
return switch (@typeInfo(T)) {
297-
.Struct, .Union, .Enum, .ErrorSet => @sizeOf(T) != 0,
297+
.@"struct", .@"union", .@"enum", .error_set => @sizeOf(T) != 0,
298298
else => false,
299299
};
300300
}
301301

302302
/// The return type of the argument parser.
303303
pub fn ParseArgsResult(comptime Generic: type, comptime MaybeVerb: ?type) type {
304-
if (@typeInfo(Generic) != .Struct)
304+
if (@typeInfo(Generic) != .@"struct")
305305
@compileError("Generic argument definition must be a struct");
306306

307307
if (MaybeVerb) |Verb| {
308308
const ti: std.builtin.Type = @typeInfo(Verb);
309-
if (ti != .Union or ti.Union.tag_type == null)
309+
if (ti != .@"union" or ti.@"union".tag_type == null)
310310
@compileError("Verb must be a tagged union");
311311
}
312312

@@ -354,18 +354,18 @@ fn requiresArg(comptime T: type) bool {
354354
return true;
355355

356356
return switch (@as(std.builtin.TypeId, @typeInfo(Type))) {
357-
.Int, .Float, .Enum => true,
358-
.Bool => false,
359-
.Struct, .Union => true,
360-
.Pointer => true,
357+
.int, .float, .@"enum" => true,
358+
.bool => false,
359+
.@"struct", .@"union" => true,
360+
.pointer => true,
361361
else => @compileError(@typeName(Type) ++ " is not a supported argument type!"),
362362
};
363363
}
364364
};
365365

366366
const ti = @typeInfo(T);
367-
if (ti == .Optional) {
368-
return H.doesArgTypeRequireArg(ti.Optional.child);
367+
if (ti == .optional) {
368+
return H.doesArgTypeRequireArg(ti.optional.child);
369369
} else {
370370
return H.doesArgTypeRequireArg(T);
371371
}
@@ -419,7 +419,7 @@ fn parseInt(comptime T: type, str: []const u8) !T {
419419
}
420420
}
421421

422-
const ret: T = switch (@typeInfo(T).Int.signedness) {
422+
const ret: T = switch (@typeInfo(T).int.signedness) {
423423
.signed => try std.fmt.parseInt(T, buf, 0),
424424
.unsigned => try std.fmt.parseUnsigned(T, buf, 0),
425425
};
@@ -442,28 +442,28 @@ test "parseInt" {
442442
/// Converts an argument value to the target type.
443443
fn convertArgumentValue(comptime T: type, allocator: std.mem.Allocator, textInput: []const u8) !T {
444444
switch (@typeInfo(T)) {
445-
.Optional => |opt| return try convertArgumentValue(opt.child, allocator, textInput),
446-
.Bool => if (textInput.len > 0)
445+
.optional => |opt| return try convertArgumentValue(opt.child, allocator, textInput),
446+
.bool => if (textInput.len > 0)
447447
return try parseBoolean(textInput)
448448
else
449449
return true, // boolean options are always true
450-
.Int => return try parseInt(T, textInput),
451-
.Float => return try std.fmt.parseFloat(T, textInput),
452-
.Enum => {
450+
.int => return try parseInt(T, textInput),
451+
.float => return try std.fmt.parseFloat(T, textInput),
452+
.@"enum" => {
453453
if (@hasDecl(T, "parse")) {
454454
return try T.parse(textInput);
455455
} else {
456456
return std.meta.stringToEnum(T, textInput) orelse return error.InvalidEnumeration;
457457
}
458458
},
459-
.Struct, .Union => {
459+
.@"struct", .@"union" => {
460460
if (@hasDecl(T, "parse")) {
461461
return try T.parse(textInput);
462462
} else {
463463
@compileError(@typeName(T) ++ " has no public visible `fn parse([]const u8) !T`!");
464464
}
465465
},
466-
.Pointer => |ptr| switch (ptr.size) {
466+
.pointer => |ptr| switch (ptr.size) {
467467
.Slice => {
468468
if (ptr.child != u8) {
469469
@compileError(@typeName(T) ++ " is not a supported pointer type, only slices of u8 are supported");
@@ -652,7 +652,7 @@ pub const ErrorHandling = union(enum) {
652652

653653
/// Processes an error with the given handling method.
654654
fn process(comptime self: Self, src_error: anytype, err: Error) !void {
655-
if (@typeInfo(@TypeOf(src_error)) != .ErrorSet)
655+
if (@typeInfo(@TypeOf(src_error)) != .error_set)
656656
@compileError("src_error must be a error union!");
657657
switch (self) {
658658
.silent => return src_error,

0 commit comments

Comments
 (0)