std.Io: remove @ptrCast workarounds

thanks to d53cc5e5b2
This commit is contained in:
Andrew Kelley 2025-04-04 15:02:15 -07:00
parent 0c1e102e97
commit 61c38d77c6

View file

@ -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 {