Skip to content

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

Closed
@Proximyst

Description

@Proximyst

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions