Fun with Pin UB

So, let's say you have a clean and nice function like this. use std::pin::Pin; async fn foo () -> u32 { let mut x = 1 ; tokio::time::sleep(std::time::Duration::from_secs( 0 )).await; x += 1 ; x } #[ tokio :: main ] async fn main () { let mut x = foo (); let a = unsafe { Pin::new_unchecked( & mut x) }; println!( " {} " , a.await); } Everything looks nice except for that Pin::new_unchecked which we…