Cannot use async fn with rustfmt
SushiWaUmai opened this issue · 2 comments
SushiWaUmai commented
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 commented
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
nerosnm commented
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.