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

Comments

@jhpratt
Copy link

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
@cramertj

This comment has been minimized.

Copy link
Member

commented Aug 19, 2019

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

@dtolnay

This comment has been minimized.

Copy link
Member

commented Aug 19, 2019

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

@jhpratt

This comment has been minimized.

Copy link
Author

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
Rollup merge of rust-lang#63759 - Centril:parse-default-async-fn, r=p…
…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 in 67e39ed Aug 21, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants
You can’t perform that action at this time.