-
Notifications
You must be signed in to change notification settings - Fork 13.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
async/await errors should not discuss "yield statements" #51751
Comments
@jonathandturner Ugh-- thanks for pointing this out! This is an annoying result of the fact that cc @eddyb |
Closely related to #51719. |
@jonathandturner What ended up being the working code? |
@brandonros You need to keep |
@eddyb I apologize for the extreme lack of knowledge on the topic as I am still a beginner, but I am curious and excited to give Rust a shot once I understand how to use async/await. I am struggling to find any kind of clear example on the Internet (probably because all of this is still so fresh) Are you saying it is not possible to call await! in main? Is it possible to make main async? Regarding the futures create, I was under the impression all of the necessary moving pieces for futures/async/await were being brought in to the Rust compiler + standard library so that no external crates would be required. Can somebody post a full example of what a simple "Hello world" level async/await/futures function would look like (including its invocation from main?) This is the closest I can come up with what seems it might be in the right direction is
but this does not compile for many obvious reasons. I feel there isn't any documentation out there that shows how to piece together the new async/await language features with the new std::future library. I think a working example of the pasted above code would be pretty big for the "beginner" community trying to get on board with Rust and not be fragmented between the many different ways to do async code that currently exist (and are most likely outdated/going to get phased out it sounds like with these new RFCs) |
@brandonros I expect any practical usecase would still involve a |
Would some wording like this work: |
I can see we have asyncness on the ast. Given that the await! macro disappears I think this is our only hint. Will explore that path. |
@gilescope IMO fixing this prior to moving to native syntax doesn't really make sense, because at that point I'm assuming we'll have an actual |
We can create an intrinsic macro (like |
Implement built-in await syntax Adds support for .await under the existing async_await feature gate. Moves macro-like await! syntax to the await_macro feature gate. Removes support for `await` as a non-keyword under the `async_await` feature. This new syntax is not final, but is the consensus solution proposed by the lang team, as explained in https://boats.gitlab.io/blog/post/await-decision/ Fix #51719 Fix #51751 Fix #60016
Awesome to see async/await starting to light up. I poked around and hit a snag putting together a naive little example. Clearly, this example is probably missing a bit more to get it running, but I just wanted to point the error here doesn't quite help:
For the above, you get:
Which immediately makes you wonder "what yield statement?" I suspect one of the first things people will want to try is awaiting an async function, so we might want to gently point them in the right direction.
cc @estebank @cramertj
The text was updated successfully, but these errors were encountered: