authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-04-04 15:02:15-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-10-02 16:30:59-07:00
log61c38d77c66fe707bba41e43e59f2c727cbe7bb7
tree4ab2aab0baed9f000ce65669aacf3912e2f433b6
parent0c1e102e975f062fdb7b513256598a0f9846a543

std.Io: remove `@ptrCast` workarounds

thanks to d53cc5e5b2ac51793ea19a847d8cee409af1dee3

1 files changed, 5 insertions(+), 20 deletions(-)

lib/std/Io.zig+5-20
......@@ -781,24 +781,14 @@ pub fn Future(Result: type) type {
781781 /// Idempotent.
782782 pub fn cancel(f: *@This(), io: Io) Result {
783783 const any_future = f.any_future orelse return f.result;
784 io.vtable.cancel(
785 io.userdata,
786 any_future,
787 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
788 .of(Result),
789 );
784 io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
790785 f.any_future = null;
791786 return f.result;
792787 }
793788
794789 pub fn await(f: *@This(), io: Io) Result {
795790 const any_future = f.any_future orelse return f.result;
796 io.vtable.await(
797 io.userdata,
798 any_future,
799 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
800 .of(Result),
801 );
791 io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
802792 f.any_future = null;
803793 return f.result;
804794 }
......@@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio
11621152 var future: Future(Result) = undefined;
11631153 future.any_future = io.vtable.async(
11641154 io.userdata,
1165 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug
1155 @ptrCast((&future.result)[0..1]),
11661156 .of(Result),
1167 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
1157 @ptrCast((&args)[0..1]),
11681158 .of(Args),
11691159 TypeErased.start,
11701160 );
......@@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))
11811171 @call(.auto, function, args_casted.*);
11821172 }
11831173 };
1184 io.vtable.go(
1185 io.userdata,
1186 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
1187 .of(Args),
1188 TypeErased.start,
1189 );
1174 io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start);
11901175}
11911176
11921177pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {