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 {...@@ -1134,24 +1134,14 @@ pub fn Future(Result: type) type {
1134 /// Idempotent.1134 /// Idempotent.
1135 pub fn cancel(f: *@This(), io: Io) Result {1135 pub fn cancel(f: *@This(), io: Io) Result {
1136 const any_future = f.any_future orelse return f.result;1136 const any_future = f.any_future orelse return f.result;
1137 io.vtable.cancel(1137 io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
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 );
1143 f.any_future = null;1138 f.any_future = null;
1144 return f.result;1139 return f.result;
1145 }1140 }
11461141
1147 pub fn await(f: *@This(), io: Io) Result {1142 pub fn await(f: *@This(), io: Io) Result {
1148 const any_future = f.any_future orelse return f.result;1143 const any_future = f.any_future orelse return f.result;
1149 io.vtable.await(1144 io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
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 );
1155 f.any_future = null;1145 f.any_future = null;
1156 return f.result;1146 return f.result;
1157 }1147 }
...@@ -1515,9 +1505,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio...@@ -1515,9 +1505,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio
1515 var future: Future(Result) = undefined;1505 var future: Future(Result) = undefined;
1516 future.any_future = io.vtable.async(1506 future.any_future = io.vtable.async(
1517 io.userdata,1507 io.userdata,
1518 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug1508 @ptrCast((&future.result)[0..1]),
1519 .of(Result),1509 .of(Result),
1520 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug1510 @ptrCast((&args)[0..1]),
1521 .of(Args),1511 .of(Args),
1522 TypeErased.start,1512 TypeErased.start,
1523 );1513 );
...@@ -1534,12 +1524,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))...@@ -1534,12 +1524,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))
1534 @call(.auto, function, args_casted.*);1524 @call(.auto, function, args_casted.*);
1535 }1525 }
1536 };1526 };
1537 io.vtable.go(1527 io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start);
1538 io.userdata,
1539 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
1540 .of(Args),
1541 TypeErased.start,
1542 );
1543}1528}
15441529
1545pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {1530pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {