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

Inconsistent syntax between `unsafe async fn` and `async fn unsafe` #62232

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

Comments

Projects
None yet
5 participants
@topecongiro
Copy link
Contributor

commented Jun 29, 2019

There is an inconsistency in the ordering of async and unsafe keywords that come before the fn signature. A plain function signature requires async unsafe fn, whereas a method signature requires unsafe async fn:

#![feature(async_await)]

struct A;

pub async unsafe fn thing() -> Result<(), ()> {
    unimplemented!()
}

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

fn main() {}
@Centril

This comment has been minimized.

Copy link
Member

commented Jun 29, 2019

Ouch seems I forgot about implementations in #61319.
I assumed it was the same code path... :(

Thanks for reporting this!

(The right order is async unsafe fn)

@Centril

This comment has been minimized.

Copy link
Member

commented Jun 29, 2019

I have a fix in #62241.

Centril added a commit to Centril/rust that referenced this issue Jun 30, 2019

Rollup merge of rust-lang#62241 - Centril:fix-async-unsafe-order, r=p…
…etrochenkov

Always parse 'async unsafe fn' + properly ban in 2015

Parse `async unsafe fn` not `unsafe async fn` in implementations. We also take the opportunity to properly ban `async fn` in Rust 2015 when they are inside implementations.

Closes rust-lang#62232.

cc rust-lang#61319, rust-lang#62121, and rust-lang#62149.

r? @petrochenkov

@bors bors closed this in #62241 Jul 1, 2019

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