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

Cannot use async fn with rustfmt #220

Closed
SushiWaUmai opened this issue Dec 26, 2022 · 2 comments
Closed

Cannot use async fn with rustfmt #220

SushiWaUmai opened this issue Dec 26, 2022 · 2 comments

Comments

@SushiWaUmai
Copy link
Contributor

The async fn keyword is not valid in the 2015 version of rustfmt.

Therefore I suggest that we should add a --edition 2021 argument to the rustfmt by default .

@regexPattern
Copy link

I got the same error here. Here is the full mesage when I just try to run :Format on a project that uses tokio (the message is from rustfmt itself):

Failed to run formatter rustfmt. error[E0670]: `async fn` is not permitted in Rust 2015  --> <stdin>:36:1   |36 | async fn main() {   | ^^^^^ to use `async fn`, switch to Rust 2018 or later
   |   = help: pass `--edition 2021` to `rustc`   = note: for more on editions, read https://doc.rust-lang.org/edition-guideerror: expected one of `!`, `)`, `,`, `.`, `::`, `?`, `{`, or an 
operator, found keyword `move`  --> <stdin>:64:37   |64 |                 (tokio::spawn(async move {   |                                     ^^^^ expected one of 8 possible tokens

@maddiemort
Copy link

One possible workaround is to add a rustfmt.toml file to your project with the contents edition = "2021" or edition = "2018" (see rust-lang/rustfmt#4454). But I agree that we should add an --edition 2021 argument by default.

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

3 participants