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

rustfmt ignores the edition setting? #4645

Closed
matthiasbeyer opened this issue Jan 15, 2021 · 4 comments
Closed

rustfmt ignores the edition setting? #4645

matthiasbeyer opened this issue Jan 15, 2021 · 4 comments
Labels
bug Panic, non-idempotency, invalid code, etc.

Comments

@matthiasbeyer
Copy link

Describe the bug

My crate is edition = "2018", but:

$ cargo fmt
error[E0670]: `async fn` is not permitted in the 2015 edition
  --> /home/m/archive/development/rust/butido/src/main.rs:73:1
   |
73 | async fn main() -> Result<()> {
   | ^^^^^ 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

To Reproduce

  1. clone https://git.sr.ht/~matthiasbeyer/butido or https://github.com/science-computing/butido
  2. Make sure to git checkout c638b21c1e09ba7a0a76e0fa5d930fbc11abe62d (current master)
  3. cargo fmt
  4. see above error message
  5. grep edition Cargo.toml

Expected behavior

It formats the code.

Meta

  • rustfmt version: rustfmt 1.4.25-stable (0f29ff6 2020-11-11)
  • From where did you install rustfmt?: cargo install rustfmt
  • How do you run rustfmt: cargo fmt
@matthiasbeyer matthiasbeyer added the bug Panic, non-idempotency, invalid code, etc. label Jan 15, 2021
@calebcartwright
Copy link
Member

calebcartwright commented Jan 16, 2021

From where did you install rustfmt?: cargo install rustfmt

Just want to verify this is correct and is indeed how you installed rustfmt?

That rustfmt crate is deprecated and incredibly outdated, and not one of the distribution channels for rustfmt (https://crates.io/crates/rustfmt), so if that's how you installed it you've got a versioning issue on your system.

@matthiasbeyer
Copy link
Author

matthiasbeyer commented Jan 16, 2021

grrr... I'm probably not the first one hitting this issue, right? Any chance the "rustfmt" crate gets yanked?

Not sure about the versioning issue you reported, but the above method was indeed not what I did,... I messed up the different systems I'm working on in my head.

My installation method was the nixpkgs-mozilla nixpkgs overlay:

$ which cargo-fmt
/nix/store/pi75h2m2f91rs15zzclkz1rq0qxw8frz-rust-1.49.0-2020-12-29-e1884a8e3/bin/cargo-fmt

$ which rustfmt
/nix/store/pi75h2m2f91rs15zzclkz1rq0qxw8frz-rust-1.49.0-2020-12-29-e1884a8e3/bin/rustfmt

$ cargo fmt --version
Unrecognized option: 'version'
usage: cargo fmt [options]

Options:
    -h, --help          show this message
    -q, --quiet         no output printed to stdout
    -v, --verbose       use verbose output
    -p, --package <package>
                        specify package to format (only usable in workspaces)
        --all           format all packages (only usable in workspaces)

This utility formats all bin and lib files of the current crate using rustfmt. Arguments after `--` are passed to rustfmt.

$ rustfmt --version
rustfmt 1.4.25-stable (0f29ff6 2020-11-11)

@calebcartwright
Copy link
Member

grrr... I'm probably not the first one hitting this issue, right? Any chance the "rustfmt" crate gets yanked?

see #4343

$ cargo fmt --version
Unrecognized option: 'version'

This output is definitively indicative of having an issue on your system, notably a very, very old cargo fmt bin being invoked. Would advise explicitly uninstalling the rustfmt crate just in case

@matthiasbeyer
Copy link
Author

Okay, so it seems that there was a rustfmt and a cargo-fmt in my ~/.cargo/bin, which is obviously not what I want, hence I install them from nix.
That solved my issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Panic, non-idempotency, invalid code, etc.
Projects
None yet
Development

No branches or pull requests

2 participants