Skip to content

clippy --fix now errors on untracked files #10261

@bryanlarsen

Description

@bryanlarsen

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions