Skip to content

Commit

Permalink
Auto merge of rust-lang#10712 - blyxyas:fix-fixflag_implies_all_targe…
Browse files Browse the repository at this point in the history
…ts, r=llogiq

Document that `cargo clippy --fix` implies `--all-targets`

In [`cargo fix`'s documentation](https://doc.rust-lang.org/cargo/commands/cargo-fix.html) they indicate that `fix` implies `--all-targets` if no target is supplied. As Clippy uses Cargo under the hood, this also applies to Clippy, but we didn't document that behaviour.

This PR changes that

Fixes rust-lang#10690
changelog: Add to documentation that `--fix` implies `--all-targets`
  • Loading branch information
bors committed Apr 25, 2023
2 parents 19465c9 + 4a76b6f commit a7335cb
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 4 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ cargo clippy

#### Automatically applying Clippy suggestions

Clippy can automatically apply some lint suggestions, just like the compiler.
Clippy can automatically apply some lint suggestions, just like the compiler. Note that `--fix` implies
`--all-targets`, so it can fix as much code as it can.

```terminal
cargo clippy --fix
Expand Down
3 changes: 2 additions & 1 deletion book/src/usage.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,8 @@ fn main() {

### Automatically applying Clippy suggestions

Clippy can automatically apply some lint suggestions, just like the compiler.
Clippy can automatically apply some lint suggestions, just like the compiler. Note that `--fix` implies
`--all-targets`, so it can fix as much code as it can.

```terminal
cargo clippy --fix
Expand Down
4 changes: 3 additions & 1 deletion lintcheck/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,11 @@ is explicitly specified in the options.

### Fix mode
You can run `cargo lintcheck --fix` which will run Clippy with `--fix` and
print a warning if Clippy's suggestions fail to apply (if the resulting code does not build).
print a warning if Clippy's suggestions fail to apply (if the resulting code does not build).
This lets us spot bad suggestions or false positives automatically in some cases.

> Note: Fix mode implies `--all-targets`, so it can fix as much code as it can.
Please note that the target dir should be cleaned afterwards since clippy will modify
the downloaded sources which can lead to unexpected results when running lintcheck again afterwards.

Expand Down
2 changes: 1 addition & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Usage:
Common options:
--no-deps Run Clippy only on the given crate, without linting the dependencies
--fix Automatically apply lint suggestions. This flag implies `--no-deps`
--fix Automatically apply lint suggestions. This flag implies `--no-deps` and `--all-targets`
-h, --help Print this message
-V, --version Print version info and exit
--explain LINT Print the documentation for a given lint
Expand Down

0 comments on commit a7335cb

Please sign in to comment.