Describe the bug
https://github.com/AldaronLau/pasts/blob/675bd309d609111fac52889602e31c9609e7f2ea/src/dyn_future.rs#L21-L22
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).
repro: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b2564e36d16d7b2a8f14f763a9477a85
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.
Describe the bug
https://github.com/AldaronLau/pasts/blob/675bd309d609111fac52889602e31c9609e7f2ea/src/dyn_future.rs#L21-L22
This is
Pin<&mut Type>toPin<Field>projection and is unsound ifdyn Futureis notUnpin(you can movedyn FutureafterDynFuturedropped).repro: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=b2564e36d16d7b2a8f14f763a9477a85
The correct projection is
Pin<&mut Type>toPin<&mut Field>. InDynFuture, it isPin<&mut DynFuture<'_, T>>toPin<&mut &mut dyn Future>, and it needs to adddyn Future: Unpinbounds to convertPin<&mut &mut dyn Future>toPin<&mut dyn Future>.Solution
Change
DynFuturefrom&'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
tokioin the past: tokio-rs/tokio#2612Also, #2, previously reported by @udoprog and already fixed by @AldaronLau, seems to be the same problem as this.