-
Notifications
You must be signed in to change notification settings - Fork 9
Description
Describe the bug
This is Pin<&mut Type>
to Pin<Field>
projection and is unsound if dyn Future
is not Unpin
(you can move dyn Future
after DynFuture
dropped).
The correct projection is Pin<&mut Type>
to Pin<&mut Field>
. In DynFuture
, it is Pin<&mut DynFuture<'_, T>>
to Pin<&mut &mut dyn Future>
, and it needs to add dyn Future: Unpin
bounds to convert Pin<&mut &mut dyn Future>
to Pin<&mut dyn Future>
.
Solution
Change DynFuture
from &'a mut dyn Future<Output = T>
to &'a mut (dyn Future<Output = T> + Unpin)
.
https://github.com/AldaronLau/pasts/blob/675bd309d609111fac52889602e31c9609e7f2ea/src/dyn_future.rs#L14
Additional context
I have fixed a similar bug on tokio
in the past: tokio-rs/tokio#2612
Also, #2, previously reported by @udoprog and already fixed by @AldaronLau, seems to be the same problem as this.