Skip to content

Cargo clippy --fix not working with 1.80.1 #13258

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
psibi opened this issue Aug 12, 2024 · 2 comments
Closed

Cargo clippy --fix not working with 1.80.1 #13258

psibi opened this issue Aug 12, 2024 · 2 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@psibi
Copy link
Member

psibi commented Aug 12, 2024

Summary

The command cargo clippy --fix --allow-dirty is not working as expected with 1.80.1.

Reproducer

I tried this code on a fresh project:

fn main() {
    let f = 1;
}

I expected the file to modify like this when I run cargo clippy --fix --allow-dirty:

fn main() {
    let _f = 1;
}

Instead the file was still this:

fn main() {
    let f = 1;
}

Infact, I confirmed that this was not the behavior in 1.76.0 and everything was working as expected there.

Version

❯ rustc -Vv
rustc 1.80.1 (3f5fd8dd4 2024-08-06)
binary: rustc
commit-hash: 3f5fd8dd41153bc5fdca9427e9e05be2c767ba23
commit-date: 2024-08-06
host: x86_64-unknown-linux-gnu
release: 1.80.1
LLVM version: 18.1.7

Additional Labels

No response

@psibi psibi added the C-bug Category: Clippy is not doing the correct thing label Aug 12, 2024
@y21
Copy link
Member

y21 commented Aug 12, 2024

This was intentionally changed in rust-lang/rust#120470. The lint unused_variables no longer has a machine-applicable suggestion so rustfix won't try to automatically apply this particular warning.

Other suggestions that are marked as machine-applicable should still work, e.g. useless_vec: vec![1].first() should get autofixed to [1].first()

@psibi
Copy link
Member Author

psibi commented Aug 12, 2024

Ah, didn't realize that. Thanks! And the useless_vec does work.

@psibi psibi closed this as completed Aug 12, 2024
psibi added a commit to emacs-rustic/rustic that referenced this issue Aug 12, 2024
Behaviour was changed in recent rust version:
rust-lang/rust-clippy#13258
psibi added a commit to emacs-rustic/rustic that referenced this issue Aug 16, 2024
Behaviour was changed in recent rust version:
rust-lang/rust-clippy#13258
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing
Projects
None yet
Development

No branches or pull requests

2 participants