Skip to content

error[E0670]: async fn is not permitted in the 2015 edition #1959

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

Closed
kanekv opened this issue Oct 5, 2019 · 14 comments · Fixed by #2477
Closed

error[E0670]: async fn is not permitted in the 2015 edition #1959

kanekv opened this issue Oct 5, 2019 · 14 comments · Fixed by #2477

Comments

@kanekv
Copy link

kanekv commented Oct 5, 2019

I'm getting this error in the output. It doesn't break anything though.

@matklad
Copy link
Member

matklad commented Oct 5, 2019

I think this works as expected? This error comes from cargo check and it indeed is true that async fn is not supported on 2015 edition

@kanekv
Copy link
Author

kanekv commented Oct 5, 2019

Probably it's cargo problem then (should it report that if project is on 2018 edition).

@kanekv kanekv closed this as completed Oct 5, 2019
@zkat
Copy link

zkat commented Dec 1, 2019

@kanekv @matklad can you reopen this? I'm getting the same error -- but it only happens through rust-analyzer. For some reason, it seems to think the project is on 2015, but it's definitely on 2018, and cargo check doesn't complain at all, so this seems to be an ra bug. I can reproduce it just by having an async fn in a file.

And yes, it's definitely breaking something: It's preventing format-on-save from working, so I keep committing bad fmt stuff 😅

@matklad matklad reopened this Dec 2, 2019
@matklad
Copy link
Member

matklad commented Dec 2, 2019

@zkat a minimal reproducible example will help here. For formatting, we just use rustfmt, so my guess would be that something's odd with the way Cargo project is setup.

@davidbarsky
Copy link
Contributor

I saw this error in a minimal project that didn't have a rustfmt.toml. I was able to make the errors go away by creating a rustfmt.toml and adding an edition = "2018" to it.

@zkat
Copy link

zkat commented Dec 3, 2019

@matklad The repro is so small, it's not even worth putting up on a repo:

  1. Install VS Code Insiders edition.
  2. install rust-analyzer using the instructions in the readme
  3. make sure cargo fmt is actually installed in the system
  4. use stable as the default rust channel
  5. cargo new bug-repro --lib
  6. Edit lib.rs and add the following code, then save the file and look at the Output pane's Rust Analyzer Language Server tab.:
pub async fn foo() -> Result<(), std::error::Error> { Ok(())
}

FWIW, @davidbarsky's suggestion of adding a rustfmt.toml file fixed this for me.

@zkat
Copy link

zkat commented Dec 3, 2019

Looks like this behavior is (somewhat) intentional, as rustfmt isn't aware of Cargo.toml unless invoked through cargo itself: https://github.com/rust-lang/rustfmt#rusts-editions. But I feel as though it's a bug for rust-analyzer to not be Cargo.toml aware if it detects that it's that kind of project?

@matklad
Copy link
Member

matklad commented Dec 4, 2019

I'd say that this is out of scope, for now. it will be in scope once we switch to rustfmt as a library (which isn't goint to happen any time soon). Closing as a dupe of #2146 (which contains some more rational).

@matklad matklad closed this as completed Dec 4, 2019
bors bot added a commit that referenced this issue Dec 4, 2019
2477: Run rustfmt with respect to Cargo.toml edition r=matklad a=Speedy37

Fixes #2146
Fixes #1959

Co-authored-by: Vincent Rouillé <[email protected]>
@malaire
Copy link

malaire commented Jan 15, 2021

I'm getting this error in some projects with Sublime Text and rust-analyzer, but not all. The --edition 2018 switch is not being passed to rustfmt.

liuchengxu added a commit to autonomys/subspace that referenced this issue Oct 22, 2021
This change is to fix the error `[E0670]: async fn is not permitted in the 2015 edition` when using Vim with rust-analyzer.

Ref: rust-lang/rust-analyzer#1959
liuchengxu added a commit to liuchengxu/cumulus that referenced this issue Nov 15, 2021
This PR is mainly to fix the error `[E0670]: async fn is not permitted in the 2015 edition` when
using Vim along with rust-analyzer, it also removes an unused dependency from parachain-template.

Ref: rust-lang/rust-analyzer#1959
bkchr pushed a commit to paritytech/cumulus that referenced this issue Nov 16, 2021
This PR is mainly to fix the error `[E0670]: async fn is not permitted in the 2015 edition` when
using Vim along with rust-analyzer, it also removes an unused dependency from parachain-template.

Ref: rust-lang/rust-analyzer#1959
@ArshiAAkhavan
Copy link

it seems that the issue still remains
i have rust-analyzer 0.0.0 (caf23f291 2022-07-11) and i use vim and i can't get it to format my code unless i set the edition in rustfmt.toml

@AustinHellerRepo
Copy link

AustinHellerRepo commented Oct 5, 2022

Just in case someone else made the same mistake I did, I was having this issue where it was stating that my edition was 2015 because I made the mistake of changing my "main.rs" filename to something else and did not specify a target in my "Cargo.toml" file. Changing the name back was the first issue, but then I learned that I had to use $ cargo run in order to ensure that my packages were visible.

WebWizrd8 added a commit to WebWizrd8/cumulus that referenced this issue Nov 21, 2022
This PR is mainly to fix the error `[E0670]: async fn is not permitted in the 2015 edition` when
using Vim along with rust-analyzer, it also removes an unused dependency from parachain-template.

Ref: rust-lang/rust-analyzer#1959
@romainds-tech
Copy link

I solved the problem by adding

edition = "2021"

just below [package] in Cargo.toml

Screenshot 2023-07-05 at 22 09 07

@LefterisJP
Copy link

I solved the problem by adding

edition = "2021"

just below [package] in Cargo.toml

Screenshot 2023-07-05 at 22 09 07

For us putting this in cargo.toml does not seem to have an effect. But adding a rustfmt.toml with the same value as per the docs works.

@djhunter67
Copy link

I saw this error in a minimal project that didn't have a rustfmt.toml. I was able to make the errors go away by creating a rustfmt.toml and adding an edition = "2018" to it.

This fixed it!

taqtiqa-mark pushed a commit to subversive-upstream/polkadot-sdk-cumulus that referenced this issue Sep 14, 2023
This PR is mainly to fix the error `[E0670]: async fn is not permitted in the 2015 edition` when
using Vim along with rust-analyzer, it also removes an unused dependency from parachain-template.

Ref: rust-lang/rust-analyzer#1959
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

Successfully merging a pull request may close this issue.

10 participants