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 deletes derived traits in #[derive(...)] #4584

Closed
ente76 opened this issue Dec 11, 2020 · 6 comments · Fixed by #4585
Closed

rustfmt deletes derived traits in #[derive(...)] #4584

ente76 opened this issue Dec 11, 2020 · 6 comments · Fixed by #4585
Assignees
Labels
1x-backport:completed bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce

Comments

@ente76
Copy link

ente76 commented Dec 11, 2020

Describe the bug

Running cargo fmt on my project takes all #[derive(Debug, Clone, PartialEq, Eq)] and deletes exactly the last letter on each execution. It does not matter how many traits I derive. If I run it multiple times, it will stop at an empty derive().

To Reproduce

Setup a new library and add the following lines:

#[derive(Debug)]
pub enum Case {
    Upper,
    Lower
}

run cargo fmt

Expected behavior

cargo fmt finishes my project while I watch funny cat videos on youtube. At least rustfmt does not make my life harder than it is.

Meta

  • rustfmt version: rustfmt 1.4.29-nightly (70ce182 2020-12-04)
  • From where did you install rustfmt?: rustup nightly version: rustc 1.50.0-nightly (d32c320 2020-12-10)
  • How do you run rustfmt: cargo fmt (manually to test), usually via rust-analyzer during file saving
@ente76 ente76 added the bug Panic, non-idempotency, invalid code, etc. label Dec 11, 2020
@ente76
Copy link
Author

ente76 commented Dec 11, 2020

rustfmt 1.4.27-nightly (580d826 2020-11-16) works without the error.

@calebcartwright
Copy link
Member

I'm unable to reproduce this locally. Can you provide some additional information so that we can be better equipped to assist?

Do you have a public repo or a CI run where we can observe the described behavior?

@ente76
Copy link
Author

ente76 commented Dec 11, 2020

Please do run:

mkdir test
cd test
git clone https://gitlab.com/systemd.rs/sd-sys.git
git clone https://gitlab.com/systemd.rs/sd-id128.git
cd sd-id128
cargo fmt

file lib.rs in test/sd-id128/src/lib.rs has multiple derives that should be lacking the last letter now. I tested above process using rustup provided by arch linux (rustup 1.23.0-1).
rustup update has been executed approx. every day since Monday (that's approximately been the first time I hit the error).
rustup default nightly is been activated. I will go back to the working version now (currently I use nightly-20-11-2020).

@calebcartwright calebcartwright added the only-with-option requires a non-default option value to reproduce label Dec 11, 2020
@calebcartwright
Copy link
Member

Thanks! This can be reproduced when indent_style is changed to Visual

@calebcartwright
Copy link
Member

Backported in v1.4.30

@calebcartwright calebcartwright added 1x-backport:completed and removed 1x-backport:pending Fixed/resolved in source but not yet backported to a 1x branch and release labels Dec 24, 2020
@karyon
Copy link
Contributor

karyon commented Oct 25, 2021

backported in #4605

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1x-backport:completed bug Panic, non-idempotency, invalid code, etc. only-with-option requires a non-default option value to reproduce
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants