Open nurmohammed840 opened 1 month ago
There is no place to store the vtable for Arc<dyn Wake>
inside the RawWaker
. The vtable field of RawWaker
is already taken by a vtable whose contents are statically known for any given type passed to impl From<Arc<W>> for Waker
: https://github.com/rust-lang/rust/blob/1e4f10ba6476e48a42a79b9f846a2d9366525b9e/library/alloc/src/task.rs#L173-L176 The comment above this function explains a bit why this is the case: https://github.com/rust-lang/rust/blob/1e4f10ba6476e48a42a79b9f846a2d9366525b9e/library/alloc/src/task.rs#L130-L134 I don't know if this is just a precaution thing or if it actually matters for safety. In any case relaxing the ?Sized
bound would also technically allow Arc<[T]>
to be converted to a Waker
, for which there is no valid vtable we can create without allocating memory.
I don't know it this issue is duplicate.
Consider this code snippet
Currently this code doesn't work, Because
Waker::from
cannot be used withArc<dyn Wake>
https://github.com/rust-lang/rust/blob/1e4f10ba6476e48a42a79b9f846a2d9366525b9e/library/alloc/src/task.rs#L109
It would be ideal if
Waker::from
could supportW: ?Sized
objects by relaxing theSized
bound onW
.