Commit graph

24053 commits

Author SHA1 Message Date
Samuel Tardieu
2bb3d0c396
refactor(elidable_lifetimes): harmonize suggestion-building logic with extra_unused_type_parameters (#15908)
It's nice to come up with a clever algorithm
(https://github.com/rust-lang/rust-clippy/pull/15667), but it's even
nicer to reuse logic that already exists elsewhere.

changelog: none

r? @samueltardieu as you reviewed the original PR
2025-10-22 10:15:01 +00:00
Samuel Tardieu
fd208399ae
Make docs more clear (#15933)
`NB!` is extremely alien + not used anywhere else in repo (per github
search).

`Notes => Note`. At first thought was convention (written from
perspective of the lint), but not seen anywhere else in repo (per github
search).

Implication: clearer docs

Changes made from github web editor; no tests/checks performed.

changelog: none
2025-10-22 08:30:46 +00:00
Zylos
bab7519d5b
Update mod.rs 2025-10-21 21:43:34 -04:00
Ada Alakbarova
17f194238d
Adapt the logic from extra_unused_type_parameters
.. and add some docs to both of them
2025-10-22 01:06:13 +02:00
Samuel Tardieu
c6c71afda1
refactor(option_as_ref_cloned): move the method_call call out of the check (#15917)
This is more consistent with what the other `methods/` lints do.

changelog: none
2025-10-21 22:49:09 +00:00
Samuel Tardieu
fb82de5ed8
`manual_option_as_slice: improve diagnostics (#15926)
- Make the diagnostic message actually desribe the problem
- Always give the suggestion, by using `snippet_with_context`
- Make the suggestion verbose, because we sometimes lint multiline exprs
like `match`es

changelog: [`manual_option_as_slice`]: improve diagnostics
2025-10-21 22:07:49 +00:00
Samuel Tardieu
039b40f7c9
match_as_ref: improve diagnostics (#15928)
- Make the diagnostic message actually desribe the problem
- Make the suggestion verbose, because we lint multiline exprs

changelog: [`match_as_ref`]: improve diagnostics
2025-10-21 22:03:15 +00:00
Ada Alakbarova
a6e5159c7d
fix: parenthesise the receiver if needed 2025-10-21 18:11:39 +02:00
Ada Alakbarova
cb33ccd3fe
improve diagnostics 2025-10-21 16:51:33 +02:00
Ada Alakbarova
91dbaae9ad
improve diagnostics 2025-10-21 16:51:14 +02:00
Ada Alakbarova
a8fa9e1627
clean-up 2025-10-21 16:48:37 +02:00
Ada Alakbarova
c5215b6d84
clean-up a bit 2025-10-21 15:36:06 +02:00
Alex Macleod
973e596eb0
option_option: split part of diagnostic message into help message (#15870)
changelog: [`option_option`]: improve diagnostic message
2025-10-20 17:54:59 +00:00
Ada Alakbarova
4e3fa960d4
refactor(option_as_ref_cloned): move the method_call call out of the check 2025-10-20 15:54:59 +02:00
Samuel Tardieu
95dd88d6c4
refactor(manual_div_ceil_: move to under operators/ (#15909)
changelog: none
2025-10-20 05:14:21 +00:00
Samuel Tardieu
1ac3cc1a83
fix(empty_enum): don't lint if all variants happen to be cfg-d out (#15911)
Fixes https://github.com/rust-lang/rust-clippy/issues/15910

changelog: [`empty_enum`]: don't lint if all variants happen to be
`cfg`-d out
2025-10-20 05:11:40 +00:00
Ada Alakbarova
c8c23bcf5b
fix(empty_enum): don't lint if all variants happen to be cfg-d out 2025-10-20 00:47:11 +02:00
Ada Alakbarova
70de06f70f
clean-up a bit 2025-10-20 00:16:29 +02:00
Ada Alakbarova
9ee9fd00d0
refactor(manual_div_ceil): move to under operators/ 2025-10-20 00:05:38 +02:00
Ada Alakbarova
c6426f5dd7
Revert "fix(elidable_lifetime_names): avoid overlapping spans in suggestions"
This reverts commit 25881bfc34.
2025-10-19 18:32:21 +02:00
Alex Macleod
1ecb18a182
Update link to the Code of Conduct (#15903)
Update to direct link to the Code of Conduct

changelog: none
2025-10-17 15:35:58 +00:00
alexey semenyuk
269679e435
Update link to the Code of Conduct 2025-10-17 20:03:29 +05:00
Philipp Krones
d9fb15c4b1
Rustup (#15892)
r? @ghost

changelog: none
2025-10-16 14:03:44 +00:00
Philipp Krones
9aa70f2bdd
Bump nightly version -> 2025-10-16 2025-10-16 15:57:16 +02:00
Philipp Krones
cf7aaa5ecf
Merge remote-tracking branch 'upstream/master' into rustup 2025-10-16 15:57:00 +02:00
llogiq
00e5e1b838
refactor(match_like_matches_macro): disentangle the if-let and match cases (#15854)
As discussed in [#clippy > `match_like_matches_macro` does the
work
of`match_same_arms`](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/.60match_like_matches_macro.60.20does.20the.20work.20of.60match_same_arms.60/with/544003831)

Sorry for the large number of commits -- I could've gotten away just
three ("clean-up", and one for each inlining of `find_matches_sugg` and
subsequent simplifications), but I found the diff of that quite
difficult to understand.

changelog: none
2025-10-15 20:31:28 +00:00
llogiq
869753389b
overhaul mutex_{atomic,integer} (#15632)
- only lint on definitions of offending mutexes, not all their uses
(fixes https://github.com/rust-lang/rust-clippy/issues/13378)
- give more orderly help messages
- stop linting on `Mutex<*const T>` (see the corresponding commit for
context)
- offer (partial) suggestions

The last change might be deemed a bit too much for the feature freeze,
but it can be easily extracted out into a separate PR.

changelog: [`mutex_atomic`]: only lint the definitions, not uses
changelog: [`mutex_atomic`]: better help messages, and suggestions
changelog: [`mutex_atomic`]: don't lint `Mutex<*const T>`
changelog: [`mutex_integer`]: only lint the definitions, not uses
changelog: [`mutex_integer`]: better help messages, and suggestions
2025-10-15 20:29:59 +00:00
llogiq
ab9eb10ef7
feat: manual_rotate also recognize non-consts (#15402)
changelog: [`manual_rotate`]: also recognize non-consts

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

r? @llogiq
2025-10-15 19:12:24 +00:00
Diggory Blake
e8fec08b9c Restrict sysroot crate imports to those defined in this repo.
It's common to import dependencies from the sysroot via `extern crate`
rather than use an explicit cargo dependency, when it's necessary to use
the same dependency version as used by rustc itself. However, this is
dangerous for crates.io crates, since rustc may not pull in the
dependency on some targets, or may pull in multiple versions. In both
cases, the `extern crate` fails to resolve.

To address this, re-export all such dependencies from the appropriate
`rustc_*` crates, and use this alias from crates which would otherwise
need to use `extern crate`.
2025-10-15 13:17:25 +01:00
Jason Newcomb
8116b2354a
Dereference argument of manual_div_ceil() if needed (#15706)
Fixes rust-lang/rust-clippy#15705

changelog: [`manual_div_ceil`]: dereference argument when needed

r? Alexendoo
2025-10-15 02:22:39 +00:00
Jason Newcomb
ec8e8fde91
refactor(non_canonical_impls): lint starting from impls (#15749)
Based on
https://github.com/rust-lang/rust-clippy/pull/15520#discussion_r2372599748,
with the following changes/additions:
- No longer use the `Trait` enum for quickly filtering out irrelevant
impls -- instead, check the `trait_of` basically right away:
    1. pre-fetch `DefId`s of the relevant traits into the lint pass
2. reuse `cx.tcx.impl_trait_ref`'s output for the the `DefId` of the
trait being implemented
    3. compare those `DefId`s, which should be very cheap
- Next, check whether `self_ty` implements the other relevant trait.
- Pre-filter impl items in the same (lazy) iterator, but delay the
proc-macro check as much as possible

changelog: none

Not auto-assigning since @blyxyas and/or @Jarcho will be the ones
reviewing it:
r? ghost
2025-10-15 02:20:21 +00:00
Jason Newcomb
d230acd9cf
Allow explicit_write in tests (#15862)
Resolves rust-lang/rust-clippy#15780.

I didn't get any feedback on that issue. So I hope it is okay that I
charged ahead and addressed it.

changelog: Allow `explicit_write` in tests
2025-10-15 01:44:50 +00:00
Alejandra González
b26a1aaa77
[unnecessary_safety_comment] Some fixes regarding comments above attributes (#15678)
The way clippy checked for SAFETY comments above attributes was wrong:
- It wasn't considered for items
- It cause an ICE with some attributes
- When considering comments above attributes, it didn't considered
comments below them, causing some unlintable situations.

This PR tries to fix this by delegating the skipping of attributes to
the function analyzing the source code itself.

changelog: [`unnecessary_safety_comment`]: Taking into account comments
above attributes for items

Fixes rust-lang/rust-clippy#14555
Fixes rust-lang/rust-clippy#15684
Fixes rust-lang/rust-clippy#15754
2025-10-14 22:18:55 +00:00
Teodoro Freund
9cc0291582 unnecessary_safety_comment fix an ICE and
improve coverage

Considering comments above attributes for items

Fixed the ICE and safety comments between attributes

- No longer using attr.span()
- ignoring attributes manually

Improve error messages on unsafe fns
2025-10-14 22:23:53 +01:00
Jason Newcomb
eee8ef85ce
New internal lint: unusual_names (#15794)
This lint aims at detecting unusual names used in Clippy source code,
such as `appl` or `application` for a `rustc_errors::Applicability`
variable, instead of `app` and `applicability` which are commonly used
throughout Clippy.

This helps maintaining the consistency of the Clippy source code.

It is currently implemented for:

- `Applicability`: `app` or `applicability`
- `EarlyContext`/`LateContext`: `cx`
- `TyCtxt`: `tcx`

changelog: none
2025-10-14 20:32:13 +00:00
Samuel Moelius
1bd8cad5a2 Allow explicit_write in tests 2025-10-14 11:52:54 -04:00
Philipp Krones
c6f2557d26
Update actions/setup-node version (#15874)
Update actions/setup-node version.

changelog: none
2025-10-13 07:51:51 +00:00
Samuel Tardieu
a8d1258ba7
feat(multiple_inherent_impl): Add config option to target specific scope (#15843)
Add a config option `inherent-impl-lint-scope` to the lint
`multiple_inherent_impl` to target a different scope according to
people's needs. It can take three values: `module`, `file`, and `crate`
(default).

- `module` is the weakest option. It lints if there are two or more
impls in the same module.
- `file` is a bit stronger, since it lints if there are two or more
impls in the same file. So, this triggers the lint (where it did not
with module):
- `crate` is the strongest of them; it triggers as soon as there are two
or more impls anywhere in the crate. It is the current behaviour of the
lint, so it's the default option.

changelog: [`multiple_inherent_impl`] : Add config option (`module`,
`file` or `crate`) to target specific scope

fixes rust-lang/rust-clippy#14867
2025-10-13 05:07:54 +00:00
alexey semenyuk
e786e009ed actions/setup-node update 2025-10-12 21:15:33 +03:00
Ada Alakbarova
2fe9d4bfa6
option_option: split part of diagnostic message into help message 2025-10-12 14:19:10 +02:00
Ada Alakbarova
3e1f8623f7
clean-up tests 2025-10-12 13:54:47 +02:00
Paul MIALANE
9be213666e feat(multiple_inherent_impl): Add config option to target specific scope 2025-10-12 10:59:57 +02:00
Camille GILLOT
918b2d88e9 Diagnose liveness on MIR. 2025-10-11 20:50:21 +00:00
Jason Newcomb
35f8bffb91
book: cleanups (#15864)
changelog: none
2025-10-11 15:58:20 +00:00
Timo
1f0b8b8629
fix(clone_on_ref_ptr): only name the generic type if possible (#15740)
Fixes https://github.com/rust-lang/rust-clippy/issues/15009

changelog: [clone_on_ref_ptr]: only name the generic type if possible
2025-10-11 14:15:19 +00:00
Alejandra González
d66e5db0f7
manual_unwrap_or: fix FP edge case (#15812)
changelog: [`manual_unwrap_or`]: fix FP edge case

Found this problem while investigating a different bug.
2025-10-11 11:15:44 +00:00
Ada Alakbarova
778da589c6
suggest adjusting the type ascription 2025-10-11 10:37:39 +02:00
Ada Alakbarova
e5fd571414
realize that a test case is incorrect
`Mutex<*const _>` doesn't make a lot of sense (there can be no
contention over a read-only reference), but `AtomicPtr::new(*const _)`
straight up doesn't compile
2025-10-11 10:37:39 +02:00
Ada Alakbarova
99ce6391dd
suggest replacing Mutex::new with AtomicX::new 2025-10-11 10:37:38 +02:00
Ada Alakbarova
38ac3d041c
only lint on definitions, not use 2025-10-11 10:37:38 +02:00