-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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 fix
does not warn about modifying untracked files
#11380
Comments
cargo clippy --fix
runs without warns on git repository without commitcargo fix
does not warn about modifying untracked files
Transferred to rust-lang/cargo, as the rustfix repo is only for the library which is not responsible for the determination of what to modify. |
@rustbot claim I'll try to fix it. |
@ehuss Do you mind giving some tips about which code causes this issue? I read |
I think the real root cause is these files are untracked files. So Line 157 in ba607b2
For example, you can try this to test this behavior: set -eux
cargo +nightly new repro
cd repro
echo "fn main() { let _ = 0.clone(); }" > src/main.rs
git add .
git commit -m "test"
echo "fn main() { let _ = 0.clone(); }" > src/main1.rs
cargo +nightly clippy --fix
cat src/main.rs You will find So I think this is probably not a bug. |
I think the StatusOpts needs to set |
It works! Thanks! |
Transferred from rust-lang/rust-clippy#9838.
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 ifcargo 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
Version
Additional Labels
No response
The text was updated successfully, but these errors were encountered: