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

cargo clippy --fix runs without warns on git repository without commit #9838

Closed
TonalidadeHidrica opened this issue Nov 12, 2022 · 3 comments
Labels
C-bug Category: Clippy is not doing the correct thing

Comments

@TonalidadeHidrica
Copy link

Summary

When cargo clippy --fix is ran on a crate that is not managed by a VCS, it warns about it and does not modify the code. This also happens if cargo clippy --fix is ran in a git repository that has uncommiteed changes. However, when it is ran on a repository with uncommited changes but without any commit, it modifies the code without an error or a warning.

Reproducer

set -eux

cargo +nightly new repro
cd repro
echo "fn main() { let _ = 0.clone(); }" > src/main.rs
cargo +nightly clippy --fix
cat src/main.rs
+ cargo +nightly new repro
     Created binary (application) `repro` package
+ cd repro
+ echo 'fn main() { let _ = 0.clone(); }'
+ cargo +nightly clippy --fix
    Checking repro v0.1.0 (/home/username/repro)
       Fixed src/main.rs (1 fix)
    Finished dev [unoptimized + debuginfo] target(s) in 0.19s
+ cat src/main.rs
fn main() { let _ = 0; }

Version

rustc 1.67.0-nightly (42325c525 2022-11-11)
binary: rustc
commit-hash: 42325c525b9d3885847a3f803abe53c562d289da
commit-date: 2022-11-11
host: x86_64-unknown-linux-gnu
release: 1.67.0-nightly
LLVM version: 15.0.4

Additional Labels

No response

@TonalidadeHidrica TonalidadeHidrica added the C-bug Category: Clippy is not doing the correct thing label Nov 12, 2022
@xFrednet
Copy link
Member

Hey @TonalidadeHidrica, thank you for the report! clippy and rustc only evoke rustfix to apply the suggestion. Would you mind filing an issue in that repo? I agree that this is definitely a bug :)

@TonalidadeHidrica
Copy link
Author

Hi @xFrednet , thanks for pointing it out. If you have the "Write" permission for rust-lang organization, then you shuold be able to transfer this issue, so could you try it first? If it seems not wroking well, I'll manually close this issue and open a new ticket in rustfix.

@xFrednet
Copy link
Member

Hey, I checked and sadly don't have write access to the rustfix repo and therefore can't transfer it 😕

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