aboutsummaryrefslogtreecommitdiff
path: root/lib/std/meta.zig
diff options
context:
space:
mode:
authorMeghan <hello@nektro.net>2023-05-05 00:17:18 -0700
committerVeikka Tuominen <git@vexu.eu>2023-05-10 16:00:14 +0300
commit0972196f4d9e583a1086a5cba41bf7918b1962c0 (patch)
tree4806b2247b3817ba152640e3c3ca87fc3163c7f9 /lib/std/meta.zig
parent11fabc4cbee7addbdb86d6ba0297abe8274bbbb4 (diff)
downloadzig-0972196f4d9e583a1086a5cba41bf7918b1962c0.tar.gz
zig-0972196f4d9e583a1086a5cba41bf7918b1962c0.zip
std.meta: remove tagName
not used by Zig itself anywhere
Diffstat (limited to 'lib/std/meta.zig')
-rw-r--r--lib/std/meta.zig43
1 files changed, 1 insertions, 42 deletions
diff --git a/lib/std/meta.zig b/lib/std/meta.zig
index 7be3b71347..cd83061d53 100644
--- a/lib/std/meta.zig
+++ b/lib/std/meta.zig
@@ -14,48 +14,7 @@ test {
_ = TrailerFlags;
}
-pub fn tagName(v: anytype) []const u8 {
- const T = @TypeOf(v);
- switch (@typeInfo(T)) {
- .ErrorSet => return @errorName(v),
- else => return @tagName(v),
- }
-}
-
-test "std.meta.tagName" {
- const E1 = enum {
- A,
- B,
- };
- const E2 = enum(u8) {
- C = 33,
- D,
- };
- const U1 = union(enum) {
- G: u8,
- H: u16,
- };
- const U2 = union(E2) {
- C: u8,
- D: u16,
- };
-
- var u1g = U1{ .G = 0 };
- var u1h = U1{ .H = 0 };
- var u2a = U2{ .C = 0 };
- var u2b = U2{ .D = 0 };
-
- try testing.expect(mem.eql(u8, tagName(E1.A), "A"));
- try testing.expect(mem.eql(u8, tagName(E1.B), "B"));
- try testing.expect(mem.eql(u8, tagName(E2.C), "C"));
- try testing.expect(mem.eql(u8, tagName(E2.D), "D"));
- try testing.expect(mem.eql(u8, tagName(error.E), "E"));
- try testing.expect(mem.eql(u8, tagName(error.F), "F"));
- try testing.expect(mem.eql(u8, tagName(u1g), "G"));
- try testing.expect(mem.eql(u8, tagName(u1h), "H"));
- try testing.expect(mem.eql(u8, tagName(u2a), "C"));
- try testing.expect(mem.eql(u8, tagName(u2b), "D"));
-}
+pub const tagName = @compileError("deprecated; use @tagName or @errorName directly");
/// Given an enum or tagged union, returns true if the comptime-supplied
/// string matches the name of the tag value. This match process should