I'm trying to understand why the Futures::poll method uses Pin for the self argument.
Is there a blog or other document put out by the team that worked on async back in 2018 and 2019 that explains it?
I've been reading about poll and Pin and found lots of explanations about being able to recognize at compile time why something can be safely moved; think I understand the guarantees the pin crate makes for pointers, and I've read a lot that goes back to 2018 and 2019, and even why a few small unsound windows remain, but my understanding is missing something. Why is the restriction/safeguard passed into the poll method?
I can understand why an async runtime should not move a future around, the future might contain self references. Certainly many futures built by the compiler for async blocks and async functions can contain self references and user futures might as well.
But I don't see why the Pin used in the Futures::poll signature is a safeguard. The implementor of a particular poll method is always on the hook to write the method so it is consistent with their goal for the future and the poll API doesn't let the method change the address that the runtime knows the future by. So how does the compiler guaranteeing that the address given to the poll method is pinned help the person writing the poll method or compiling the code? That person has to rely on the runtime being well behaved in many other ways too, not just that it doesn't move futures it has been given via await and spawn calls.
I can almost see that a generic future might not know at the time it is being written whether all the types it will be used for are safe to move, but even then, I don't see how a poll would be written where a move of the data pointed to by the poll's self could make any sense as the runtime would still know the future by the address it had for it internally. Even the awake callback doesn't take the address, it's a closure on the task's address presumably.
Sorry my question is so long winded. I've read so many explanations about pinning a pointer and why a future with a self reference shouldn't be allowed to move - and I think I understand those. I just don't see why a poll method would be written to move a future, and if it did, how a runtime was supposed to know about the new address anyway.
(Here's a last minute thought: is it related to what might be put into the Poll::Ready enum as that involves a move or a copy?)