From 61c38d77c66fe707bba41e43e59f2c727cbe7bb7 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 4 Apr 2025 15:02:15 -0700 Subject: [PATCH] std.Io: remove `@ptrCast` workarounds thanks to d53cc5e5b2ac51793ea19a847d8cee409af1dee3 --- lib/std/Io.zig | 25 +++++-------------------- 1 file changed, 5 insertions(+), 20 deletions(-) diff --git a/lib/std/Io.zig b/lib/std/Io.zig index f9d99525e9..dddd86ecff 100644 --- a/lib/std/Io.zig +++ b/lib/std/Io.zig @@ -781,24 +781,14 @@ pub fn Future(Result: type) type { /// Idempotent. pub fn cancel(f: *@This(), io: Io) Result { const any_future = f.any_future orelse return f.result; - io.vtable.cancel( - io.userdata, - any_future, - if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug - .of(Result), - ); + io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result)); f.any_future = null; return f.result; } pub fn await(f: *@This(), io: Io) Result { const any_future = f.any_future orelse return f.result; - io.vtable.await( - io.userdata, - any_future, - if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug - .of(Result), - ); + io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result)); f.any_future = null; return f.result; } @@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio var future: Future(Result) = undefined; future.any_future = io.vtable.async( io.userdata, - if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug + @ptrCast((&future.result)[0..1]), .of(Result), - if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug + @ptrCast((&args)[0..1]), .of(Args), TypeErased.start, ); @@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function)) @call(.auto, function, args_casted.*); } }; - io.vtable.go( - io.userdata, - if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug - .of(Args), - TypeErased.start, - ); + io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start); } pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {