std: remove meta.trait

In general, I don't like the idea of std.meta.trait, and so I am
providing some guidance by deleting the entire namespace from the
standard library and compiler codebase.

My main criticism is that it's overcomplicated machinery that bloats
compile times and is ultimately unnecessary given the existence of Zig's
strong type system and reference traces.

Users who want this can create a third party package that provides this
functionality.

closes #18051
This commit is contained in:
Andrew Kelley
2023-11-21 15:23:44 -07:00
parent 994e191643
commit d5e21a4f1a
23 changed files with 389 additions and 974 deletions

View File

@@ -451,14 +451,14 @@ pub fn WriteStream(
}
},
.Enum, .EnumLiteral => {
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
if (std.meta.hasFn(T, "jsonStringify")) {
return value.jsonStringify(self);
}
return self.stringValue(@tagName(value));
},
.Union => {
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
if (std.meta.hasFn(T, "jsonStringify")) {
return value.jsonStringify(self);
}
@@ -487,7 +487,7 @@ pub fn WriteStream(
}
},
.Struct => |S| {
if (comptime std.meta.trait.hasFn("jsonStringify")(T)) {
if (std.meta.hasFn(T, "jsonStringify")) {
return value.jsonStringify(self);
}