rust-lang / rust-lang/rust-clippy

clippy --fix now errors on untracked files

Open
#10,261 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug
Dominant language
Rust
Stars
13.5k
Forks
2.2k
Avg merge
2d 10h
Merged PRs (30d)
32

Description

Summary

After upgrading to rust 1.67.0 clippy --fix now fails if you have any untracked files in your git repository. I now have to pass the --allow-dirty flag to use clippy --fix. I didn't have to do this in rust 1.66.0.

If this is a deliberate change, I suggest adding an --allow-untracked flag to clippy --fix so that we can get the old behavior back.

Reproducer

reproduce:

cargo new foo
cd foo
git add .
git commit -m "Initial commit"
touch bar.txt
cargo clippy --fix

I expected to see this happen: Success

Instead, this happened:

error: the working directory of this package has uncommitted changes, and `cargo fix` can potentially perform destructive changes; if you'd like to suppress this error pass `--allow-dirty`, `--allow-staged`, or commit the changes to these files:

  * bar.txt (dirty)
Version
rustc 1.67.0 (fc594f156 2023-01-24)
binary: rustc
commit-hash: fc594f15669680fa70d255faec3ca3fb507c3405
commit-date: 2023-01-24
host: x86_64-unknown-linux-gnu
release: 1.67.0
LLVM version: 15.0.6
Additional Labels

No response

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by running the reported cargo new, git commit, touch bar.txt, and cargo clippy --fix reproducer with Rust 1.67.0, then inspect the clippy --fix handling related to dirty and untracked files. Confirm the behavior against Rust 1.66.0 and define done as restoring the expected success or providing the requested way to allow untracked files without allowing other dirty changes.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.