From 0b52c2e9dcf019c5cff5c422595e9e37bfae235b Mon Sep 17 00:00:00 2001 From: Wooster Date: Mon, 18 Sep 2023 22:35:32 +0200 Subject: [PATCH] std: remove remaining mentions of #425 --- lib/std/c.zig | 1 - lib/std/meta.zig | 1 - lib/std/unicode.zig | 20 ++++---------------- 3 files changed, 4 insertions(+), 18 deletions(-) diff --git a/lib/std/c.zig b/lib/std/c.zig index bbfbc5163373..04631d4e9c73 100644 --- a/lib/std/c.zig +++ b/lib/std/c.zig @@ -14,7 +14,6 @@ pub const Token = tokenizer.Token; pub const Tokenizer = tokenizer.Tokenizer; /// The return type is `type` to force comptime function call execution. -/// TODO: https://github.com/ziglang/zig/issues/425 /// If not linking libc, returns struct{pub const ok = false;} /// If linking musl libc, returns struct{pub const ok = true;} /// If linking gnu libc (glibc), the `ok` value will be true if the target diff --git a/lib/std/meta.zig b/lib/std/meta.zig index b10ecd273155..c6cf8ff6a4e3 100644 --- a/lib/std/meta.zig +++ b/lib/std/meta.zig @@ -1091,7 +1091,6 @@ test "ArgsTuple forwarding" { } } -/// TODO: https://github.com/ziglang/zig/issues/425 pub fn globalOption(comptime name: []const u8, comptime T: type) ?T { if (!@hasDecl(root, name)) return null; diff --git a/lib/std/unicode.zig b/lib/std/unicode.zig index 678e570e1bc6..7118625fe16a 100644 --- a/lib/std/unicode.zig +++ b/lib/std/unicode.zig @@ -238,17 +238,6 @@ pub const Utf8View = struct { return Utf8View{ .bytes = s }; } - /// TODO: https://github.com/ziglang/zig/issues/425 - pub fn initComptime(comptime s: []const u8) Utf8View { - if (comptime init(s)) |r| { - return r; - } else |err| switch (err) { - error.InvalidUtf8 => { - @compileError("invalid utf8"); - }, - } - } - pub fn iterator(s: Utf8View) Utf8Iterator { return Utf8Iterator{ .bytes = s.bytes, @@ -457,7 +446,7 @@ test "utf8 iterator on ascii" { try testUtf8IteratorOnAscii(); } fn testUtf8IteratorOnAscii() !void { - const s = Utf8View.initComptime("abc"); + const s = try Utf8View.init("abc"); var it1 = s.iterator(); try testing.expect(std.mem.eql(u8, "a", it1.nextCodepointSlice().?)); @@ -477,8 +466,7 @@ test "utf8 view bad" { try testUtf8ViewBad(); } fn testUtf8ViewBad() !void { - // Compile-time error. - // const s3 = Utf8View.initComptime("\xfe\xf2"); + try testing.expectError(error.InvalidUtf8, Utf8View.init("\xfe\xf2")); try testing.expectError(error.InvalidUtf8, Utf8View.init("hel\xadlo")); } @@ -487,7 +475,7 @@ test "utf8 view ok" { try testUtf8ViewOk(); } fn testUtf8ViewOk() !void { - const s = Utf8View.initComptime("東京市"); + const s = try Utf8View.init("東京市"); var it1 = s.iterator(); try testing.expect(std.mem.eql(u8, "東", it1.nextCodepointSlice().?)); @@ -598,7 +586,7 @@ test "utf8 iterator peeking" { } fn testUtf8Peeking() !void { - const s = Utf8View.initComptime("noël"); + const s = try Utf8View.init("noël"); var it = s.iterator(); try testing.expect(std.mem.eql(u8, "n", it.nextCodepointSlice().?));