Commit graph

22626 commits

Author SHA1 Message Date
Samuel Tardieu
e16801e68c
Use symbols instead of &str when possible 2025-05-19 22:47:57 +02:00
Samuel Tardieu
82bf659dc8
Ensure that symbols list stays sorted 2025-05-19 22:47:57 +02:00
Samuel Tardieu
bb724f3421
Sort the existing list of symbols 2025-05-19 22:47:57 +02:00
Alejandra González
d4e7e5ba31
Access items through rustc_session instead of rustc_lint_defs (#14852)
Items such as the `declare_tool_lint!()` macro are publicly reexported
from `rustc_lint_defs` to `rustc_session`. Use the latter for
consistency.

changelog: none
2025-05-19 18:17:04 +00:00
Jason Newcomb
e34e8ac42b
cargo dev fmt: format clippy_lints_internal as well (#14853)
changelog: none
r? @Jarcho
2025-05-19 17:22:14 +00:00
Samuel Tardieu
ac7c87e044
Remove obsolete restriction in code (#14851)
changelog: none
2025-05-19 16:56:31 +00:00
Samuel Tardieu
608f6822ca
cargo dev fmt: format clippy_lints_internal as well 2025-05-19 18:10:59 +02:00
Samuel Tardieu
e2b1de107f
Access items through rustc_session instead of rustc_lint_defs
Items such as the `declare_tool_lint!()` macro are publicly reexported
from `rustc_lint_defs` to `rustc_session`. Use the latter for
consistency.
2025-05-19 18:05:34 +02:00
Samuel Tardieu
db42c7dddc
Remove obsolete restriction in code 2025-05-19 17:50:22 +02:00
Samuel Tardieu
ebc2a68fe8
Add new useless_concat lint (#13829)
Fixes #13793.

Interestingly enough, to actually check that the macro call has at least
two arguments, we need to use the rust lexer after getting the original
source code snippet.

changelog: Add new `useless_concat` lint
2025-05-19 15:11:37 +00:00
Alejandra González
df33aaf540
Check if dropping an expression may have indirect side-effects (#14594)
It is not enough to check if an expression type implements `Drop` to
determine whether it can have a significant side-effect.

Also, add tests for unchecked cases which were explicitly handled in the
code, such as checking for side effect in a `struct`'s fields, or in its
base expression.

Fix rust-lang/rust-clippy#14592

changelog: [`no_effect_underscore_binding`]: do not propose to remove
the assignment of an object if dropping it might indirectly have a
visible side effect
2025-05-19 11:41:40 +00:00
Samuel Tardieu
d44e35d595
Docs: Use spaces in good first issue label (#14844)
This unifies the Clippy repo with the rest of the rust org repos.

changelog: none
2025-05-19 07:55:42 +00:00
Philipp Krones
7123f2acf7
Docs: Use spaces in good first issue label
This unifies the Clippy repo with the rest of the rust org repos.
2025-05-19 09:37:47 +02:00
Samuel Tardieu
375c65030b
fix: unnecessary_to_owned FP when map key is a reference (#14834)
Closes rust-lang/rust-clippy#14833

changelog: [`unnecessary_to_owned`] fix FP when map key is a reference
2025-05-18 19:49:20 +00:00
llogiq
b03370b9ce
Add a reason to/remove some //@no-rustfix annotations (#14839)
changelog: none
2025-05-18 18:53:22 +00:00
yanglsh
492c4e197d fix: unnecessary_to_owned FP when map key is a reference 2025-05-19 00:27:53 +08:00
Alex Macleod
19e967c6b7 Add a reason to/remove some //@no-rustfix annotations 2025-05-18 16:15:43 +00:00
Alex Macleod
618ccd7f03
Do not call TyCtxt::type_of() on a trait (#14830)
changelog: [`useless_as_ref`]: fix ICE on trait method

Fixes rust-lang/rust-clippy#14828
2025-05-18 12:22:57 +00:00
Samuel Tardieu
15d47d74bf
Fixing minor typo in book (#14835)
fix minor typo in book: toolcahin => toolchain

changelog: none
2025-05-18 08:42:27 +00:00
Pete LeVasseur
1e3fc3cc46 fix minor typo: toolcahin => toolchain
changelog: none
2025-05-18 17:26:28 +09:00
Samuel Tardieu
b7caa1b3e0
Do not call TyCtxt::type_of() on a trait 2025-05-18 09:38:19 +02:00
Timo
da7b678992
empty_struct_with_brackets: do not lint code coming from macro expansion (#14623)
Do not attempt to fetch a snippet from expansion. Without this change,
the inside of macros could[*] be shown as the source of the problem.

[*] Due to the way the source code is processed and reparsed in this
macro, the declarative macro has to be located outside the current
source file for the bug to appear. Otherwise, the macro call itself will
be (mis)identified as a potential `struct` field definition and the lint
will not trigger.

changelog: [`empty_struct_with_brackets`]: do not lint code coming from
macro expansion
2025-05-17 10:43:54 +00:00
Timo
daeb6a1d18
Misc changes (#14702)
This mainly fixes `with_leading_whitespace` not always adding the
whitespace it can.

changelog: None
2025-05-17 10:40:21 +00:00
Samuel Tardieu
9ebfb84fe0
Refactor and speed up cargo dev fmt (#14638)
Based on rust-lang/rust-clippy#14616

`cargo dev fmt` should now run almost instantly rather than taking a few
seconds.

changelog: None
2025-05-17 10:16:07 +00:00
Jason Newcomb
232be55859 clippy_dev: refactor rustfmt calls 2025-05-17 06:11:19 -04:00
Jason Newcomb
9d47e0c8ce clippy_dev: remove the need for markers when bumping the version 2025-05-17 04:27:39 -04:00
Samuel Tardieu
c97b4761d8
excessive_precision: Fix false positive when exponent has leading zero (#14824)
Fixes rust-lang/rust-clippy#6341.

changelog: [`excessive_precision`] no longer triggers on an exponent
with leading zeros
2025-05-17 05:56:05 +00:00
Michael Hackner
e666b83b11 excessive_precision: Fix false positive when exponent has leading zero 2025-05-16 21:35:09 -07:00
Samuel Tardieu
dcd8bb6d7e
Skip inner ordering checking in presence of #[repr(…)] (#14610)
A representation attribute `#[repr(…)]` might indicate that the ordering
of the fields or the variants is dictated by the API the code is
interfacing with. Better not lint with `arbitrary_source_item_ordering`
in this case.

changelog: [`arbitrary_source_item_ordering`]: do not lint inside items
with `#[repr]` attribute
2025-05-16 19:34:32 +00:00
Samuel Tardieu
604b7b0c5c
Extend cargo dev rename_lint (#14633)
Based on rust-lang/rust-clippy#14616

Extends `rename_lint` to handle more cases and makes `update_lints` sort
`deprecated_lints.rs`.

changelog: None
2025-05-16 15:06:30 +00:00
llogiq
94cfebb397
Rewrite non_copy_const (#13207)
fixes #12979
fixes #12951
fixes #13233

Tests still need to be finished and the docs still need to be updated,
but this should otherwise ready.

changelog: Lint `declare_interior_mutable_const` and
`borrow_interior_mutable_const` more precisely
2025-05-16 15:05:36 +00:00
llogiq
5cb7e4039e
Reenable linting on UFCS deref calls (#14808)
Was disabled in rust-lang/rust-clippy#10855 due to a broken suggestion.
This will only lint if a type is not proveded (e.g. `T::deref`).

changelog: none
2025-05-16 14:47:34 +00:00
Alejandra González
5239b7fa2c
unnecessary_wraps: do not include the whole body in the lint span (#14777)
Using the function declaration, by stripping the body, is enough to
convey the lint message.

changelog: [`unnecessary_wraps`]: do not include the whole body in the
lint span

Closes rust-lang/rust-clippy#14773
2025-05-16 14:24:58 +00:00
Samuel Tardieu
feb70b51c4
match_same_arms, ifs_same_cond: lint once per same arm/condition (#14637)
A large fraction of the lints emitted in CI lintcheck come from [this
`match`](https://github.com/unicode-rs/unicode-normalization/blob/v0.1.23/src/tables.rs#L34289),
currently for `n` same arms `((n - 1) * n)/2` lints are emitted, with
this change it will be emitted as a single lint

Also fixes https://github.com/rust-lang/rust-clippy/issues/13835

changelog: none
2025-05-16 14:16:45 +00:00
Alex Macleod
39ab00a3a1 match_same_arms, ifs_same_cond: lint once per same arm/condition 2025-05-16 12:56:25 +00:00
Jason Newcomb
27acbf2c66 Reenable linting on UFCS deref calls. 2025-05-16 06:45:08 -04:00
Jason Newcomb
13b070e356 clippy_dev: Fix previous renames in rename_lint 2025-05-16 06:43:55 -04:00
Jason Newcomb
b3f490202b clippy_dev: order deprecated_lints.rs in update_lints 2025-05-16 06:43:52 -04:00
Jason Newcomb
44681fd81b Improve cargo dev rename_lint
* rename test files inside directories and ui-toml tests
* rename tests prefixed with the lint's name
* better module path renaming when renaming the lint's module
* partially delete lint files when uplifting
* rename ui_test error markers
2025-05-16 06:20:13 -04:00
Jason Newcomb
318ba60cfb Rewrite tests for declare_interior_mutable_const and
`borrow_interior_mutable_const` to be more thorough on weird constructs
2025-05-16 06:08:41 -04:00
Jason Newcomb
7c41ec7395 Reword declare_interior_mutable_const and
`borrow_interior_mutable_const` messages to be less assertive.
Update documentation for both lints.
2025-05-16 06:08:40 -04:00
Jason Newcomb
57782e0ff1 Rewrite non_copy_const 2025-05-16 06:08:35 -04:00
llogiq
95d7eda0b4
comparison_chain: do not lint on 2 blocks expression (#14811)
Clippy should not lint 2 blocks expression for comparison_chain.

Fixes rust-lang/rust-clippy#4725

changelog: [`comparison_chain`]: do not lint 2 blocks expression
2025-05-16 06:52:35 +00:00
llogiq
ff5e626837
Fix false positive of useless_conversion when using .into_iter().any() (#14800)
Fixes: rust-lang/rust-clippy#14656

changelog: Fix [`useless_conversion`] false positive when using
`.into_iter().any()`.
2025-05-16 06:49:42 +00:00
Samuel Tardieu
a1931dd7cc
unnecessary_wraps: do not include the whole body in the lint span
Using the function declaration, by stripping the body, is enough to
convey the lint message.
2025-05-15 19:37:06 +02:00
Philipp Krones
0450db33a5
Rustup (#14815)
r? @ghost

changelog: none
2025-05-15 17:24:57 +00:00
Philipp Krones
367073195a
Bump Clippy version -> 0.1.89 2025-05-15 19:19:46 +02:00
Philipp Krones
5be888c479
Bump nightly version -> 2025-05-14 2025-05-15 19:19:34 +02:00
Philipp Krones
0bb1b5bd3b
Merge remote-tracking branch 'upstream/master' into rustup 2025-05-15 19:19:08 +02:00
Georges Savoundararadj
34c6ba7354 comparison_chain: do not lint on 2 blocks expression
Clippy should not lint 2 blocks expression for comparison_chain.
2025-05-15 12:57:19 +02:00