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

Add more context when trying to write async trait function #65899

Closed
estebank opened this issue Oct 28, 2019 · 2 comments · Fixed by #66526
Closed

Add more context when trying to write async trait function #65899

estebank opened this issue Oct 28, 2019 · 2 comments · Fixed by #66526
Assignees
Labels
A-async-await Area: Async & Await A-diagnostics Area: Messages for errors, warnings, and lints A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-trait-system Area: Trait system AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@estebank
Copy link
Contributor

estebank commented Oct 28, 2019

Given

trait T {
    async fn foo() {}
    async fn bar(&self) {}
}

we currently emit

error[E0706]: trait fns cannot be declared `async`
 --> src/lib.rs:2:5
  |
2 |     async fn foo() {}
  |     ^^^^^^^^^^^^^^^^^

error[E0706]: trait fns cannot be declared `async`
 --> src/lib.rs:3:5
  |
3 |     async fn bar(&self) {}
  |     ^^^^^^^^^^^^^^^^^^^^^^

We should tell people that async trait functions are not possible because of technical restrictions, and possibly point them to the async-trait crate.

This issue has been assigned to @jafern14 via this comment.

@estebank estebank added A-diagnostics Area: Messages for errors, warnings, and lints A-trait-system Area: Trait system T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-async-await Area: Async & Await F-async_await D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. labels Oct 28, 2019
@estebank estebank changed the title Make rustc parse async trait functions and provide targetted error Add more context when trying to write async trait function Oct 28, 2019
@estebank estebank reopened this Oct 28, 2019
@Centril Centril added the E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. label Oct 28, 2019
@jafern14
Copy link

@rustbot claim

@rustbot rustbot self-assigned this Oct 29, 2019
@jafern14
Copy link

jafern14 commented Oct 29, 2019

Created #65937

@nikomatsakis nikomatsakis added the AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. label Oct 29, 2019
@bors bors closed this as completed in 0a0d07a Nov 20, 2019
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 A-impl-trait Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch. A-trait-system Area: Trait system AsyncAwait-Triaged Async-await issues that have been triaged during a working group meeting. D-newcomer-roadblock Diagnostics: Confusing error or lint; hard to understand for new users. E-easy Call for participation: Easy difficulty. Experience needed to fix: Not much. Good first issue. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants