A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/rust-lang/rustfmt/issues/4454 below:

Improve error message when `edition = "2018"` has not been set · Issue #4454 · rust-lang/rustfmt · GitHub

Describe the bug

Hi there,

I just spent about 4 hours puzzling about why my emacs configuration was producing the following error:

error[E0670]: `async fn` is not permitted in the 2015 edition
 --> <stdin>:7:1
  |
7 | async fn async_main() {
  | ^^^^^ to use `async fn`, switch to Rust 2018
  |
  = help: set `edition = "2018"` in `Cargo.toml`
  = note: for more on editions, read https://doc.rust-lang.org/edition-guide

Despite having edition = "2018" set in Cargo.toml, the error was in fact due to edition = "2018" not being set in rustfmt.toml. As you might imagine, this was very confusing!

I am not the only one who's experienced this issue:

brotzeit/rustic#128
brotzeit/rustic#27
rust-lang/rls#1688

To Reproduce

Create a new cargo project, set the edition = "2018" in cargo.toml, add an async fn to the project, and then without any sort of configuration applied to rustfmt, run it as you normally would.

Run cargo check manually to verify that the error is not shown when running cargo.

Expected behavior

If it's not practical to change the default behaviour to edition 2018, I understand fully, but perhaps the error could be improved to point the developer in the direction of rustfmt.toml and not the cargo.toml?

Meta

nph4rd, TheWandererLee, notrodes, ryanobjc, ashlineldridge and 6 more


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4