authorgravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-05-21 12:56:08 -07:00
committergravatar for hello@nektro.netMeghan Denny <hello@nektro.net> 2025-05-21 12:56:08 -07:00
log7026667f5ba4a7489fbdb30979f399e4fff50481
tree21bd5f795a539dc16e9204ec6a5dc54bc4e89189
parent100510135aa7be25b8b465ac32450678de009103

update to Zig 0.14


21 files changed, 52 insertions(+), 52 deletions(-)

src/AnyReader.zig+2-2
......@@ -12,7 +12,7 @@ pub const AnyReader = struct {
1212 const ctx = reader.context;
1313 const Ctx = @TypeOf(ctx);
1414 switch (@typeInfo(Ctx)) {
15 .Pointer => {
15 .pointer => {
1616 const S = struct {
1717 fn foo(s: *anyopaque, buffer: []u8) anyerror!usize {
1818 const r = R{ .context = @ptrCast(@alignCast(s)) };
......@@ -24,7 +24,7 @@ pub const AnyReader = struct {
2424 .state = ctx,
2525 };
2626 },
27 .Struct => switch (R) {
27 .@"struct" => switch (R) {
2828 std.fs.File.Reader => {
2929 const S = struct {
3030 fn foo(s: *anyopaque, buffer: []u8) anyerror!usize {
src/FieldUnion.zig+1-1
......@@ -14,7 +14,7 @@ pub fn FieldUnion(comptime T: type) type {
1414 .alignment = field.alignment,
1515 };
1616 }
17 return @Type(std.builtin.Type{ .Union = .{
17 return @Type(std.builtin.Type{ .@"union" = .{
1818 .layout = .auto,
1919 .tag_type = std.meta.FieldEnum(T),
2020 .fields = &fields,
src/FlippedInt.zig+1-1
......@@ -4,7 +4,7 @@ const extras = @import("./lib.zig");
44
55pub fn FlippedInt(comptime T: type) type {
66 var info = @typeInfo(T);
7 info.Int.signedness = switch (info.Int.signedness) {
7 info.int.signedness = switch (info.int.signedness) {
88 .signed => .unsigned,
99 .unsigned => .signed,
1010 };
src/OneBiggerInt.zig+1-1
......@@ -4,7 +4,7 @@ const extras = @import("./lib.zig");
44
55pub fn OneBiggerInt(comptime T: type) type {
66 var info = @typeInfo(T);
7 info.Int.bits += 1;
7 info.int.bits += 1;
88 return @Type(info);
99}
1010
src/OneSmallerInt.zig+1-1
......@@ -4,7 +4,7 @@ const extras = @import("./lib.zig");
44
55pub fn OneSmallerInt(comptime T: type) type {
66 var info = @typeInfo(T);
7 info.Int.bits -= 1;
7 info.int.bits -= 1;
88 return @Type(info);
99}
1010
src/Partial.zig+2-2
......@@ -12,12 +12,12 @@ pub fn Partial(comptime T: type) type {
1212 fields_after[i] = std.builtin.Type.StructField{
1313 .name = item.name,
1414 .type = ?item.type,
15 .default_value = &@as(?item.type, null),
15 .default_value_ptr = &@as(?item.type, null),
1616 .is_comptime = false,
1717 .alignment = @alignOf(?item.type),
1818 };
1919 }
20 return @Type(@unionInit(std.builtin.Type, "Struct", .{
20 return @Type(@unionInit(std.builtin.Type, "struct", .{
2121 .layout = .auto,
2222 .backing_integer = null,
2323 .fields = &fields_after,
src/ReverseFields.zig+2-2
......@@ -4,14 +4,14 @@ const extras = @import("./lib.zig");
44const expectSimilarType = extras.expectSimilarType;
55
66pub fn ReverseFields(comptime T: type) type {
7 var info = @typeInfo(T).Struct;
7 var info = @typeInfo(T).@"struct";
88 const len = info.fields.len;
99 var fields: [len]std.builtin.Type.StructField = undefined;
1010 for (0..len) |i| {
1111 fields[i] = info.fields[len - 1 - i];
1212 }
1313 info.fields = &fields;
14 return @Type(.{ .Struct = info });
14 return @Type(.{ .@"struct" = info });
1515}
1616
1717test {
src/StructOfArrays.zig+2-2
......@@ -10,13 +10,13 @@ pub fn StructOfArrays(len: usize, T: type) type {
1010 new_fields[i] = .{
1111 .name = item.name,
1212 .type = [len]item.type,
13 .default_value = null,
13 .default_value_ptr = null,
1414 .is_comptime = false,
1515 .alignment = @alignOf([len]item.type),
1616 };
1717 }
1818 const result = new_fields[0..fields.len];
19 return @Type(@unionInit(std.builtin.Type, "Struct", .{
19 return @Type(@unionInit(std.builtin.Type, "struct", .{
2020 .layout = .auto,
2121 .backing_integer = null,
2222 .fields = result,
src/StructOfSlices.zig+2-2
......@@ -10,13 +10,13 @@ pub fn StructOfSlices(T: type) type {
1010 new_fields[i] = .{
1111 .name = item.name,
1212 .type = []const item.type,
13 .default_value = null,
13 .default_value_ptr = null,
1414 .is_comptime = false,
1515 .alignment = @alignOf([]const item.type),
1616 };
1717 }
1818 const result = new_fields[0..fields.len];
19 return @Type(@unionInit(std.builtin.Type, "Struct", .{
19 return @Type(@unionInit(std.builtin.Type, "struct", .{
2020 .layout = .auto,
2121 .backing_integer = null,
2222 .fields = result,
src/expectSimilarType.zig+9-9
......@@ -7,9 +7,9 @@ pub fn expectSimilarType(comptime A: type, comptime B: type) !void {
77 const info_b = @typeInfo(B);
88 try std.testing.expect(std.meta.activeTag(info_a) == std.meta.activeTag(info_b));
99
10 if (info_a == .Struct) {
11 const info_a_s = info_a.Struct;
12 const info_b_s = info_b.Struct;
10 if (info_a == .@"struct") {
11 const info_a_s = info_a.@"struct";
12 const info_b_s = info_b.@"struct";
1313
1414 try std.testing.expect(info_a_s.layout == info_b_s.layout);
1515 try std.testing.expect(info_a_s.is_tuple == info_b_s.is_tuple);
......@@ -24,9 +24,9 @@ pub fn expectSimilarType(comptime A: type, comptime B: type) !void {
2424
2525 return;
2626 }
27 if (info_a == .Union) {
28 const info_a_u = info_a.Union;
29 const info_b_u = info_b.Union;
27 if (info_a == .@"union") {
28 const info_a_u = info_a.@"union";
29 const info_b_u = info_b.@"union";
3030
3131 try std.testing.expect(info_a_u.layout == info_b_u.layout);
3232 try expectSimilarType(info_a_u.tag_type.?, info_b_u.tag_type.?);
......@@ -39,9 +39,9 @@ pub fn expectSimilarType(comptime A: type, comptime B: type) !void {
3939
4040 return;
4141 }
42 if (info_a == .Enum) {
43 const info_a_e = info_a.Enum;
44 const info_b_e = info_b.Enum;
42 if (info_a == .@"enum") {
43 const info_a_e = info_a.@"enum";
44 const info_b_e = info_b.@"enum";
4545
4646 try std.testing.expect(info_a_e.tag_type == info_b_e.tag_type);
4747 try std.testing.expect(info_a_e.is_exhaustive == info_b_e.is_exhaustive);
src/hasFn.zig+1-1
......@@ -8,7 +8,7 @@ pub fn hasFn(comptime name: []const u8) fn (type) bool {
88 if (!comptime extras.isContainer(T)) return false;
99 if (!comptime @hasDecl(T, name)) return false;
1010 const DeclType = @TypeOf(@field(T, name));
11 return @typeInfo(DeclType) == .Fn;
11 return @typeInfo(DeclType) == .@"fn";
1212 }
1313 };
1414 return Closure.trait;
src/isArrayOf.zig+1-1
......@@ -6,7 +6,7 @@ pub fn isArrayOf(comptime T: type) fn (type) bool {
66 const Closure = struct {
77 pub fn trait(comptime C: type) bool {
88 return switch (@typeInfo(C)) {
9 .Array => |ti| ti.child == T,
9 .array => |ti| ti.child == T,
1010 else => false,
1111 };
1212 }
src/isContainer.zig+4-4
......@@ -4,10 +4,10 @@ const extras = @import("./lib.zig");
44
55pub fn isContainer(comptime T: type) bool {
66 return switch (@typeInfo(T)) {
7 .Struct,
8 .Union,
9 .Enum,
10 .Opaque,
7 .@"struct",
8 .@"union",
9 .@"enum",
10 .@"opaque",
1111 => true,
1212 else => false,
1313 };
src/isIndexable.zig+5-5
......@@ -3,13 +3,13 @@ const string = []const u8;
33const extras = @import("./lib.zig");
44
55pub fn isIndexable(comptime T: type) bool {
6 if (comptime is(.Pointer)(T)) {
7 if (@typeInfo(T).Pointer.size == .One) {
8 return (comptime is(.Array)(std.meta.Child(T)));
6 if (comptime is(.pointer)(T)) {
7 if (@typeInfo(T).pointer.size == .one) {
8 return (comptime is(.array)(std.meta.Child(T)));
99 }
1010 return true;
1111 }
12 return comptime is(.Array)(T) or is(.Vector)(T) or isTuple(T);
12 return comptime is(.array)(T) or is(.vector)(T) or isTuple(T);
1313}
1414fn is(comptime id: std.builtin.TypeId) fn (type) bool {
1515 const Closure = struct {
......@@ -20,7 +20,7 @@ fn is(comptime id: std.builtin.TypeId) fn (type) bool {
2020 return Closure.trait;
2121}
2222fn isTuple(comptime T: type) bool {
23 return is(.Struct)(T) and @typeInfo(T).Struct.is_tuple;
23 return is(.@"struct")(T) and @typeInfo(T).@"struct".is_tuple;
2424}
2525
2626test {
src/isSlice.zig+3-3
......@@ -3,9 +3,9 @@ const string = []const u8;
33const extras = @import("./lib.zig");
44
55pub fn isSlice(comptime T: type) bool {
6 if (comptime is(.Pointer)(T)) {
7 if (@typeInfo(T).Pointer.size == .Slice) return true;
8 if (@typeInfo(T).Pointer.size == .One and is(.Array)(std.meta.Child(T))) return true;
6 if (comptime is(.pointer)(T)) {
7 if (@typeInfo(T).pointer.size == .slice) return true;
8 if (@typeInfo(T).pointer.size == .one and is(.array)(std.meta.Child(T))) return true;
99 }
1010 return false;
1111}
src/isZigString.zig+6-6
......@@ -18,22 +18,22 @@ pub fn isZigString(comptime T: type) bool {
1818 return comptime blk: {
1919 // Only pointer types can be strings, no optionals
2020 const info = @typeInfo(T);
21 if (info != .Pointer) break :blk false;
21 if (info != .pointer) break :blk false;
2222
23 const ptr = &info.Pointer;
23 const ptr = &info.pointer;
2424 // Check for CV qualifiers that would prevent coerction to []const u8
2525 if (ptr.is_volatile or ptr.is_allowzero) break :blk false;
2626
2727 // If it's already a slice, simple check.
28 if (ptr.size == .Slice) {
28 if (ptr.size == .slice) {
2929 break :blk ptr.child == u8;
3030 }
3131
3232 // Otherwise check if it's an array type that coerces to slice.
33 if (ptr.size == .One) {
33 if (ptr.size == .one) {
3434 const child = @typeInfo(ptr.child);
35 if (child == .Array) {
36 const arr = &child.Array;
35 if (child == .array) {
36 const arr = &child.array;
3737 break :blk arr.child == u8;
3838 }
3939 }
src/pipe.zig+1-1
......@@ -3,7 +3,7 @@ const string = []const u8;
33const extras = @import("./lib.zig");
44
55pub fn pipe(reader_from: anytype, writer_to: anytype) !void {
6 var buf: [std.mem.page_size]u8 = undefined;
6 var buf: [std.heap.page_size_min]u8 = undefined;
77 var fifo = std.fifo.LinearFifo(u8, .Slice).init(&buf);
88 defer fifo.deinit();
99 try fifo.pump(reader_from, writer_to);
src/randomSlice.zig+1-1
......@@ -4,7 +4,7 @@ const extras = @import("./lib.zig");
44
55const alphabet = "0123456789abcdefghijklmnopqrstuvwxyz";
66
7pub fn randomSlice(alloc: std.mem.Allocator, rand: std.rand.Random, comptime T: type, len: usize) ![]T {
7pub fn randomSlice(alloc: std.mem.Allocator, rand: std.Random, comptime T: type, len: usize) ![]T {
88 var buf = try alloc.alloc(T, len);
99 var i: usize = 0;
1010 while (i < len) : (i += 1) {
src/rawInt.zig+1-1
......@@ -5,7 +5,7 @@ const builtin = @import("builtin");
55const native_endian = builtin.target.cpu.arch.endian();
66
77pub fn rawInt(comptime T: type, comptime literal: comptime_int) T {
8 comptime std.debug.assert(@typeInfo(T).Int.bits % 8 == 0);
8 comptime std.debug.assert(@typeInfo(T).int.bits % 8 == 0);
99 return switch (native_endian) {
1010 .little => @byteSwap(@as(T, literal)),
1111 .big => @compileError("unreachable"),
src/readType.zig+4-4
......@@ -8,7 +8,7 @@ const rawIntBytes = extras.rawIntBytes;
88pub fn readType(reader: anytype, comptime T: type, endian: std.builtin.Endian) !T {
99 if (T == u8) return reader.readByte(); // single bytes dont have an endianness
1010 return switch (@typeInfo(T)) {
11 .Struct => |t| {
11 .@"struct" => |t| {
1212 switch (t.layout) {
1313 .auto, .@"extern" => {
1414 var s: T = undefined;
......@@ -20,15 +20,15 @@ pub fn readType(reader: anytype, comptime T: type, endian: std.builtin.Endian) !
2020 .@"packed" => return @bitCast(try readType(reader, t.backing_integer.?, endian)),
2121 }
2222 },
23 .Array => |t| {
23 .array => |t| {
2424 var s: T = undefined;
2525 for (0..t.len) |i| {
2626 s[i] = try readType(reader, t.child, endian);
2727 }
2828 return s;
2929 },
30 .Int => try reader.readInt(T, endian),
31 .Enum => |t| @enumFromInt(try readType(reader, t.tag_type, endian)),
30 .int => try reader.readInt(T, endian),
31 .@"enum" => |t| @enumFromInt(try readType(reader, t.tag_type, endian)),
3232 else => |e| @compileError(@tagName(e)),
3333 };
3434}
src/sliceToInt.zig+2-2
......@@ -3,8 +3,8 @@ const string = []const u8;
33const extras = @import("./lib.zig");
44
55pub fn sliceToInt(comptime T: type, comptime E: type, slice: []const E) !T {
6 const a = @typeInfo(T).Int.bits;
7 const b = @typeInfo(E).Int.bits;
6 const a = @typeInfo(T).int.bits;
7 const b = @typeInfo(E).int.bits;
88 if (a < b * slice.len) return error.Overflow;
99
1010 var n: T = 0;