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

[bug] async specialization is not parsed #63716

Closed
jhpratt opened this issue Aug 19, 2019 · 3 comments · Fixed by #63759
Closed

[bug] async specialization is not parsed #63716

jhpratt opened this issue Aug 19, 2019 · 3 comments · Fixed by #63759
Assignees
Labels
A-async-await Area: Async & Await A-parser Area: The parsing of Rust source code to an AST A-specialization Area: Trait impl specialization C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@jhpratt
Copy link
Member

jhpratt commented Aug 19, 2019

The async keyword doesn't seem to currently work with specialization (namely default fn). The order of keywords does not matter — I'm not sure which it's supposed to be.

Minimal example from @dtolnay in dtolnay/async-trait#25:

macro_rules! item {
    ($i:item) => {}
}

item! {
    trait Trait {
        async default fn f() {}
    }
}

item! {
    trait Trait {
        default async fn f() {}
    }
}

which gives the following error

error: expected one of `extern`, `fn`, or `unsafe`, found `default`
 --> src/main.rs:7:15
  |
7 |         async default fn f() {}
  |               ^^^^^^^ expected one of `extern`, `fn`, or `unsafe` here

error: missing `fn`, `type`, or `const` for trait-item declaration
  --> src/main.rs:12:18
   |
12 |       trait Trait {
   |  __________________^
13 | |         default async fn f() {}
   | |________^ missing `fn`, `type`, or `const`

error: aborting due to 2 previous errors
@jonas-schievink jonas-schievink added A-async-await Area: Async & Await A-parser Area: The parsing of Rust source code to an AST A-specialization Area: Trait impl specialization C-bug Category: This is a bug. F-async_await F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 19, 2019
@cramertj
Copy link
Member

Note that async in traits is not yet allowed, so this would be meaningless even if it parsed.

@dtolnay
Copy link
Member

dtolnay commented Aug 19, 2019

@cramertj #[async_trait] can handle this if rustc will parse it.

@jhpratt
Copy link
Member Author

jhpratt commented Aug 19, 2019

@cramertj Where this came up is when attempting to use the async-trait crate, which uses a proc macro to transform async traits to current syntax. I was attempting to use it in Rocket when I ran into this.

@Centril Centril self-assigned this Aug 20, 2019
Centril added a commit to Centril/rust that referenced this issue Aug 20, 2019
…etrochenkov

Allow 'default async fn' to parse.

- Parse default async fn. Fixes rust-lang#63716.

(`cherry-pick`ed from 3rd commit in rust-lang#63749.)

r? @petrochenkov
@bors bors closed this as completed in 67e39ed Aug 21, 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-parser Area: The parsing of Rust source code to an AST A-specialization Area: Trait impl specialization C-bug Category: This is a bug. F-specialization `#![feature(specialization)]` requires-nightly This issue requires a nightly compiler in some way. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
5 participants