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 {...@@ -781,24 +781,14 @@ pub fn Future(Result: type) type {
781 /// Idempotent.781 /// Idempotent.
782 pub fn cancel(f: *@This(), io: Io) Result {782 pub fn cancel(f: *@This(), io: Io) Result {
783 const any_future = f.any_future orelse return f.result;783 const any_future = f.any_future orelse return f.result;
784 io.vtable.cancel(784 io.vtable.cancel(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
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 );
790 f.any_future = null;785 f.any_future = null;
791 return f.result;786 return f.result;
792 }787 }
793788
794 pub fn await(f: *@This(), io: Io) Result {789 pub fn await(f: *@This(), io: Io) Result {
795 const any_future = f.any_future orelse return f.result;790 const any_future = f.any_future orelse return f.result;
796 io.vtable.await(791 io.vtable.await(io.userdata, any_future, @ptrCast((&f.result)[0..1]), .of(Result));
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 );
802 f.any_future = null;792 f.any_future = null;
803 return f.result;793 return f.result;
804 }794 }
...@@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio...@@ -1162,9 +1152,9 @@ pub fn async(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(functio
1162 var future: Future(Result) = undefined;1152 var future: Future(Result) = undefined;
1163 future.any_future = io.vtable.async(1153 future.any_future = io.vtable.async(
1164 io.userdata,1154 io.userdata,
1165 if (@sizeOf(Result) == 0) &.{} else @ptrCast((&future.result)[0..1]), // work around compiler bug1155 @ptrCast((&future.result)[0..1]),
1166 .of(Result),1156 .of(Result),
1167 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug1157 @ptrCast((&args)[0..1]),
1168 .of(Args),1158 .of(Args),
1169 TypeErased.start,1159 TypeErased.start,
1170 );1160 );
...@@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))...@@ -1181,12 +1171,7 @@ pub fn go(io: Io, function: anytype, args: std.meta.ArgsTuple(@TypeOf(function))
1181 @call(.auto, function, args_casted.*);1171 @call(.auto, function, args_casted.*);
1182 }1172 }
1183 };1173 };
1184 io.vtable.go(1174 io.vtable.go(io.userdata, @ptrCast((&args)[0..1]), .of(Args), TypeErased.start);
1185 io.userdata,
1186 if (@sizeOf(Args) == 0) &.{} else @ptrCast((&args)[0..1]), // work around compiler bug
1187 .of(Args),
1188 TypeErased.start,
1189 );
1190}1175}
11911176
1192pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {1177pub fn now(io: Io, clockid: std.posix.clockid_t) ClockGetTimeError!Timestamp {