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-07-20 10:38:39-07:00
log3178cf07f297a1a5f3e852a4f33a14dd9463ba07
tree36cab0c6ae1ca7b42c51d71373c0cfba2857de53
parent13e30c4fd29aa610b1cd0d4622bffc2b2948898f

std.Io: remove `@ptrCast` workarounds

thanks to d53cc5e5b2ac51793ea19a847d8cee409af1dee3

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

lib/std/Io.zig+5-20
......@@ -1134,24 +1134,14 @@ pub fn Future(Result: type) type {
11341134 /// Idempotent.
11351135 pub fn cancel(f: *@This(), io: Io) Result {
11361136 const any_future = f.any_future orelse return f.result;
1137 io.vtable.cancel(
1138 io.userdata,
1139 any_future,
1140 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
1141 .of(Result),
1142 );
1137 io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
11431138 f.any_future = null;
11441139 return f.result;
11451140 }
11461141
11471142 pub fn await(f: *@This(), io: Io) Result {
11481143 const any_future = f.any_future orelse return f.result;
1149 io.vtable.await(
1150 io.userdata,
1151 any_future,
1152 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&f.result)[0..1]), // work around compiler bug
1153 .of(Result),
1154 );
1144 io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
11551145 f.any_future = null;
11561146 return f.result;
11571147 }
......@@ -1515,9 +1505,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio
15151505 var future: Future(Result) = undefined;
15161506 future.any_future = io.vtable.async(
15171507 io.userdata,
1518 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug
1508 @ptrCast((&future.result)[0..1]),
15191509 .of(Result),
1520 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
1510 @ptrCast((&args)[0..1]),
15211511 .of(Args),
15221512 TypeErased.start,
15231513 );
......@@ -1534,12 +1524,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))
15341524 @call(.auto, function, args_casted.*);
15351525 }
15361526 };
1537 io.vtable.go(
1538 io.userdata,
1539 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
1540 .of(Args),
1541 TypeErased.start,
1542 );
1527 io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start);
15431528}
15441529
15451530pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {