Commit graph

22852 commits

Author SHA1 Message Date
Samuel Tardieu
0fdd0b928e
Add integer_const() and is_zero_integer_const() utility functions 2025-06-20 09:42:27 +02:00
Samuel Tardieu
8ec6f1a96f
Fix suggestion-cases-error of empty_line_after_outer_attr (#15078)
Fixes: rust-lang/rust-clippy#14980

changelog: Fix suggestion-cases-error of [`empty_line_after_outer_attr`]
2025-06-20 07:12:49 +00:00
relaxcn
95778b554d Fix suggestion-cases-error of empty_line_after_outer_attr 2025-06-20 07:07:51 +00:00
llogiq
62fd159a5d
Fix non_copy_const ICE (#15083)
fixes rust-lang/rust-clippy#15069

----

changelog: none
2025-06-19 20:46:45 +00:00
Samuel Tardieu
59291a75df
Fix clippy::question_mark on let-else with cfg (#15082)
Fixes rust-lang/rust-clippy#13642

changelog: Fix false positive in [`question_mark`] when else branch of
let-else contains `#[cfg]`
2025-06-19 20:34:05 +00:00
Jason Newcomb
ac8f50473c Fix non_copy_const ICE 2025-06-19 16:03:21 -04:00
Samuel Tardieu
db32d3980b
Fix typo (#15081)
Add missing word (attribute) after the `#[expect]` attribute.

changelog: [`allow_attributes`]: Fix typo in documentation
2025-06-19 19:05:12 +00:00
Max Siling
4aa93a1129
Fix clippy::question_mark on let-else with cfg 2025-06-19 21:55:35 +03:00
Jason Newcomb
498562df52
Check MSRV before suggesting applying const to a function (#15080)
If a function environment contains trait bounds other than `Sized`,
`const` cannot be used before Rust 1.61.

changelog: [`missing_const_for_fn`]: check MSRV before emitting lint on
function containing non-`Sized` trait bounds

Fixes rust-lang/rust-clippy#15079

r? Jarcho
2025-06-19 18:34:13 +00:00
Everett Pompeii
9c8f3e9b11
Fix typo
Add missing word (attribute) after the `#[expect]` attribute.
2025-06-19 10:26:08 -05:00
Catherine Flores
d8e99530c8
Fix exhaustive_structs FP on structs with default valued field (#15022)
Closes rust-lang/rust-clippy#14992

changelog: [`exhaustive_structs`] fix FP on structs with default valued
field
2025-06-19 13:38:28 +00:00
Samuel Tardieu
6524bf78b6
Check MSRV before suggesting applying const to a function
If a function environment contains trait bounds other than `Sized`,
`const` cannot be used before Rust 1.61.
2025-06-19 15:26:36 +02:00
Alex Macleod
10780e9122
Prepare to split clippy_lints (#14684)
Based on rust-lang/rust-clippy#14633

The end goal here is to split `clippy_lints` into several independent
crates and have the driver call out to each of them to register lints.
`clippy_lints` takes way too long to compile right now.

r? @flip1995

changelog: none
2025-06-19 11:30:32 +00:00
Jason Newcomb
acd8810e77 Prepare to split lints into multiple crates
* Move `declare_clippy_lint` to it's own crate
* Move lint/group registration into the driver
* Make `dev update_lints` handle multiple lint crates
2025-06-18 22:37:23 -04:00
Samuel Tardieu
19c1c70905
Add allow-invalid configuration option for disallowed_* to the documentation (#14845)
Close rust-lang/rust-clippy#14836

changelog: none
2025-06-17 09:05:05 +00:00
Timo
b765acb49d
docs: add link to span_lint in diagnostics.rs. (#15065)
Some of the docs in `clippy_utils/src/diagnostics.rs` were missing links
to `span_lint`.

changelog: none
2025-06-16 21:52:28 +00:00
Chris Bloodsworth
75762c41d4 docs: add link to span_lint in diagnostics.rs.
changelog: None
2025-06-16 17:36:02 -04:00
Jason Newcomb
af9d56860e
Add lint for broken doc links (#13696)
fixes https://github.com/rust-lang/rust-clippy/issues/2179

changelog: [`doc_broken_link`]: Add pedantic lint to catch broken doc
links that won't produce a link tag by rustdoc.
2025-06-16 15:19:03 +00:00
Samuel Tardieu
4d67a1c64a
Fix FP of identity_op when encountering Default::default() (#15028)
Fixes: rust-lang/rust-clippy#14932

changelog: Fix false positive of [`identity_op`] when encountering
`Default::default()`.
2025-06-15 22:16:14 +00:00
dswij
97815d0cda
docs: make unbuffered_bytes docs more consistent (#15019)
changelog: None
2025-06-14 18:05:34 +00:00
dswij
49d0f86a73
Remove unneeded lifetime (#15040)
changelog: none
2025-06-14 17:40:22 +00:00
dswij
086a7c9780
Fix needless_doctest_main panic when doctest is invalid (#15052)
Closes rust-lang/rust-clippy#8244
Closes rust-lang/rust-clippy#15041

This feels like a bug with the compiler, because the panic happens when
`Diag` is getting unwinded. However, `drop()` is already called in
`.cancel()` so this should not happen.

In this PR, I find a workaround to just call `emit()`, since the
`DiagCtxt` here is just a `io::sink`, nothing will happen and the panic
just goes away.

changelog: [`needless_doctest_main`] fix panic when doctest is invalid
2025-06-14 15:58:39 +00:00
relaxcn
2dfab750e7 fix ci/cd error 2025-06-14 17:24:09 +08:00
yanglsh
7d708a45af fix: needless_doctest_main panic when doctest is invalid 2025-06-14 15:04:19 +08:00
relaxcn
bf1a276db3 make it support more cases 2025-06-14 04:58:47 +08:00
yanglsh
535b0d5708 fix: exhaustive_structs FP on structs with default valued field 2025-06-14 01:19:12 +08:00
Samuel Tardieu
506411d9d1
Fix collapsible_else_if FP on conditionally compiled stmt (#14906)
Closes rust-lang/rust-clippy#14799

changelog: [`collapsible_else_if`] fix FP on conditionally compiled stmt
2025-06-13 15:45:00 +00:00
yanglsh
ee80deb723 Apply collapsible_else_if to Clippy itself 2025-06-13 22:55:06 +08:00
yanglsh
fea8dd28a0 Lint more cases in collapsible_else_if 2025-06-13 22:54:59 +08:00
Philipp Krones
4ef75291b5
Rustup (#15044)
r? @ghost

changelog: none
2025-06-13 08:22:55 +00:00
Philipp Krones
19c2f0332c
Bump nightly version -> 2025-06-13 2025-06-13 10:17:27 +02:00
Philipp Krones
85655d4a09
Merge remote-tracking branch 'upstream/master' into rustup 2025-06-13 10:17:14 +02:00
Samuel Tardieu
6662aedb86
[PERF] Optimize 3rd heaviest func, (81b -> 10m) (#15043)
So this is funny, the query `tcx.module_children` was top 3 in most
time consuming functions in Clippy, it was being called 24384 times in
tokio. "Unacceptable!" I thought. Digging a bit around, turns out that
`clippy::strlen_on_c_strings` was calling for `get_def_path` via
`match_libc_symbol`. This query pretty-prints things and performs some
analysis.

Yes, we were running early lint checks to see if symbols were from
`libc`.
I don't really trust callgrind when it says I've turn 81 billion
instructions
into like 10 million. So I benchmarked this the good ol' "compiling 20
times
without incr" method and it went from 0.31s-0.45s to 0.25s
constistently.

(Profiled, and "benchmarked") on tokio.

What I can get behind is via `strlen_on_c_strings` changing from 31
million instructions into 76k. 🎉 🥳

changelog: [`strlen_on_c_strings`]: Optimize it by 99.75%
2025-06-13 06:09:14 +00:00
blyxyas
6cd55b966f Optimize by 99.75% strlen_on_c_strings, 8.5% globally
So this is funny, the query `tcx.module_children` was top 3 in most
time consuming functions in Clippy, it was being called 24384 times in
tokio. "Unacceptable!" I thought. Digging a bit around, turns out that
`clippy::strlen_on_c_strings` was calling for `get_def_path` via
`match_libc_symbol`. This query pretty-prints things and performs some
analysis.

Yes, we were running early lint checks to see if symbols were from `libc`.
I don't really trust callgrind when it says I've turn 81 billion instructions
into like 10 million. So I benchmarked this the good ol' "compiling 20 times
without incr" method and it went from 0.31s-0.45s to 0.25s constistently.

(Profiled, and "benchmarked") on tokio.
2025-06-13 02:08:35 +02:00
Samuel Tardieu
59d8345852
Fix suggestion-causes-error of manual_swap (#14978)
Fixes: rust-lang/rust-clippy#14931

changelog: Fix [`manual_swap`]'s suggestion-causes-error when the
variable is mutable or as loop variable.
2025-06-12 23:21:32 +00:00
Samuel Tardieu
180adb3eb2
Fix unit_arg suggests wrongly for Default::default (#14881)
Closes rust-lang/rust-clippy#14857

changelog: [`unit_arg`] fix wrong suggestion for `Default::default`
2025-06-12 23:21:07 +00:00
Samuel Tardieu
ce8d263874
Fixes manual_flatten removes the useless if let (#14861)
Closes rust-lang/rust-clippy#14692

The suggestion of `manual_flatten` does not includes the replacement of
`if let` so far despite of `.flatten()` suggestion.
This PR eliminates a redundant `if let`.

changelog: [`manual_flatten`] the suggestion removes `if let`
2025-06-12 23:20:25 +00:00
Samuel Tardieu
0d21f087df
Remove unneeded lifetime 2025-06-12 22:27:22 +02:00
Alejandra González
6d7c16a3d6
Remove ClippyCtfe pass (#14712)
It doesn't seem to be load bearing for any clippy lints and the rustc
ones that no longer appear behave the same as they would for a `cargo
check`

r? @blyxyas

changelog: none
2025-06-11 22:14:03 +00:00
relaxcn
7cb7e28c4d Fix FP of identity_op when encountering Default::default() 2025-06-12 00:37:05 +08:00
donkomura
358b80cc1f
Fix manual_flatten removes the useless if let
The suggestion of `manual_flatten` does not includes the replacement
of `if let` so far despite of `.flatten()` suggestion. This change
eliminates a redundant `if let`.

changelog: [`manual_flatten`] the suggestion removes `if let`
2025-06-09 22:00:55 +09:00
Boot0x7c00
4389e177eb optimize codes 2025-06-09 03:05:28 +00:00
nekename
982abc48b3
docs: make unbuffered_bytes docs more consistent 2025-06-08 18:37:39 +01:00
llogiq
9e7782b809
Fix match_single_binding misses curlies on type signatures (#15017)
Closes rust-lang/rust-clippy#14991

----

changelog: [`match_single_binding`] fix missing curlies on type
signatures
2025-06-08 13:21:14 +00:00
Alex Macleod
3af333e346
Fix create_dir ignores paths in suggestions (#15011)
Closes rust-lang/rust-clippy#14994

changelog: [`create_dir`] fix missing paths in suggestions
2025-06-08 13:07:59 +00:00
yanglsh
b5eac24820 fix: match_single_binding misses curlies on type signatures 2025-06-08 20:19:24 +08:00
llogiq
737b8be34d
Fix std_instead_of_core FP when part of the use cannot be replaced (#15016)
Closes rust-lang/rust-clippy#14982

----

changelog: [`std_instead_of_core`] fix FP when part of the `use` cannot
be replaced
2025-06-08 11:58:08 +00:00
yanglsh
d98070dbdb fix: std_instead_of_core FP when part of the use cannot be replaced 2025-06-08 19:31:15 +08:00
llogiq
a1a1393171
Invert suggestion if pointer is tested for non-nullness (#15015)
Fixes rust-lang/rust-clippy#15010

----

changelog: [`cmp_null`]: emit proper suggestion when pointer is checked
for non-nullness
2025-06-08 08:57:45 +00:00
Samuel Tardieu
f397a302a9
Invert suggestion if pointer is tested for non-nullness 2025-06-08 10:29:30 +02:00