Skip to content

Clippy subtree update #145749

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

Merged
merged 137 commits into from
Aug 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
137 commits
Select commit Hold shift + click to select a range
3688b33
Move `adjust_derefs_manually_drop` into `clippy_utils`
samueltardieu Mar 11, 2025
2cfbb05
Convert `deref_addrof` lint to late lint
samueltardieu Mar 10, 2025
6030997
Remove `verify_inside_clippy_dir` since we always set the current dir…
Jarcho May 23, 2025
fc8bf97
Rename `exit_if_err` to `run_exit_on_err`
Jarcho May 23, 2025
ed50c8a
Make `dev serve` actually detect all updates
Jarcho May 23, 2025
46ff0a8
Add helper function for creating cargo commands.
Jarcho May 23, 2025
ed1088e
Use `track_caller` more for better error spans in `clippy_dev`
Jarcho May 23, 2025
e624b77
Inline `cargo_clippy_path` and add a note about removing it when poss…
Jarcho May 24, 2025
9136814
Make `utils` module private.
Jarcho May 24, 2025
7ed763b
Do not replace `match` by `if` if any arm contains a binding
samueltardieu Jul 26, 2025
27478be
Do not use `DerefMut` on `ManuallyDrop<_>` reached through unions
samueltardieu Mar 10, 2025
ff496ad
Lint more cases when the explicit dereference can be kept in place
samueltardieu May 7, 2025
7224dff
Do not lint data coming from macro
samueltardieu May 7, 2025
849f71f
remove gate
Kivooeo Aug 3, 2025
7a11381
fix &str type check in `from_str_radix_10`
zihan0822 Aug 5, 2025
cece1b9
Reuse previous `Vec` allocation in loop
samueltardieu Aug 6, 2025
eb15cf0
Merge commit '334fb906aef13d20050987b13448f37391bb97a2' into clippy-s…
flip1995 Aug 7, 2025
c752fb2
Do not attempt to compute size of a type with escaping lifetimes
samueltardieu Aug 7, 2025
32a216e
Reuse previous `Vec` allocation in loop (#15428)
blyxyas Aug 7, 2025
26cf75a
`unnecessary_operation`: add space between stmts in suggestion
ada4a Aug 7, 2025
7aa7563
move `crosspointer_transmute` from `complexity` to `suspicious`
ada4a Aug 3, 2025
c945393
fix inf loop
odysa Jun 28, 2025
ac9361e
`eta_reduction`: don't refer to ADT constructors as "function"s
ada4a Aug 7, 2025
d654c26
`eta_reduction`: don't refer to ADT constructors as "function"s (#15436)
samueltardieu Aug 8, 2025
2208884
move `crosspointer_transmute` from `complexity` to `suspicious` (#15403)
samueltardieu Aug 8, 2025
82c1ce7
misc: use let-chains
ada4a Aug 8, 2025
7057cd8
Correct `needless_borrow_for_generic_args` doc comment
smoelius Aug 8, 2025
388d3f3
use a let-chain in `needless_bool` (#15444)
samueltardieu Aug 8, 2025
0a70523
remove `P`
fee1-dead Aug 9, 2025
d5f2b66
`expect_fun_call`: move helper functions out of the main one
ada4a Aug 7, 2025
ea7ebaa
Do not attempt to compute size of a type with escaping lifetimes (#15…
Jarcho Aug 9, 2025
386372a
[[infinite_loop] fix infinite loop false positive (#15157)
dswij Aug 9, 2025
5c617b4
Add "PowerPC" to the list of valid CamelCase strings in docs
autarch Aug 9, 2025
aeec153
Update CONTRIBUTING.md to use RustRover instead of IntelliJ Rust
reddevilmidzy Aug 9, 2025
e622300
Add "PowerPC" to the list of valid CamelCase strings in docs (#15447)
Alexendoo Aug 9, 2025
04606e2
introduce `path_to_local_with_projections`
ada4a Aug 2, 2025
f3ced4d
`expect_fun_call`: move helper functions out of the main one (#15446)
llogiq Aug 9, 2025
e6b63d1
fix &str type check in `from_str_radix_10` (#15410)
samueltardieu Aug 9, 2025
a5469b8
Constify remaining operators
clarfonthey Jul 15, 2025
14dfc03
feat: introduce `path_to_local_with_projections` (#15396)
y21 Aug 10, 2025
7dd3ecb
Update CONTRIBUTING.md to use RustRover instead of IntelliJ Rust (#15…
Alexendoo Aug 10, 2025
a43e386
Adjust `declare_interior_mutable_const` lint's category
SomeoneToIgnore Aug 11, 2025
2293095
doc: use `is_some_and` instead of `map_or(false, _)`
ada4a Aug 11, 2025
02eb548
doc: use `is_some_and` instead of `map_or(false, _)` (#15455)
flip1995 Aug 11, 2025
1f9a6ad
Correct `needless_borrow_for_generic_args` doc comment (#15440)
blyxyas Aug 11, 2025
696d96d
Update actions/checkouts to v5
alex-semenyuk Aug 11, 2025
2ba5fe8
Get myself off assignment rotation
samueltardieu Aug 11, 2025
dfbbeee
Get myself off assignment rotation (#15459)
samueltardieu Aug 11, 2025
874f1c8
Update actions/checkouts to v5 (#15457)
flip1995 Aug 11, 2025
bec5346
fix clippy test
estebank Aug 11, 2025
c8c483d
Account for new `assert!` desugaring in `!condition` suggestion
estebank Aug 11, 2025
7fe9a40
Extract ast TraitImplHeader
camsteffen Jul 22, 2025
9f98857
Propagate TraitImplHeader to hir
camsteffen Jul 24, 2025
fe086d7
misc: take `span` as the last parameter
ada4a Aug 11, 2025
9ea90b3
add test case for a method
ada4a Aug 11, 2025
abfc498
give the test functions more complex signatures
ada4a Aug 11, 2025
68c1574
make no_mangle explicit on foreign items
jdonszelmann Jul 29, 2025
2dd7208
Rollup merge of #145238 - estebank:attr-overhaul, r=jdonszelmann
Zalathar Aug 12, 2025
12087f1
Rollup merge of #145273 - estebank:not-not, r=samueltardieu
Zalathar Aug 12, 2025
f2f0665
Revert "Partially outline code inside the panic! macro".
m-ou-se Aug 12, 2025
49666f6
`too_many_lines`: only highlight the function signature
ada4a Aug 11, 2025
a493e27
Auto merge of #144678 - jdonszelmann:no-mangle-extern, r=bjorn3
bors Aug 12, 2025
e7e18a3
clippy: Update for switch to `MacroKinds`
joshtriplett Aug 9, 2025
0a522cc
Change the desugaring of `assert!` for better error output
estebank Mar 17, 2024
af2dd2d
fix `unnecessary_semicolon`: don't lint on stmts with attrs
ada4a Aug 12, 2025
7f23aba
get `DefId` from `AdtDef` instead of `expect`ing
ada4a Aug 12, 2025
8725fac
misc: use `Ty::is_unit`
ada4a Aug 12, 2025
306d4e3
fix `unnecessary_semicolon`: don't lint on stmts with attrs (#15466)
dswij Aug 12, 2025
e28266d
Bump slab from 0.4.10 to 0.4.11 in /clippy_test_deps
dependabot[bot] Aug 13, 2025
d42a48d
Rollup merge of #144870 - Kivooeo:file_prefix-stabilize, r=tgross35
Kobzol Aug 13, 2025
f0bb5cd
`as_ptr_cast`: move the unfixable case into a separate file
ada4a Aug 13, 2025
ad9686e
test: move the main file to `unfixable`
ada4a Aug 13, 2025
ff2b5e6
test: make `suggestions` the main file
ada4a Aug 13, 2025
e6f3cb0
move `char_lit_as_u8` into the `if`
ada4a Aug 13, 2025
cb3dedc
Update clippy tests
petrochenkov Aug 13, 2025
cf42ac6
Rollup merge of #145153 - joshtriplett:macro-kinds-plural, r=petroche…
GuillaumeGomez Aug 13, 2025
6659540
move `char_lit_as_u8` under the explicit-cast case (#15477)
Jarcho Aug 13, 2025
355e4ba
`as_ptr_cast`: move the unfixable case into a separate file (#15475)
Jarcho Aug 13, 2025
371b174
misc: move `is_expr_temporary_value` check into let-chain
ada4a Aug 13, 2025
bc0e43c
fix `borrow_as_ptr`: don't lint in proc-macros
ada4a Aug 13, 2025
e19a11f
misc: import macros explicitly
ada4a Aug 13, 2025
b3faf62
Bump slab from 0.4.10 to 0.4.11 in /clippy_test_deps (#15471)
flip1995 Aug 13, 2025
e7d8d34
Auto merge of #144793 - petrochenkov:extprel3, r=davidtwco
bors Aug 13, 2025
05c2d72
fix: `match_ref_pats` FP on match scrutinee of never type
profetia Aug 13, 2025
ca19405
Adjust `declare_interior_mutable_const` lint's category (#15454)
y21 Aug 14, 2025
3e86f05
`result_large_err`: get `DefId` from `AdtDef` instead of `expect`ing …
dswij Aug 14, 2025
871df56
Fix `match_ref_pats` FP on match scrutinee of never type (#15474)
y21 Aug 14, 2025
aeaa348
`unnecessary_operation`: add space between stmts in suggestion (#15432)
y21 Aug 14, 2025
066bdb2
replace with `?`
ada4a Aug 14, 2025
22bbb4e
use `let-else` to reduce nesting
ada4a Aug 14, 2025
210097a
Rollup merge of #122661 - estebank:assert-macro-span, r=petrochenkov
Zalathar Aug 15, 2025
9570ed8
`ptr_as_ptr`: don't allow in proc-macros
ada4a Aug 13, 2025
9563a5c
`{borrow,ptr}_as_ptr`: don't lint inside proc-macros (#15473)
Jarcho Aug 15, 2025
a8b52ba
clean-up `unnecessary_unwrap` a bit
ada4a Aug 14, 2025
aa8b09d
clean-up `unnecessary_unwrap` a bit (#15489)
y21 Aug 16, 2025
cdcce5a
Auto merge of #145304 - m-ou-se:simplify-panic, r=oli-obk
bors Aug 16, 2025
43f832d
use `Option::is_some_and`
ada4a Aug 16, 2025
27784f2
use `str::ends_with`
ada4a Aug 16, 2025
42ddaa3
inline `ctxt`; use `eq_ctxt`
ada4a Aug 16, 2025
8418fb8
shorten `expr_block`
ada4a Aug 16, 2025
e41fb7c
similar_names stop linting for 3-char names
honeyspoon Jun 22, 2025
1fd9504
`similar_names` stop linting for 3-char names (#15100)
blyxyas Aug 16, 2025
fc42a20
Misc `clippy_dev` changes (#14896)
Jarcho Aug 17, 2025
feb18ca
clean-up `collapsible_if` a bit (#15503)
llogiq Aug 17, 2025
73b5a59
Do not suggest to use implicit `DerefMut` on `ManuallyDrop` reached t…
blyxyas Aug 18, 2025
0e4ce7f
`msrv`: replace nested `if`s with guard clauses (#15490)
dswij Aug 18, 2025
64d6f82
Cut needless mut
nickdrozd Aug 18, 2025
9a2076e
Cut needless mut (#15512)
blyxyas Aug 18, 2025
c1dfeea
Prevent impossible combinations in `ast::ModKind`.
nnethercote Aug 19, 2025
54c52e2
extract `duplicate_underscore_argument`, and move it into `functions`
ada4a Aug 17, 2025
e4d9449
`ptr_arg`: clean-up a bit
ada4a Aug 17, 2025
4b2b9c2
bless tests with new lint messages
karolzwolak Apr 28, 2025
5ec13c9
merge pats
ada4a Aug 19, 2025
6de463c
make a big let-chain
ada4a Aug 20, 2025
f177835
fix whatever this is
ada4a Aug 20, 2025
f4c6ab0
fix: `unnecessary_safety_comment` does not lint for the first line
profetia Jul 26, 2025
bea2e2b
Rollup merge of #145590 - nnethercote:ModKind-Inline, r=petrochenkov
jhpratt Aug 21, 2025
763420c
extract `duplicate_underscore_argument`, and move it into `functions`…
y21 Aug 21, 2025
743405d
Do not replace `match` by `if` if any arm contains a binding (#15352)
Alexendoo Aug 21, 2025
0039c64
`ptr_arg`: clean-up a bit (#15507)
y21 Aug 21, 2025
e2a8b5b
Lint to stable/beta lint docs page in diagnostics
Alexendoo Apr 4, 2025
1954d4c
`len_zero`: clean-up a bit (#15518)
Alexendoo Aug 21, 2025
c32c864
Lint to stable/beta lint docs page in diagnostics (#14547)
Alexendoo Aug 21, 2025
c18363c
`too_many_lines`: only highlight the function signature (#15461)
Alexendoo Aug 21, 2025
5cdabad
Add myself back to reviewer rotation
samueltardieu Aug 21, 2025
cca6576
Add myself back to reviewer rotation (#15523)
samueltardieu Aug 21, 2025
27b2c5d
`renamed_function_params`: clean-up a bit
ada4a Aug 17, 2025
9759df6
`renamed_function_params`: clean-up a bit (#15524)
y21 Aug 21, 2025
ffbbbdc
chore: remove redundant word in comment
xihuwenhua Aug 22, 2025
e408b25
chore: remove redundant word in comment (#15530)
flip1995 Aug 22, 2025
6d89c55
Fix`unnecessary_safety_comment` does not lint for the first line (#15…
flip1995 Aug 22, 2025
284b596
Merge remote-tracking branch 'upstream/master' into rustup
flip1995 Aug 22, 2025
567b65e
Ignore unexpected_cfgs warning for bootstrap
flip1995 Aug 22, 2025
9de86f4
Dogfood fixes
flip1995 Aug 22, 2025
60374e2
Bump nightly version -> 2025-08-22
flip1995 Aug 22, 2025
8779679
Rustup (#15531)
flip1995 Aug 22, 2025
9a348e8
Merge commit '877967959ae8da9814df4f2614971f4d784bf53f' into clippy-s…
flip1995 Aug 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/tools/clippy/.github/workflows/clippy_dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false
Expand Down
8 changes: 4 additions & 4 deletions src/tools/clippy/.github/workflows/clippy_mq.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
persist-credentials: false

Expand Down Expand Up @@ -96,7 +96,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
persist-credentials: false

Expand All @@ -114,7 +114,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
persist-credentials: false

Expand Down Expand Up @@ -170,7 +170,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
persist-credentials: false

Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/.github/workflows/clippy_pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false
Expand Down
4 changes: 2 additions & 2 deletions src/tools/clippy/.github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false

- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
ref: ${{ env.TARGET_BRANCH }}
path: 'out'
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/.github/workflows/feature_freeze.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
permissions:
pull-requests: write

# Do not in any case add code that runs anything coming from the the content
# Do not in any case add code that runs anything coming from the content
# of the pull request, as malicious code would be able to access the private
# GitHub token.
steps:
Expand Down
6 changes: 3 additions & 3 deletions src/tools/clippy/.github/workflows/lintcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
fetch-depth: 2
# Unsetting this would make so that any malicious package could get our Github Token
Expand Down Expand Up @@ -80,7 +80,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false
Expand Down Expand Up @@ -113,7 +113,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/.github/workflows/remark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
steps:
# Setup
- name: Checkout
uses: actions/checkout@v4
uses: actions/checkout@v5
with:
# Unsetting this would make so that any malicious package could get our Github Token
persist-credentials: false
Expand Down
12 changes: 6 additions & 6 deletions src/tools/clippy/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ All contributors are expected to follow the [Rust Code of Conduct].
- [High level approach](#high-level-approach)
- [Finding something to fix/improve](#finding-something-to-fiximprove)
- [Getting code-completion for rustc internals to work](#getting-code-completion-for-rustc-internals-to-work)
- [IntelliJ Rust](#intellij-rust)
- [RustRover](#rustrover)
- [Rust Analyzer](#rust-analyzer)
- [How Clippy works](#how-clippy-works)
- [Issue and PR triage](#issue-and-pr-triage)
Expand Down Expand Up @@ -92,22 +92,22 @@ an AST expression).

## Getting code-completion for rustc internals to work

### IntelliJ Rust
Unfortunately, [`IntelliJ Rust`][IntelliJ_rust_homepage] does not (yet?) understand how Clippy uses compiler-internals
### RustRover
Unfortunately, [`RustRover`][RustRover_homepage] does not (yet?) understand how Clippy uses compiler-internals
using `extern crate` and it also needs to be able to read the source files of the rustc-compiler which are not
available via a `rustup` component at the time of writing.
To work around this, you need to have a copy of the [rustc-repo][rustc_repo] available which can be obtained via
`git clone https://github.com/rust-lang/rust/`.
Then you can run a `cargo dev` command to automatically make Clippy use the rustc-repo via path-dependencies
which `IntelliJ Rust` will be able to understand.
which `RustRover` will be able to understand.
Run `cargo dev setup intellij --repo-path <repo-path>` where `<repo-path>` is a path to the rustc repo
you just cloned.
The command will add path-dependencies pointing towards rustc-crates inside the rustc repo to
Clippy's `Cargo.toml`s and should allow `IntelliJ Rust` to understand most of the types that Clippy uses.
Clippy's `Cargo.toml`s and should allow `RustRover` to understand most of the types that Clippy uses.
Just make sure to remove the dependencies again before finally making a pull request!

[rustc_repo]: https://github.com/rust-lang/rust/
[IntelliJ_rust_homepage]: https://intellij-rust.github.io/
[RustRover_homepage]: https://www.jetbrains.com/rust/

### Rust Analyzer
For [`rust-analyzer`][ra_homepage] to work correctly make sure that in the `rust-analyzer` configuration you set
Expand Down
11 changes: 11 additions & 0 deletions src/tools/clippy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,3 +64,14 @@ harness = false
[[test]]
name = "dogfood"
harness = false

# quine-mc_cluskey makes up a significant part of the runtime in dogfood
# due to the number of conditions in the clippy_lints crate
# and enabling optimizations for that specific dependency helps a bit
# without increasing total build times.
[profile.dev.package.quine-mc_cluskey]
opt-level = 3

[lints.rust.unexpected_cfgs]
level = "warn"
check-cfg = ['cfg(bootstrap)']
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
clippy_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v5
- name: Run Clippy
run: cargo clippy --all-targets --all-features
```
4 changes: 2 additions & 2 deletions src/tools/clippy/book/src/development/basics.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ cargo dev new_lint
cargo dev deprecate
# automatically formatting all code before each commit
cargo dev setup git-hook
# (experimental) Setup Clippy to work with IntelliJ-Rust
# (experimental) Setup Clippy to work with RustRover
cargo dev setup intellij
# runs the `dogfood` tests
cargo dev dogfood
```

More about [intellij] command usage and reasons.

[intellij]: https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#intellij-rust
[intellij]: https://github.com/rust-lang/rust-clippy/blob/master/CONTRIBUTING.md#rustrover

## lintcheck

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl LateLintPass<'_> for MyStructLint {
// we are looking for the `DefId` of `Drop` trait in lang items
.drop_trait()
// then we use it with our type `ty` by calling `implements_trait` from Clippy's utils
.map_or(false, |id| implements_trait(cx, ty, id, &[])) {
.is_some_and(|id| implements_trait(cx, ty, id, &[])) {
// `expr` implements `Drop` trait
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/book/src/lint_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ default configuration of Clippy. By default, any configuration will replace the
* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.

**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "MHz", "GHz", "THz", "AccessKit", "CoAP", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "NixOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "MHz", "GHz", "THz", "AccessKit", "CoAP", "CoreFoundation", "CoreGraphics", "CoreText", "DevOps", "Direct2D", "Direct3D", "DirectWrite", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript", "PowerPC", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenAL", "OpenDNS", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenTelemetry", "OpenType", "WebGL", "WebGL2", "WebGPU", "WebRTC", "WebSocket", "WebTransport", "WebP", "OpenExr", "YCbCr", "sRGB", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "NetBSD", "OpenBSD", "NixOS", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`

---
**Affected lints:**
Expand Down
2 changes: 1 addition & 1 deletion src/tools/clippy/clippy_config/src/conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[
"GitHub", "GitLab",
"IPv4", "IPv6",
"ClojureScript", "CoffeeScript", "JavaScript", "PostScript", "PureScript", "TypeScript",
"WebAssembly",
"PowerPC", "WebAssembly",
"NaN", "NaNs",
"OAuth", "GraphQL",
"OCaml",
Expand Down
49 changes: 21 additions & 28 deletions src/tools/clippy/clippy_dev/src/dogfood.rs
Original file line number Diff line number Diff line change
@@ -1,35 +1,28 @@
use crate::utils::exit_if_err;
use std::process::Command;
use crate::utils::{cargo_cmd, run_exit_on_err};
use itertools::Itertools;

/// # Panics
///
/// Panics if unable to run the dogfood test
#[allow(clippy::fn_params_excessive_bools)]
pub fn dogfood(fix: bool, allow_dirty: bool, allow_staged: bool, allow_no_vcs: bool) {
let mut cmd = Command::new("cargo");

cmd.args(["test", "--test", "dogfood"])
.args(["--features", "internal"])
.args(["--", "dogfood_clippy", "--nocapture"]);

let mut dogfood_args = Vec::new();
if fix {
dogfood_args.push("--fix");
}

if allow_dirty {
dogfood_args.push("--allow-dirty");
}

if allow_staged {
dogfood_args.push("--allow-staged");
}

if allow_no_vcs {
dogfood_args.push("--allow-no-vcs");
}

cmd.env("__CLIPPY_DOGFOOD_ARGS", dogfood_args.join(" "));

exit_if_err(cmd.status());
run_exit_on_err(
"cargo test",
cargo_cmd()
.args(["test", "--test", "dogfood"])
.args(["--features", "internal"])
.args(["--", "dogfood_clippy", "--nocapture"])
.env(
"__CLIPPY_DOGFOOD_ARGS",
[
if fix { "--fix" } else { "" },
if allow_dirty { "--allow-dirty" } else { "" },
if allow_staged { "--allow-staged" } else { "" },
if allow_no_vcs { "--allow-no-vcs" } else { "" },
]
.iter()
.filter(|x| !x.is_empty())
.join(" "),
),
);
}
7 changes: 4 additions & 3 deletions src/tools/clippy/clippy_dev/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@
)]
#![allow(clippy::missing_panics_doc)]

// The `rustc_driver` crate seems to be required in order to use the `rust_lexer` crate.
#[allow(unused_extern_crates)]
#[expect(unused_extern_crates, reason = "required to link to rustc crates")]
extern crate rustc_driver;
extern crate rustc_lexer;
extern crate rustc_literal_escaper;
Expand All @@ -32,4 +31,6 @@ pub mod serve;
pub mod setup;
pub mod sync;
pub mod update_lints;
pub mod utils;

mod utils;
pub use utils::{ClippyInfo, UpdateMode};
56 changes: 28 additions & 28 deletions src/tools/clippy/clippy_dev/src/lint.rs
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
use crate::utils::{cargo_clippy_path, exit_if_err};
use std::process::{self, Command};
use crate::utils::{ErrAction, cargo_cmd, expect_action, run_exit_on_err};
use std::process::Command;
use std::{env, fs};

pub fn run<'a>(path: &str, edition: &str, args: impl Iterator<Item = &'a String>) {
let is_file = match fs::metadata(path) {
Ok(metadata) => metadata.is_file(),
Err(e) => {
eprintln!("Failed to read {path}: {e:?}");
process::exit(1);
},
};
#[cfg(not(windows))]
static CARGO_CLIPPY_EXE: &str = "cargo-clippy";
#[cfg(windows)]
static CARGO_CLIPPY_EXE: &str = "cargo-clippy.exe";

pub fn run<'a>(path: &str, edition: &str, args: impl Iterator<Item = &'a String>) {
let is_file = expect_action(fs::metadata(path), ErrAction::Read, path).is_file();
if is_file {
exit_if_err(
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
run_exit_on_err(
"cargo run",
cargo_cmd()
.args(["run", "--bin", "clippy-driver", "--"])
.args(["-L", "./target/debug"])
.args(["-Z", "no-codegen"])
.args(["--edition", edition])
.arg(path)
.args(args)
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
.env("RUSTC_ICE", "0")
.status(),
.env("RUSTC_ICE", "0"),
);
} else {
exit_if_err(
Command::new(env::var("CARGO").unwrap_or_else(|_| "cargo".into()))
.arg("build")
.status(),
);

let status = Command::new(cargo_clippy_path())
.arg("clippy")
.args(args)
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
.env("RUSTC_ICE", "0")
.current_dir(path)
.status();
// Ideally this would just be `cargo run`, but the working directory needs to be
// set to clippy's directory when building, and the target project's directory
// when running clippy. `cargo` can only set a single working directory for both
// when using `run`.
run_exit_on_err("cargo build", cargo_cmd().arg("build"));

exit_if_err(status);
let mut exe = env::current_exe().expect("failed to get current executable name");
exe.set_file_name(CARGO_CLIPPY_EXE);
run_exit_on_err(
"cargo clippy",
Command::new(exe)
.arg("clippy")
.args(args)
// Prevent rustc from creating `rustc-ice-*` files the console output is enough.
.env("RUSTC_ICE", "0")
.current_dir(path),
);
}
}
Loading
Loading