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 · Fixed by #62241
Closed

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

topecongiro opened this issue Jun 29, 2019 · 2 comments · Fixed by #62241
Assignees
Labels
A-async-await Area: Async & Await A-grammar Area: The grammar of Rust A-parser Area: The parsing of Rust source code to an AST AsyncAwait-Polish Async-await issues that are part of the "polish" area C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@topecongiro
Copy link
Contributor

topecongiro 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() {}
@matthewjasper matthewjasper added A-async-await Area: Async & Await AsyncAwait-Polish Async-await issues that are part of the "polish" area labels Jun 29, 2019
@jonas-schievink jonas-schievink added A-grammar Area: The grammar of Rust C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Jun 29, 2019
@Centril
Copy link
Contributor

Centril 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)

@csmoe csmoe added the A-parser Area: The parsing of Rust source code to an AST label Jun 29, 2019
@Centril Centril self-assigned this Jun 29, 2019
@Centril
Copy link
Contributor

Centril commented Jun 29, 2019

I have a fix in #62241.

Centril added a commit to Centril/rust that referenced this issue Jun 30, 2019
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-async-await Area: Async & Await A-grammar Area: The grammar of Rust A-parser Area: The parsing of Rust source code to an AST AsyncAwait-Polish Async-await issues that are part of the "polish" area C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants