diff options
Diffstat (limited to '9proc/src')
| -rw-r--r-- | 9proc/src/core.zig | 42 | ||||
| -rw-r--r-- | 9proc/src/linux/debug.zig | 16 | ||||
| -rw-r--r-- | 9proc/src/linux/probe.zig | 12 | ||||
| -rw-r--r-- | 9proc/src/linux/runtime.zig | 2 | ||||
| -rw-r--r-- | 9proc/src/vars.zig | 86 |
5 files changed, 81 insertions, 77 deletions
diff --git a/9proc/src/core.zig b/9proc/src/core.zig index ce71809..bdeb715 100644 --- a/9proc/src/core.zig +++ b/9proc/src/core.zig @@ -239,20 +239,20 @@ pub fn fieldsText(comptime T: type) []const u8 { @setEvalBranchQuota(200_000); var s: []const u8 = ""; switch (@typeInfo(T)) { - .@"struct" => |info| for (info.fields) |f| { + .@"struct" => |info| for (info.field_names, info.field_types, info.field_attrs) |name, F, attrs| { if (info.layout == .@"packed") { - s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}b\n", .{ f.name, @typeName(f.type), @bitOffsetOf(T, f.name) }); - } else if (f.is_comptime) { - s = s ++ std.fmt.comptimePrint("{s}: {s} (comptime)\n", .{ f.name, @typeName(f.type) }); + s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}b\n", .{ name, @typeName(F), @bitOffsetOf(T, name) }); + } else if (attrs.@"comptime") { + s = s ++ std.fmt.comptimePrint("{s}: {s} (comptime)\n", .{ name, @typeName(F) }); } else { - s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}\n", .{ f.name, @typeName(f.type), @offsetOf(T, f.name) }); + s = s ++ std.fmt.comptimePrint("{s}: {s} @{d}\n", .{ name, @typeName(F), @offsetOf(T, name) }); } }, - .@"union" => |info| for (info.fields) |f| { - s = s ++ f.name ++ ": " ++ @typeName(f.type) ++ "\n"; + .@"union" => |info| for (info.field_names, info.field_types) |name, F| { + s = s ++ name ++ ": " ++ @typeName(F) ++ "\n"; }, - .@"enum" => |info| for (info.fields) |f| { - s = s ++ std.fmt.comptimePrint("{s} = {d}\n", .{ f.name, f.value }); + .@"enum" => |info| for (info.field_names, info.field_values) |name, value| { + s = s ++ std.fmt.comptimePrint("{s} = {d}\n", .{ name, value }); }, else => s = @typeName(T) ++ "\n", } @@ -264,11 +264,11 @@ fn declsText(comptime T: type) []const u8 { comptime { @setEvalBranchQuota(20_000); const decls = switch (@typeInfo(T)) { - inline .@"struct", .@"union", .@"enum", .@"opaque" => |info| info.decls, - else => &[_]std.builtin.Type.Declaration{}, + inline .@"struct", .@"union", .@"enum", .@"opaque" => |info| info.decl_names, + else => &[_][:0]const u8{}, }; var s: []const u8 = ""; - for (decls) |d| s = s ++ d.name ++ "\n"; + for (decls) |name| s = s ++ name ++ "\n"; return s; } } @@ -297,10 +297,10 @@ pub const Node = struct { } }; -fn genNodes(comptime Fns: type) [@typeInfo(Fns).@"struct".decls.len]Node { - const decls = @typeInfo(Fns).@"struct".decls; +fn genNodes(comptime Fns: type) [@typeInfo(Fns).@"struct".decl_names.len]Node { + const decls = @typeInfo(Fns).@"struct".decl_names; var arr: [decls.len]Node = undefined; - for (decls, 0..) |d, i| arr[i] = .{ .name = d.name, .kind = .dynamic, .gen = genFor(Fns, d.name) }; + for (decls, 0..) |name, i| arr[i] = .{ .name = name, .kind = .dynamic, .gen = genFor(Fns, name) }; return arr; } @@ -490,7 +490,7 @@ pub fn Server(comptime cfg: Config) type { pub fn expose(s: *Shared, name: []const u8, ptr: anytype) error{Full}!void { const P = @TypeOf(ptr); const info = @typeInfo(P); - if (info != .pointer or info.pointer.size != .one or info.pointer.is_const) @compileError("expose wants a *T, got " ++ @typeName(P)); + if (info != .pointer or info.pointer.size != .one or info.pointer.attrs.@"const") @compileError("expose wants a *T, got " ++ @typeName(P)); if (s.nvars == cfg.max_vars) return error.Full; std.debug.assert(validName(name) != error.BadName); std.debug.assert(s.findVar(name) == null); @@ -1759,7 +1759,7 @@ test "runtime/fn calls the function at open and at each read from offset 0" { defer x.deinit(); const names = try x.h.listPath(&.{ "runtime", "fn" }); defer TS.Harness.freeNames(names); - try testing.expectEqual(@typeInfo(TestFns).@"struct".decls.len, names.len); + try testing.expectEqual(@typeInfo(TestFns).@"struct".decl_names.len, names.len); const fib_text = try x.h.readPath(&.{ "runtime", "fn", "fib30" }); defer testing.allocator.free(fib_text); try testing.expectEqualStrings("832040", fib_text); @@ -2012,7 +2012,7 @@ test "provider: walk/list/stat/open/read/write/create/remove/wstat/clunk and err try testing.expectEqualStrings("fresh", rr.read); try x.h.walkTo(6, &.{"prov"}); try x.h.expectFail(.{ .create = .{ .fid = 6, .name = "new", .perm = 0o644, .mode = cloud9.oread } }, "file already exists"); - const long_name = [_]u8{'n'} ** (max_name + 1); + const long_name: [max_name + 1]u8 = @splat('n'); try x.h.expectFail(.{ .create = .{ .fid = 6, .name = &long_name, .perm = 0o644, .mode = cloud9.oread } }, e_illegal_name); try x.h.expectFail(.{ .create = .{ .fid = 6, .name = "d", .perm = cloud9.dmdir | 0o755, .mode = cloud9.owrite } }, e_perm); const dr = try x.h.ok(.{ .create = .{ .fid = 6, .name = "d", .perm = cloud9.dmdir | 0o755, .mode = cloud9.oread } }); @@ -2162,12 +2162,12 @@ test "msize: below the engine's floor the connection dies; at the floor everythi const st = try y.h.ok(.{ .stat = .{ .fid = 0 } }); try testing.expectEqualStrings("/", st.stat.name); // A full 16-element Rwalk is exactly msize_min. - const w = try y.h.ok(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &([_][]const u8{"."} ** 16) } }); + const w = try y.h.ok(.{ .walk = .{ .fid = 0, .newfid = 1, .names = &@as([16][]const u8, @splat(".")) } }); try testing.expectEqual(@as(u16, 16), w.walk.nwqid); _ = try y.h.ok(.{ .clunk = .{ .fid = 1 } }); // An Rstat that cannot fit is an Rerror, not a dead connection. try y.h.walkTo(2, &.{"prov"}); - const long_name = [_]u8{'n'} ** 180; // Tcreate fits; the Rstat (61 + 180 bytes) does not + const long_name: [180]u8 = @splat('n'); // Tcreate fits; the Rstat (61 + 180 bytes) does not _ = try y.h.ok(.{ .create = .{ .fid = 2, .name = &long_name, .perm = 0o644, .mode = cloud9.oread } }); try y.h.expectFail(.{ .stat = .{ .fid = 2 } }, e_small_msize); _ = try y.h.ok(.{ .remove = .{ .fid = 2 } }); @@ -2484,7 +2484,7 @@ test "a provider read that is not ready parks and is answered on a later step" { _ = try x.h.client.submit(.{ .read = .{ .fid = 1, .offset = 0, .count = 100 } }); _ = try x.h.pump(); try testing.expectEqual(@as(?cloud9.Client.Done, null), x.h.client.take()); - try x.h.expectFail(.{ .read = .{ .fid = 1, .offset = 0, .count = 100 } }, fs.e_again); + try x.h.expectFail(.{ .read = .{ .fid = 1, .offset = 0, .count = 100 } }, TS.Engine.e_waiting); // ready: the next step answers both, oldest first, with the original tags x.prov.park = false; _ = try x.h.pump(); diff --git a/9proc/src/linux/debug.zig b/9proc/src/linux/debug.zig index a344380..8bbee52 100644 --- a/9proc/src/linux/debug.zig +++ b/9proc/src/linux/debug.zig @@ -163,7 +163,7 @@ pub const Debug = struct { max_paused: u8, capture: CaptureSlot = .{}, - paused: [max_paused_cap]PauseSlot = [_]PauseSlot{.{}} ** max_paused_cap, + paused: [max_paused_cap]PauseSlot = @splat(.{}), old_capture_action: linux.Sigaction = undefined, old_trap_action: linux.Sigaction = undefined, @@ -187,7 +187,7 @@ pub const Debug = struct { d.* = .{ .io = opts.io, .text_buf = opts.text_buf, - .capture_signal = @enumFromInt(opts.capture_signal), + .capture_signal = @fromBackingInt(@intCast(opts.capture_signal)), .capture_timeout_ns = opts.capture_timeout_ns, .max_paused = opts.max_paused, }; @@ -249,7 +249,7 @@ pub const Debug = struct { pub fn threadExists(d: *Debug, tid: u32) bool { _ = d; var path_buf: [64]u8 = undefined; - const path = std.fmt.bufPrintZ(&path_buf, "/proc/self/task/{d}/comm", .{tid}) catch return false; + const path = std.fmt.bufPrintSentinel(&path_buf, "/proc/self/task/{d}/comm", .{tid}, 0) catch return false; var buf: [32]u8 = undefined; _ = readFile(path, &buf) catch return false; return true; @@ -259,7 +259,7 @@ pub const Debug = struct { pub fn threadName(d: *Debug, tid: u32, w: *Writer) Error!void { _ = d; var path_buf: [64]u8 = undefined; - const path = std.fmt.bufPrintZ(&path_buf, "/proc/self/task/{d}/comm", .{tid}) catch return error.Unexpected; + const path = std.fmt.bufPrintSentinel(&path_buf, "/proc/self/task/{d}/comm", .{tid}, 0) catch return error.Unexpected; var buf: [64]u8 = undefined; const text = readFile(path, &buf) catch |err| switch (err) { error.NotFound => return error.NoThread, @@ -273,7 +273,7 @@ pub const Debug = struct { pub fn threadStat(d: *Debug, tid: u32, w: *Writer) Error!void { _ = d; var path_buf: [64]u8 = undefined; - const path = std.fmt.bufPrintZ(&path_buf, "/proc/self/task/{d}/stat", .{tid}) catch return error.Unexpected; + const path = std.fmt.bufPrintSentinel(&path_buf, "/proc/self/task/{d}/stat", .{tid}, 0) catch return error.Unexpected; var buf: [1024]u8 = undefined; const text = readFile(path, &buf) catch |err| switch (err) { error.NotFound => return error.NoThread, @@ -924,8 +924,8 @@ fn writeHexLines(base: usize, bytes: []const u8, w: *Writer) Error!void { fn writeRegs(ctx: *const Native, w: *Writer) Error!void { if (comptime arch == .x86_64) { - inline for (@typeInfo(Native.Gpr).@"enum".fields) |f| { - w.print("{s} 0x{x}\n", .{ f.name, ctx.gprs.get(@field(Native.Gpr, f.name)) }) catch return error.WriteFailed; + inline for (@typeInfo(Native.GprName).@"enum".field_names) |name| { + w.print("{s} 0x{x}\n", .{ name, ctx.gprs.get(@field(Native.GprName, name)) }) catch return error.WriteFailed; } w.print("pc 0x{x}\nsp 0x{x}\nfp 0x{x}\n", .{ ctx.gprs.get(.rip), ctx.gprs.get(.rsp), ctx.gprs.get(.rbp), @@ -1369,7 +1369,7 @@ test "panic record path" { // A long message is truncated, not overflowed. resetPanicRecord(); - const long = [_]u8{'x'} ** (panic_msg_cap + 100); + const long: [panic_msg_cap + 100]u8 = @splat('x'); try testing.expect(recordPanic(&long, null)); out.clearRetainingCapacity(); try d.panicMessage(&out.writer); diff --git a/9proc/src/linux/probe.zig b/9proc/src/linux/probe.zig index 00c256e..f9cb585 100644 --- a/9proc/src/linux/probe.zig +++ b/9proc/src/linux/probe.zig @@ -141,7 +141,7 @@ pub fn Probe(comptime Srv: type) type { refused: u64 = 0, stopping: std.atomic.Value(bool) = .init(false), /// Slots whose request is being handled (excluded from nested servicing and eviction). - serving: std.StaticBitSet(256) = .initEmpty(), + serving: std.StaticBitSet(256) = .empty, /// Current `sleepServing` nesting depth. nested: u8 = 0, debug_ready: bool = false, @@ -569,7 +569,7 @@ pub fn Probe(comptime Srv: type) type { const rc = linux.statx(linux.AT.FDCWD, path, 0, .{ .TYPE = true, .INO = true }, &stx); const s: isize = @bitCast(rc); if (s == 0) return stx; - const noent: isize = @intCast(@intFromEnum(linux.E.NOENT)); + const noent: isize = @intCast(@backingInt(linux.E.NOENT)); if (s == -noent) return null; return error.StatFailed; } @@ -616,7 +616,7 @@ pub fn parseIpv4(text: []const u8) ?linux.sockaddr.in { var it = std.mem.splitScalar(u8, text[0..colon], '.'); for (&octets) |*o| o.* = std.fmt.parseInt(u8, it.next() orelse return null, 10) catch return null; if (it.next() != null) return null; - return .{ .port = std.mem.nativeToBig(u16, port), .addr = @bitCast(octets) }; + return .{ .port = std.mem.nativeToBig(u16, port), .addr = std.mem.bytesToValue(u32, &octets) }; } /// Names the calling thread (comm, at most 15 bytes) via prctl. @@ -624,7 +624,7 @@ pub fn setThreadName(name: []const u8) void { var buf: [16]u8 = @splat(0); const n = @min(name.len, 15); @memcpy(buf[0..n], name[0..n]); - _ = linux.prctl(@intFromEnum(linux.PR.SET_NAME), @intFromPtr(&buf), 0, 0, 0); + _ = linux.prctl(@backingInt(linux.PR.SET_NAME), @intFromPtr(&buf), 0, 0, 0); } pub fn sleepMs(ms: u64) void { @@ -863,7 +863,7 @@ test "probe: single pre-connected client mode ends when the client hangs up" { test "parseIpv4 and sleepServing off the probe thread" { const sa = parseIpv4("127.0.0.1:564").?; try testing.expectEqual(std.mem.nativeToBig(u16, 564), sa.port); - try testing.expectEqual(@as(u32, @bitCast([4]u8{ 127, 0, 0, 1 })), sa.addr); + try testing.expectEqual(std.mem.bytesToValue(u32, &[4]u8{ 127, 0, 0, 1 }), sa.addr); try testing.expect(parseIpv4("localhost:1") == null); try testing.expect(parseIpv4("1.2.3:1") == null); try testing.expect(parseIpv4("1.2.3.4") == null); @@ -871,7 +871,7 @@ test "parseIpv4 and sleepServing off the probe thread" { const t0 = monotonicMs(); var probe: TP = undefined; probe.thread_tid = .init(0); - probe.serving = .initEmpty(); + probe.serving = .empty; probe.nested = 0; probe.sleepServing(20); try testing.expect(monotonicMs() - t0 >= 20); diff --git a/9proc/src/linux/runtime.zig b/9proc/src/linux/runtime.zig index 503d6c2..c7a7366 100644 --- a/9proc/src/linux/runtime.zig +++ b/9proc/src/linux/runtime.zig @@ -86,5 +86,5 @@ test "runtime generators read Info through the context" { w = .fixed(&buf); try F.pid(&ctx, &w); try std.testing.expectEqual(linux.getpid(), try std.fmt.parseInt(i32, w.buffered(), 10)); - try std.testing.expectEqual(@as(usize, 7), @typeInfo(F).@"struct".decls.len); + try std.testing.expectEqual(@as(usize, 7), @typeInfo(F).@"struct".decl_names.len); } diff --git a/9proc/src/vars.zig b/9proc/src/vars.zig index 20cadfc..90a5ee4 100644 --- a/9proc/src/vars.zig +++ b/9proc/src/vars.zig @@ -100,8 +100,9 @@ fn hasFields(comptime T: type, depth: u8) bool { fn fieldCount(comptime T: type) usize { var n: usize = 0; - for (@typeInfo(T).@"struct".fields) |f| { - if (!f.is_comptime and @sizeOf(f.type) != 0) n += 1; + const info = @typeInfo(T).@"struct"; + for (info.field_types, info.field_attrs) |F, attrs| { + if (!attrs.@"comptime" and @sizeOf(F) != 0) n += 1; } return n; } @@ -110,9 +111,10 @@ fn countNodes(comptime T: type, depth: u8) usize { var n: usize = 6; // dir + value, type, size, addr, raw if (hasFields(T, depth)) { n += 1; // f - for (@typeInfo(T).@"struct".fields) |f| { - if (f.is_comptime or @sizeOf(f.type) == 0) continue; - n += countNodes(f.type, depth + 1); + const info = @typeInfo(T).@"struct"; + for (info.field_types, info.field_attrs) |F, attrs| { + if (attrs.@"comptime" or @sizeOf(F) == 0) continue; + n += countNodes(F, depth + 1); } } return n; @@ -137,9 +139,10 @@ fn fill(nodes: []Node, next: *usize, idx: usize, comptime T: type, name: []const next.* += nf; nodes[fdir] = .{ .name = "f", .kind = .fields, .parent = me, .first = @intCast(ffirst), .count = @intCast(nf), .offset = offset, .size = @sizeOf(T) }; var i: usize = 0; - for (@typeInfo(T).@"struct".fields) |f| { - if (f.is_comptime or @sizeOf(f.type) == 0) continue; - fill(nodes, next, ffirst + i, f.type, f.name, offset + @offsetOf(T, f.name), depth + 1, fdir); + const info = @typeInfo(T).@"struct"; + for (info.field_names, info.field_types, info.field_attrs) |field_name, F, attrs| { + if (attrs.@"comptime" or @sizeOf(F) == 0) continue; + fill(nodes, next, ffirst + i, F, field_name, offset + @offsetOf(T, field_name), depth + 1, fdir); i += 1; } } @@ -198,7 +201,7 @@ pub fn render(ptr: anytype, w: *Writer, depth: usize) Writer.Error!void { fn isPlainStruct(comptime T: type) bool { return switch (@typeInfo(T)) { - .@"struct" => |s| !s.is_tuple and s.fields.len > 0, + .@"struct" => |s| !s.is_tuple and s.field_names.len > 0, else => false, }; } @@ -210,25 +213,26 @@ fn renderStruct(comptime T: type, ptr: *const T, w: *Writer, depth: usize, inden try w.writeAll("…\n"); return; } - const packed_layout = @typeInfo(T).@"struct".layout == .@"packed"; - inline for (@typeInfo(T).@"struct".fields) |f| { + const info = @typeInfo(T).@"struct"; + const packed_layout = info.layout == .@"packed"; + inline for (info.field_names, info.field_types, info.field_attrs) |field_name, F, attrs| { try w.splatByteAll(' ', indent); - try w.writeAll(f.name); + try w.writeAll(field_name); try w.writeByte(':'); - if (comptime f.is_comptime) { + if (comptime attrs.@"comptime") { try w.writeAll(" (comptime)\n"); } else if (comptime packed_layout) { // Fields of a packed struct have no byte address: render a copy. - const v = @field(ptr.*, f.name); + const v = @field(ptr.*, field_name); try w.writeByte(' '); - try renderValue(f.type, &v, w, depth - 1); + try renderValue(F, &v, w, depth - 1); try w.writeByte('\n'); - } else if (comptime isPlainStruct(f.type)) { + } else if (comptime isPlainStruct(F)) { try w.writeByte('\n'); - try renderStruct(f.type, &@field(ptr.*, f.name), w, depth - 1, indent + 2); + try renderStruct(F, &@field(ptr.*, field_name), w, depth - 1, indent + 2); } else { try w.writeByte(' '); - try renderValue(f.type, &@field(ptr.*, f.name), w, depth - 1); + try renderValue(F, &@field(ptr.*, field_name), w, depth - 1); try w.writeByte('\n'); } } @@ -255,15 +259,15 @@ fn renderValue(comptime T: type, ptr: *const T, w: *Writer, depth: usize) Writer // value is a safety panic, and the value is caller memory we do not // control. A load through the tag type would truncate to its bit // width (a u2 tag in a byte), so the full storage width is read. - if (@sizeOf(T) == 0) return w.writeAll(e.fields[0].name); - const Raw = std.meta.Int(.unsigned, @sizeOf(T) * 8); + if (@sizeOf(T) == 0) return w.writeAll(e.field_names[0]); + const Raw = @Int(.unsigned, @sizeOf(T) * 8); const raw = @as(*align(@alignOf(T)) const Raw, @ptrCast(ptr)).*; - const TagU = std.meta.Int(.unsigned, @bitSizeOf(e.tag_type)); + const TagU = @Int(.unsigned, @bitSizeOf(e.tag_type)); const padding: Raw = if (@bitSizeOf(TagU) == @bitSizeOf(Raw)) 0 else ~@as(Raw, std.math.maxInt(TagU)); if (raw & padding == 0) { const low: TagU = @truncate(raw); - inline for (e.fields) |f| { - if (low == @as(TagU, @bitCast(@as(e.tag_type, f.value)))) return w.writeAll(f.name); + inline for (e.field_names, e.field_values) |field_name, value| { + if (low == @as(TagU, @bitCast(@as(e.tag_type, value)))) return w.writeAll(field_name); } } try w.print("{d}", .{raw}); @@ -306,24 +310,24 @@ fn renderValue(comptime T: type, ptr: *const T, w: *Writer, depth: usize) Writer try w.writeAll("…"); return; } - if (s.fields.len == 0) { + if (s.field_names.len == 0) { try w.writeAll("{}"); return; } try w.writeAll("{ "); - inline for (s.fields, 0..) |f, i| { + inline for (s.field_names, s.field_types, s.field_attrs, 0..) |field_name, F, attrs, i| { if (i != 0) try w.writeAll(", "); if (!s.is_tuple) { - try w.writeAll(f.name); + try w.writeAll(field_name); try w.writeAll(": "); } - if (comptime f.is_comptime) { + if (comptime attrs.@"comptime") { try w.writeAll("(comptime)"); } else if (comptime s.layout == .@"packed") { - const v = @field(ptr.*, f.name); - try renderValue(f.type, &v, w, depth - 1); + const v = @field(ptr.*, field_name); + try renderValue(F, &v, w, depth - 1); } else { - try renderValue(f.type, &@field(ptr.*, f.name), w, depth - 1); + try renderValue(F, &@field(ptr.*, field_name), w, depth - 1); } } try w.writeAll(" }"); @@ -338,13 +342,13 @@ fn renderValue(comptime T: type, ptr: *const T, w: *Writer, depth: usize) Writer return; } // A switch on a corrupt tag is a safety panic: match the integer first. - const raw = @intFromEnum(@as(Tag, ptr.*)); - inline for (u.fields) |f| { - if (raw == @intFromEnum(@field(Tag, f.name))) { - try w.writeAll(f.name); - if (f.type != void) { + const raw = @backingInt(@as(Tag, ptr.*)); + inline for (u.field_names, u.field_types) |field_name, F| { + if (raw == @backingInt(@field(Tag, field_name))) { + try w.writeAll(field_name); + if (F != void) { try w.writeAll(": "); - try renderValue(f.type, &@field(ptr.*, f.name), w, depth - 1); + try renderValue(F, &@field(ptr.*, field_name), w, depth - 1); } return; } @@ -421,9 +425,9 @@ pub fn set(ptr: anytype, text: []const u8) SetError!void { .@"enum" => |e| { if (std.meta.stringToEnum(T, s)) |v| { ptr.* = v; - } else if (!e.is_exhaustive) { + } else if (e.mode != .exhaustive) { const raw = std.fmt.parseInt(e.tag_type, s, 0) catch return error.Invalid; - ptr.* = @enumFromInt(raw); + ptr.* = @fromBackingInt(@intCast(raw)); } else return error.Invalid; }, else => return error.Unsupported, @@ -466,7 +470,7 @@ test "render scalars, strings, pointers, optionals, enums, arrays" { const e: E = .green; try testing.expectEqualStrings("green", try renderToBuf(&buf, &e)); const NE = enum(u8) { a, _ }; - const ne: NE = @enumFromInt(9); + const ne: NE = @fromBackingInt(@intCast(9)); try testing.expectEqualStrings("9", try renderToBuf(&buf, &ne)); const arr = [_]u16{ 1, 2, 3 }; try testing.expectEqualStrings("[1, 2, 3]", try renderToBuf(&buf, &arr)); @@ -508,7 +512,7 @@ test "render structs multi-line with nested indentation and depth limit" { } test "long strings and arrays are truncated" { - const long = [_]u8{'x'} ** 300; + const long: [300]u8 = @splat('x'); var buf: [1024]u8 = undefined; const s: []const u8 = &long; const out = try renderToBuf(&buf, &s); @@ -802,7 +806,7 @@ test "set rejects hostile input without partial writes" { const NE = enum(u8) { a, _ }; var ne: NE = .a; try set(&ne, "200"); - try testing.expectEqual(@as(u8, 200), @intFromEnum(ne)); + try testing.expectEqual(@as(u8, 200), @backingInt(ne)); try testing.expectError(error.Invalid, set(&ne, "256")); try testing.expectError(error.Invalid, set(&ne, "-1")); try set(&ne, "a"); |
