Commit 750b1431bf

Andrew Kelley <andrew@ziglang.org>
2025-10-09 07:37:39
std: fix some Io compilation errors
1 parent eadfefa
Changed files (6)
lib/std/fs/test.zig
@@ -1928,7 +1928,7 @@ test "'.' and '..' in fs.Dir functions" {
             try ctx.dir.writeFile(.{ .sub_path = update_path, .data = "something" });
             var dir = ctx.dir.adaptToNewApi();
             const prev_status = try dir.updateFile(io, file_path, dir, update_path, .{});
-            try testing.expectEqual(fs.Dir.PrevStatus.stale, prev_status);
+            try testing.expectEqual(Io.Dir.PrevStatus.stale, prev_status);
 
             try ctx.dir.deleteDir(subdir_path);
         }
lib/std/http/Client.zig
@@ -300,7 +300,7 @@ pub const Connection = struct {
             remote_host: HostName,
             port: u16,
             stream: Io.net.Stream,
-        ) error{ OutOfMemory, TlsInitializationFailed }!*Tls {
+        ) !*Tls {
             const io = client.io;
             const gpa = client.allocator;
             const alloc_len = allocLen(client, remote_host.bytes.len);
@@ -320,7 +320,7 @@ pub const Connection = struct {
             const tls: *Tls = @ptrCast(base);
             var random_buffer: [176]u8 = undefined;
             std.crypto.random.bytes(&random_buffer);
-            const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |_| return error.TlsInitializationFailed;
+            const now_ts = if (Io.Clock.real.now(io)) |ts| ts.toSeconds() else |err| return err;
             tls.* = .{
                 .connection = .{
                     .client = client,
@@ -349,7 +349,11 @@ pub const Connection = struct {
                         // the content length which is used to detect truncation attacks.
                         .allow_truncation_attacks = true,
                     },
-                ) catch return error.TlsInitializationFailed,
+                ) catch |err| switch (err) {
+                    error.WriteFailed => return tls.connection.stream_writer.err.?,
+                    error.ReadFailed => return tls.connection.stream_reader.err.?,
+                    else => |e| return e,
+                },
             };
             return tls;
         }
@@ -1446,7 +1450,8 @@ pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcp
             const tc = Connection.Tls.create(client, proxied_host, proxied_port, stream) catch |err| switch (err) {
                 error.OutOfMemory => |e| return e,
                 error.Unexpected => |e| return e,
-                error.UnsupportedClock => return error.TlsInitializationFailed,
+                error.Canceled => |e| return e,
+                else => return error.TlsInitializationFailed,
             };
             client.connection_pool.addUsed(&tc.connection);
             return &tc.connection;
lib/std/Io/Dir.zig
@@ -263,6 +263,6 @@ pub const StatPathError = File.OpenError || File.StatError;
 /// * On Windows, `sub_path` should be encoded as [WTF-8](https://simonsapin.github.io/wtf-8/).
 /// * On WASI, `sub_path` should be encoded as valid UTF-8.
 /// * On other platforms, `sub_path` is an opaque sequence of bytes with no particular encoding.
-pub fn statPath(dir: Dir, io: Io, sub_path: []const u8) StatPathError!File.Stat {
+pub fn statPath(dir: Dir, io: Io, sub_path: []const u8) StatPathError!Stat {
     return io.vtable.dirStatPath(io.userdata, dir, sub_path);
 }
lib/std/os/linux/IoUring.zig
@@ -2459,12 +2459,12 @@ test "timeout (after a relative time)" {
     const margin = 5;
     const ts: linux.kernel_timespec = .{ .sec = 0, .nsec = ms * 1000000 };
 
-    const started = try std.Io.Timestamp.now(io, .awake);
+    const started = try std.Io.Clock.awake.now(io);
     const sqe = try ring.timeout(0x55555555, &ts, 0, 0);
     try testing.expectEqual(linux.IORING_OP.TIMEOUT, sqe.opcode);
     try testing.expectEqual(@as(u32, 1), try ring.submit());
     const cqe = try ring.copy_cqe();
-    const stopped = try std.Io.Timestamp.now(io, .awake);
+    const stopped = try std.Io.Clock.awake.now(io);
 
     try testing.expectEqual(linux.io_uring_cqe{
         .user_data = 0x55555555,
lib/std/posix.zig
@@ -357,6 +357,7 @@ pub const FChmodAtError = FChmodError || error{
     ProcessFdQuotaExceeded,
     /// The procfs fallback was used but the system exceeded it open file limit.
     SystemFdQuotaExceeded,
+    Canceled,
 };
 
 /// Changes the `mode` of `path` relative to the directory referred to by
@@ -487,6 +488,7 @@ fn fchmodat2(dirfd: fd_t, path: []const u8, mode: mode_t, flags: u32) FChmodAtEr
         error.NameTooLong => unreachable,
         error.FileNotFound => unreachable,
         error.InvalidUtf8 => unreachable,
+        error.Canceled => return error.Canceled,
         else => |e| return e,
     };
     if ((stat.mode & S.IFMT) == S.IFLNK)
lib/std/time.zig
@@ -204,7 +204,7 @@ test Timer {
 
     var timer = try Timer.start();
 
-    try std.Io.Duration.sleep(.fromMilliseconds(10), io);
+    try std.Io.Clock.Duration.sleep(.{ .clock = .awake, .raw = .fromMilliseconds(10) }, io);
     const time_0 = timer.read();
     try testing.expect(time_0 > 0);