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

Open
Phrohdoh opened this Issue May 11, 2018 · 3 comments

Comments

Projects
None yet
6 participants
@Phrohdoh
Copy link

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Contributor

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

This comment has been minimized.

Copy link

jesskfullwood commented Aug 20, 2018

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment