willcrichton / flowistry

Flowistry is an IDE plugin for Rust that helps you focus on relevant code.
https://marketplace.visualstudio.com/items?itemName=wcrichton.flowistry
MIT License
1.91k stars 45 forks source link

Fix async return handling #92

Open JustusAdam opened 9 months ago

JustusAdam commented 9 months ago

Fixes the parent-to-child translation of async functions.

The prior code assumed that the type of the destination place an async function returns from is the same as the type of _0 in the child. However it is instead Poll<...>. This adds the requisite projections to the destination place to make this work out. In particular it adds a Downcast (because Poll is an enum and the Ready variant is the one that carries the actual result) and a Field projection (because a variant downcast is always followed by a projection onto one of the fields).

I also refactored translate_to_parent slightly so it is just one match statement. I think that is clearer.

We should probably add some test cases for this but I've verified that this works in the Paralegal tests.