Skip to content
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

Suggestion for E0627's message #50659

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

Comments

@phrohdoh
Copy link

@phrohdoh phrohdoh commented May 11, 2018

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

@Arnavion
Copy link

@Arnavion Arnavion commented May 11, 2018

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

@estebank estebank commented May 14, 2018

@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

@jesskfullwood jesskfullwood commented Aug 20, 2018

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

@nikomatsakis
Copy link
Contributor

@nikomatsakis nikomatsakis commented Feb 22, 2019

Closing as duplicate of #51751

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
7 participants