Skip to content

[bug] async specialization is not parsed #63716

Closed
@jhpratt

Description

@jhpratt

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

Metadata

Metadata

Assignees

Labels

A-async-awaitArea: Async & AwaitA-parserArea: The lexing & parsing of Rust source code to an ASTA-specializationArea: Trait impl specializationC-bugCategory: This is a bug.F-specialization`#![feature(specialization)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.requires-nightlyThis issue requires a nightly compiler in some way.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions