Skip to content

Suggestion for E0627's message #50659

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

Closed
phrohdoh opened this issue May 11, 2018 · 4 comments
Closed

Suggestion for E0627's message #50659

phrohdoh opened this issue May 11, 2018 · 4 comments
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@phrohdoh
Copy link

The error message for E0627 is currently:

"yield statement outside of generator literal").emit();

But could be something, IMHO more helpful, like:

The containing function is not marked as async

@oli-obk oli-obk added the A-diagnostics Area: Messages for errors, warnings, and lints label May 11, 2018
@Arnavion
Copy link

But the error message is correct. It's about yield statements outside of generator literals.

You're getting this error because you used future-await's await! macro (which expands to code that uses yield) on a function that you didn't annotate with #[async] (which expands to code that creates a generator). The compiler can't special-case its error message just for a specific user crate macro. Native async-await syntax would have its own separate error message for await outside of async functions.

@estebank
Copy link
Contributor

@Arnavion I wouldn't be against the compiler having special case code for climbing the scope tree and suggesting marking the enclosing method as #[async] if the crate futures-await is available (and even suggest adding the crate dep if it isn't).

We shouldn't be encoding information in the compiler that depends on the community's crates, as things change over time, but I feel that the usability improvement in this case is worth it. That being said, we could try to implement something along the lines of rustc_on_unimplemented for E0627 that could be generic and use messages provided by the available crates instead.

@jesskfullwood
Copy link

FWIW this error confused me a lot while trying out async/await for the first time.

@XAMPPRocky XAMPPRocky added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Oct 2, 2018
@estebank estebank added the A-async-await Area: Async & Await label Feb 7, 2019
@nikomatsakis
Copy link
Contributor

Closing as duplicate of #51751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants