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

unsafe async fn -> async unsafe fn + error #3662

Closed
Proximyst opened this issue Jun 29, 2019 · 2 comments
Closed

unsafe async fn -> async unsafe fn + error #3662

Proximyst opened this issue Jun 29, 2019 · 2 comments

Comments

@Proximyst
Copy link

The reordering of the signature pub unsafe async fn test(&mut self) in an impl block breaks compilation, given it makes it pub async unsafe fn test(&mut self). I have no clue if this applies to any and all functions with unsafe async fn, but it breaks with this simple case:

#![feature(async_await)]

struct A;

impl A {
    pub unsafe async fn thing(&mut self) -> Result<(), ()> {
        Err(())
    }
}

If you now use the newest rustfmt (i.e. from latest nightly), it breaks compilation:

error: missing `fn`, `type`, or `const` for impl-item declaration
 --> a.rs:5:8
  |
5 |     pub async unsafe fn thing(&mut self) -> Result<(), ()> {
  |        ^ missing `fn`, `type`, or `const`

A simple case for making this work is just creating a file called a.rs, copy+paste that, run rustfmt a.rs, then rustc a.rs to get the error.

@topecongiro
Copy link
Contributor

Hmm, I thought the correct ordering has changed to async unsafe fn in rust-lang/rust#61319, but that doesn't apply to methods in impl? That's strange.

@topecongiro
Copy link
Contributor

This is a bug in the rustc parser. It will be fixed in rust-lang/rust#62241.

Closing as this is not a rustfmt issue. @Proximyst Thank you for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants