Commit graph

23968 commits

Author SHA1 Message Date
Ada Alakbarova
097f2fd2f4
add missing test for macros
The missing external macro test for `non_canonical_clone_impl` was
caught thanks to lintcheck -- I went ahead and added all the other
combinations of the test while at it
2025-10-11 09:24:58 +02:00
Samuel Tardieu
ebbbbebf2d
Replace all item identification utils (#15682)
This introduces a new way of identifying items/paths using extension
traits with a composable set of functions rather than unique functions
for various combinations of starting points and target items. Altogether
this is a set of five traits:

* `MaybeTypeckRes`: Allows both `LateContext` and `TypeckResults` to be
used for type-dependent lookup. The implementation here will avoid ICEs
by returning `None` when debug assertions are disabled. With assertions
this will assert that we don't silently lookup anything from a different
body than the current one and that a definition actually exists.
* `HasHirId`: Simply a convenience to allow not typing `.hir_id` at call
sites.
* `MaybeQPath`: This is the old `MaybePath`. Extension functions for
type-dependent path lookups exist here. A lot of these functions aren't
used in the current PR, but what they accomplish is done in various
places I haven't cleaned up yet.
* `MaybeResPath`: Like `MaybeQPath`, but only does non-type-dependent
lookup (`QPath::Resolved`).
* `MaybeDef`: Extension functions for identifying the current definition
and accessing properties. Implemented for several types for convenience.

`MaybeDef` is implemented for `Option` to allow chaining methods
together. e.g.
`cx.ty_based_def(e).opt_parent(cx).opt_impl_ty(cx).is_diag_item(..)`
would chaining `and_then` or `if let` on every step. `MaybeQPath` and
`MaybeResPath` are also implemented for `Option` for the same reason.

`ty_based_def` is just a shorter name for `type_dependent_def`. I'm not
really attached to it, but it's nice that it's a little shorter.

changelog: none
2025-10-11 07:03:12 +00:00
Jason Newcomb
42f2ba1869
fix(zero_repeat_side_effects): don't suggest unsuggestable types (#15815)
Fixes https://github.com/rust-lang/rust-clippy/issues/14998

changelog: [`zero_repeat_side_effects`]: don't suggest unsuggestable
types
2025-10-11 04:15:13 +00:00
Jason Newcomb
6bfb524e9a Remove is_trait_item 2025-10-10 23:15:59 -04:00
Jason Newcomb
e69d88bb10 Remove is_trait_method 2025-10-10 23:15:59 -04:00
Jason Newcomb
d0be3356ba Remove is_inherent_method_call 2025-10-10 23:12:44 -04:00
Jason Newcomb
e78f86d550 Remove is_diag_item_method 2025-10-10 23:09:26 -04:00
Jason Newcomb
2e6729ea64 Remove is_diag_trait_item 2025-10-10 23:09:26 -04:00
Jason Newcomb
a6078f87db Remove path_to_local_id 2025-10-10 23:09:26 -04:00
Jason Newcomb
53675ce061 Remove path_to_local 2025-10-10 23:09:26 -04:00
Jason Newcomb
3f686a074d Remove is_res_lang_ctor 2025-10-10 23:00:17 -04:00
Jason Newcomb
3ed7aa0d5f Remove path_def_id 2025-10-10 23:00:17 -04:00
Jason Newcomb
5b659ba0b4 Remove path_res 2025-10-10 22:51:33 -04:00
Jason Newcomb
53783de8f0 Remove MaybePath 2025-10-10 22:51:33 -04:00
Jason Newcomb
e1a4c90f61 Remove get_type_diagnostic_name 2025-10-10 22:47:41 -04:00
Jason Newcomb
083b1c1059 Remove is_type_lang_item 2025-10-10 22:44:01 -04:00
Jason Newcomb
fe13e0675a Remove is_type_ref_to_diagnostic_item 2025-10-10 22:41:10 -04:00
Jason Newcomb
4914f5908f Remove is_type_diagnostic_item 2025-10-10 22:41:10 -04:00
Jason Newcomb
cb32444ee6 Remove is_path_diagnostic_item 2025-10-10 22:30:57 -04:00
Jason Newcomb
d32ef64ed5 Remove is_path_lang_item 2025-10-10 22:30:57 -04:00
Jason Newcomb
748a593a7f Add new utils for defninition identification. 2025-10-10 22:30:25 -04:00
Samuel Tardieu
70d5c8c9e4
Autolabel PR touching declared_lints.rs with needs-fcp (#15859)
changelog: none
2025-10-10 20:09:34 +00:00
Samuel Tardieu
6a08a85b06
Autolabel PR touching declared_lints.rs with needs-fcp 2025-10-10 18:19:00 +02:00
Alejandra González
844fadbb7e
Check structs and enums for use_self (#15566)
Closes rust-lang/rust-clippy#15555

changelog: [`use_self`]: Check structs and enums
2025-10-09 23:42:49 +00:00
Nick Drozd
b71fe9254d Check structs and enums for use_self 2025-10-09 18:23:12 -05:00
Alejandra González
57913b4737
Honor allow/expect attributes on ADT and impl Clone nodes (#15849)
changelog: [`expl_impl_clone_on_copy`]: honor `allow`/`expect`
attributes on both the type declaration and the `impl`

Fixes rust-lang/rust-clippy#15842

r? @blyxyas
2025-10-09 22:09:37 +00:00
Alejandra González
77ce8b81f0
Mark blyxyas on vacation (#15856)
I'll still take care of my currently-assigned reviews.
Edit: Sorry Philipp, I forgot to r? ghost

changelog:none
2025-10-09 21:59:58 +00:00
llogiq
e6febbd13b
Add lint unnecessary_option_map_or_else (#14662)
changelog: [`unnecessary_option_map_or_else`]: Added lint
unnecessary_option_map_or_else. As suggested in the issue description,
the implementation takes as reference the issue
rust-lang/rust-clippy#7328. The tests for lints `option_if_let_else` and
`or_fun_call` needed to be adjusted to comply with new lint.
fixes rust-lang/rust-clippy#14588
2025-10-09 21:56:14 +00:00
blyxyas
343e7806ea Mark blyxyas on vacation 2025-10-09 23:54:11 +02:00
Timo
99b810634e
Cleanup: do not handle methods from several places (#15751)
Some methods lints were handled in the `methods` module outside the
`check_methods()` function.

changelog: none
2025-10-09 09:26:13 +00:00
Samuel Tardieu
c425389f18
Cleanup: do not handle methods from several places
Some methods lints were handled in the `methods` module outside the
`check_methods()` function.
2025-10-09 06:45:30 +02:00
Timo
e70b206665
chore: multipart_suggestions for manual_assert (#13787)
This should address
https://github.com/rust-lang/rust-clippy/issues/13099 for the let_unit
test.

changelog: [manual_assert]: Updated manual_assert to use
multipart_suggestions where appropriate
2025-10-08 21:32:11 +00:00
Samuel Tardieu
69bd890ff1
Honor allow/expect attributes on ADT and impl Clone nodes 2025-10-08 22:02:14 +02:00
Samuel Tardieu
c5a96d49e4
perf(get_unwrap): avoid calling is_type_diagnostic_item multiple times (#15847)
changelog: none
2025-10-08 19:43:59 +00:00
Ada Alakbarova
80b886e895
perf(get_unwrap): avoid calling is_type_diagnostic_item multiple times 2025-10-08 19:27:51 +02:00
Alex Macleod
7b0c3d02c8
refactor(obfuscated_if_else): make a bit more type-safe (#15846)
changelog: none
2025-10-08 16:58:54 +00:00
Ada Alakbarova
d1be6d810b
Make obfuscated_if_else a bit more type-safe 2025-10-08 18:29:29 +02:00
Scott Gerring
8ef90574a2
chore: update manual_assert span suggestions 2025-10-08 11:58:50 +01:00
Samuel Tardieu
30c73fef62
replace_box: clean-up a bit (#15834)
changelog: none
2025-10-07 17:03:03 +00:00
Ada Alakbarova
01d2adc2f9
replace get_box_inner_type with Ty::boxed_ty 2025-10-07 18:31:46 +02:00
Ada Alakbarova
e5e3bbd9a1
extend the let-chain 2025-10-07 18:31:46 +02:00
Samuel Tardieu
f110f3412d
Fix needless_continue FP when match type is not unit or never (#15547)
Closes rust-lang/rust-clippy#14550
Closes rust-lang/rust-clippy#15548

changelog: [`needless_continue`] fix FP when match type is not unit or
never
2025-10-07 16:24:56 +00:00
yanglsh
13bd9b5d0f fix: needless_continue wrongly unmangled macros 2025-10-08 00:03:48 +08:00
yanglsh
7117bd9a27 fix: needless_continue FP when match type is not unit or never 2025-10-08 00:03:48 +08:00
yanglsh
0415d96f1e Migrate needless_continue to late pass 2025-10-08 00:03:48 +08:00
Samuel Tardieu
0a2eeceefc
Add replace_box lint (#14953)
Adds a new lint that detects `var = Default::default()` when `var` is
`Box<T>` and `T` implements `Default`.

changelog: [`replace_box`]: new lint
2025-10-07 15:56:38 +00:00
dswij
ea54123fd4
fix(collapsible_match): exclude binding modes from struct field pattern suggestions (#15608)
Fixes https://github.com/rust-lang/rust-clippy/issues/13287

changelog: [`collapsible_match`]: exclude binding modes from struct
field pattern suggestions
2025-10-07 15:49:47 +00:00
+merlan #flirora
517ef604af Add replace_box lint 2025-10-07 11:33:54 -04:00
Timo
c1f61242e2
legacy_numeric_constants: add ctxt check for internal macro (#15816)
Fixes rust-lang/rust-clippy#15805

ICE bisects to 9457d640b7, which handles the span incorrectly when part
of the path originates from internal declarative macro.

changelog: none
2025-10-07 08:34:10 +00:00
Samuel Tardieu
f3c020cd55
Use expect for lint warnings (#15625)
changelog:none
2025-10-07 06:40:53 +00:00