summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/walk.zig46
1 files changed, 3 insertions, 43 deletions
diff --git a/src/walk.zig b/src/walk.zig
index 14e1929e..facc4bd9 100644
--- a/src/walk.zig
+++ b/src/walk.zig
@@ -319,7 +319,6 @@ pub fn hash(comptime T: type, v: *const T, h: *Hasher) void {
if (s.layout == .@"packed") return hashInt(s.backing_integer.?, @bitCast(v.*), h);
if (comptime isList(T))
return hashSlice(@typeInfo(@FieldType(T, "items")).pointer.child, v.items, h);
- if (comptime @hasDecl(T, "KV") and @hasDecl(T, "Hash") and @hasField(T, "metadata")) return hashMap(T, v, h);
// std.atomic.Value: what it holds.
if (comptime @hasField(T, "raw") and s.field_names.len == 1 and @hasDecl(T, "load")) return hash(@FieldType(T, "raw"), &v.raw, h);
// A worker's future is a handle of the host's, never state.
@@ -405,20 +404,6 @@ fn hashSlice(comptime E: type, items: []const E, h: *Hasher) void {
for (items) |*e| hash(E, e, h);
}
-/// A hash map's entries in no order: each one's own digest, summed.
-fn hashMap(comptime T: type, v: *const T, h: *Hasher) void {
- var sum: u64 = 0;
- var it = v.iterator();
- while (it.next()) |entry| {
- var one = Hasher.init(0);
- hash(@TypeOf(entry.key_ptr.*), entry.key_ptr, &one);
- hash(@TypeOf(entry.value_ptr.*), entry.value_ptr, &one);
- sum +%= one.final();
- }
- h.update(std.mem.asBytes(&v.count()));
- h.update(std.mem.asBytes(&sum));
-}
-
/// The value as bytes, the same walk: what the tape carries (src/tape.zig),
/// to a replica of another build too (a window of a terminal's session, a
/// Linux client of a FreeBSD one). Native byte order, which every machine
@@ -795,8 +780,6 @@ fn kindOf(comptime T: type) Kind {
else
.@"struct",
.@"union" => |u| if (u.tag_type == null) @compileError("walk: an untagged union: " ++ @typeName(T)) else .@"union",
- .error_set => .err,
- .error_union => .error_union,
else => @compileError("walk: cannot dump " ++ @typeName(T)),
};
}
@@ -856,7 +839,6 @@ fn children(comptime T: type) []const type {
.one, .slice => &.{Canon(@typeInfo(T).pointer.child)},
.array => &.{Canon(@typeInfo(T).array.child)},
.prefix => &.{T.element},
- .error_union => &.{Canon(@typeInfo(T).error_union.payload)},
.@"struct" => blk: {
var out: []const type = &.{};
for (dumpFields(T)) |name| out = out ++ .{FieldDump(T, name)};
@@ -1150,14 +1132,8 @@ pub fn Dump(comptime roots: []const type) type {
inline else => |*payload| try d.value(@TypeOf(payload.*), payload),
}
},
- .err => try writeName(w, @errorName(v.*)),
- .error_union => if (v.*) |*payload| {
- try w.writeByte(1);
- try d.value(@typeInfo(T).error_union.payload, payload);
- } else |err| {
- try w.writeByte(0);
- try writeName(w, @errorName(err));
- },
+ // Kinds an old dump's table may name (`skip`); no type walked here has them.
+ .err, .error_union => unreachable,
.custom => {
const at = d.out.writer.end;
try w.writeAll(&std.mem.toBytes(@as(u64, 0)));
@@ -1569,16 +1545,7 @@ pub fn Load(comptime roots: []const type) type {
l.note("{s}: no {s} here", .{ l.field, was.name });
return error.Incompatible;
},
- .err => out.* = try l.errorNamed(T),
- .error_union => {
- const P = @typeInfo(T).error_union.payload;
- if ((try l.take(1))[0] != 0) {
- var payload: P = undefined;
- try l.fresh(P, &payload);
- try l.value(P, s.child, &payload);
- out.* = payload;
- } else out.* = try l.errorNamed(@typeInfo(T).error_union.error_set);
- },
+ .err, .error_union => unreachable,
.custom => {
const bytes = try l.take(try l.count());
T.dumpRead(out, l.gpa, bytes) catch |err| {
@@ -1597,13 +1564,6 @@ pub fn Load(comptime roots: []const type) type {
}
}
- fn errorNamed(l: *Self, comptime E: type) DecodeError!E {
- const was = try l.name();
- const names = @typeInfo(E).error_set.error_names orelse @compileError("walk: anyerror cannot be loaded by name: " ++ @typeName(E));
- inline for (names) |field| if (std.mem.eql(u8, was, field)) return @field(E, field);
- return error.Incompatible;
- }
-
/// A reference to a pointer or slice made before, or null for a
/// new one (its length then read).
fn ref(l: *Self) DecodeError!?[]u8 {