Commit Graph

25054 Commits

Author SHA1 Message Date
linshuy2 fef8a7130e fix: collapsible_if FP when the inner if contains cfg 2026-03-24 04:48:31 +00:00
Samuel Tardieu ac86fd103d Add BinaryHeap::pop_if() to manual_pop_if (#16734)
Detects manual implementations of the newly implemented
[`BinaryHeap::pop_if()`](https://github.com/rust-lang/rust/issues/151828)
in `manual_pop_if`.

I wasn't sure about how best to handle checking for the nightly feature.
Could we let people compiling with nightly know that the feature is
available even if they don't have it enabled?

changelog: [`manual_pop_if`]: detect manual implementations of
`BinaryHeap::pop_if()`
2026-03-22 15:49:42 +00:00
Max Heller 9bf6fafdbf Add BinaryHeap::pop_if() to manual_pop_if 2026-03-22 11:22:16 -04:00
Philipp Krones 256c21c543 Rustup (#16740)
r? @ghost

changelog: none
2026-03-21 12:45:54 +00:00
Philipp Krones e191c9429e Bump nightly version -> 2026-03-21 2026-03-21 13:40:35 +01:00
Philipp Krones 1e283ba0ce Merge remote-tracking branch 'upstream/master' into rustup 2026-03-21 13:40:20 +01:00
Philipp Krones b98de10e9c Update bytes dependency in clippy_test_deps to avoid CVE warning (#16667)
Pull-requests get a warning because of

[RUSTSEC-2026-0007](https://rustsec.org/advisories/RUSTSEC-2026-0007.html).
Bumping `bytes` will silence the warning.

changelog: none

r? flip1995
2026-03-20 17:32:03 +00:00
Stuart Cook 525c8ac943 Rollup merge of #153778 - bjorn3:driver_cleanups, r=TaKO8Ki
Couple of driver interface improvements

* Pass Session to `make_codegen_backend` callback. This simplifies some code in miri.
* Move env/file_depinfo from ParseSess to Session. There is no reason it has to be in ParseSess rather than Session.
* Rename hash_untracked_state to track_state to indicate that it isn't just used for hashing state, but also for adding env vars and files to be tracked through the dep info file.
2026-03-18 15:07:31 +11:00
Ada Alakbarova 773f77b9cc Refactor implementation of unnecessary_{option,result}_map_or_else (#15889)
When checking if a function is an identity function, try to use existing
functionalities.

Some cases are no longer covered, but I believe that's ok and there were
some bugs:
- No longer considering the identity a closure where the pattern
captures by reference, since that made [the suggestion break
compilation](https://play.rust-lang.org/?version=beta&mode=debug&edition=2024&gist=f3165f23dc5c46972ef4d53600273fd5)
- No longer going into other function's body to check if they're
isomorphic to the identity, discussed a bit [on Zulip]([#clippy > Going
into other function definitions
desirable?](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Going.20into.20other.20function.20definitions.20desirable.3F/with/546402683)).
I understand this could not catch some cases, but I think it's something
that is out the scope of this lint. It also requires some ad hoc
mechanism in the implementation, doable but a bit hacky.

Fixes rust-lang/rust-clippy#15916

changelog: [`unnecessary_option_map_or_else`]: function definitions are
no longer traversed when checking if an expression is the identity
changelog: [`unnecessary_result_map_or_else`]: function definitions are
no longer traversed when checking if an expression is the identity
2026-03-15 09:36:22 +00:00
Teodoro Freund c455f7ce52 Refactors to unnecessary_{option,result}_map_or_else:
- When checking if a function is an identity function, try to use existing functionalities.
- Some cases are no longer supported, but they were buggy
2026-03-15 09:20:27 +00:00
Esteban Küber e389568d92 fix clippy test 2026-03-14 20:43:57 +00:00
dswij 7849496c17 fix: question_mark suggestion caused error (#16656)
Closes: rust-lang/rust-clippy#16654

changelog: [`question_mark`]: fix suggestion-caused-error caused by
semicolon inference relying only on parent-node shape.
2026-03-14 14:23:27 +00:00
Samuel Tardieu d82d650272 Reduce clippy lints HTML size by removing a CSS class (#16707)
Reduces the size of the clippy lints page from 1.643.619 to 1.609.095
(-2.1%). No UI changes.

r? @samueltardieu

changelog: none
2026-03-13 13:41:31 +00:00
Guillaume Gomez 2c85a53b5d Reduce clippy lints HTML size by removing a CSS class 2026-03-12 18:36:37 +01:00
bjorn3 62bd45d7be Move env/file_depinfo from ParseSess to Session 2026-03-12 15:35:27 +00:00
Jonathan Brouwer 1d0d647b4c Rollup merge of #153641 - nnethercote:mv-Spanned, r=JonathanBrouwer
Move `Spanned`.

It's defined in `rustc_span::source_map` which doesn't make any sense because it has nothing to do with source maps. This commit moves it to the crate root, a more sensible spot for something this basic.

r? @JonathanBrouwer
2026-03-10 22:46:56 +01:00
Nicholas Nethercote f599afe624 Move Spanned.
It's defined in `rustc_span::source_map` which doesn't make any sense
because it has nothing to do with source maps. This commit moves it to
the crate root, a more sensible spot for something this basic.
2026-03-11 06:25:23 +11:00
Samuel Tardieu c2178bb44c Fix match_same_arms FP with associated consts (#16701)
Closes rust-lang/rust-clippy#16698

changelog: [`match_same_arms`] fix FP with associated consts
2026-03-10 17:21:54 +00:00
linshuy2 e9d76c811a fix: match_same_arms FP with associated consts 2026-03-10 17:13:35 +00:00
Guillaume Gomez ab867a90e1 Remove usage of TyCtxt::node_span_lint in clippy 2026-03-09 22:50:10 +01:00
dswij 5e1d741a1d Fix semicolon-inside-block inside try_blocks (#16697)
fixes rust-lang/rust-clippy#16696

changelog: [`semicolon_inside_block`]: fix false positive in `try`
blocks where moving `;` inside changes the block's return type and
causes type errors.
2026-03-09 18:59:48 +00:00
Samuel Tardieu a721c29eee Reduce lints page HTML size (#16632)
This PR reduces the clippy lints page HTML size.

Currently, we need to hover the link to be able to click it:

<img width="276" height="59" alt="Screenshot From 2026-02-24 20-37-53"
src="https://github.com/user-attachments/assets/3c49d511-f6b5-47eb-9436-a2ece6082f78"
/>

With the first commit of this PR, the whole "case" becomes the link:

<img width="276" height="59" alt="image"
src="https://github.com/user-attachments/assets/094923fb-6725-4941-a680-015c53faad8e"
/>

That is the only visible change.

Here are the diff of size for each commit:

| step | size (in bytes) | diff with previous size (in %) |
|-|-|-|
| before this PR | 1.684.543 | |
| first commit | 1.666.635 | -1.1% |
| second commit | 1.643.619 | -1.4% |

So in total, going from 1.684.543 to 1.643.619, we have a 2.5% reduction
of size.

changelog: none

r? @Alexendoo
2026-03-09 14:02:21 +00:00
Alejandra González bc2a571167 Do not materialize snippets when it is not needed to (#16666)
It is not necessary to materialize snippets into `String` objects just
to check if they contain comments for example.

changelog: none

r? @blyxyas
(for perf measurements)
2026-03-09 10:58:41 +00:00
Taym Haddadi a5fa3995d6 Fix semicolon-inside-block inside try_blocks
Signed-off-by: Taym Haddadi <haddadi.taym@gmail.com>
2026-03-09 02:08:04 +01:00
Jason Newcomb 3678193248 Fix ICE when using the min_generic_const_args incomplete feature (#16692)
changelog: fix ICE when using the `min_generic_const_args` incomplete
feature

Fixes rust-lang/rust-clippy#16691
2026-03-08 16:27:34 +00:00
Samuel Tardieu 201759058d Fix ICE when using the min_generic_const_args incomplete feature 2026-03-08 11:53:45 +01:00
Jason Newcomb 9450d567b9 Fix ICE in match_same_arms (#16685)
The wrong `TypeckResults` was used in the fallback equality function
passed by the `match_same_arms` and `filter_map` lints. Previously,
those fallback functions had no way of using the proper `TypeckResults`.
Those (one per expression being compared) are now passed to the
registered fallback function.

changelog: [`match_same_arms`]: fix internal compiler error

Fixes rust-lang/rust-clippy#16678
Fixes rust-lang/rust-clippy#16686

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- [Beta
nomination](https://github.com/rust-lang/rust-clippy/pull/16685#issuecomment-4017155418)
by [samueltardieu](https://github.com/samueltardieu)

*Managed by `@rustbot`—see
[help](https://forge.rust-lang.org/triagebot/note.html) for details*

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2026-03-07 22:48:24 +00:00
Samuel Tardieu 1ecc9d7e04 Fix ICE in match_same_arms
The wrong `TypeckResults` was used in the fallback equality function
passed by the `match_same_arms` and `filter_map` lints. Previously,
those fallback functions had no way of using the proper `TypeckResults`.
Those (one per expression being compared) are now passed to the
registered fallback function.
2026-03-07 20:13:56 +01:00
Josh Stone c260a1fb50 Update cfg(bootstrap) 2026-03-07 10:42:02 -08:00
bors 1fc8c3bd9a Auto merge of #153507 - JonathanBrouwer:rollup-ki59UTE, r=JonathanBrouwer
Rollup of 14 pull requests

Successful merges:

 - rust-lang/rust#153466 (`rust-analyzer` subtree update)
 - rust-lang/rust#151280 (Fix incorrect trailing comma suggested in no_accessible_fields)
 - rust-lang/rust#152593 (Box in `ValTreeKind::Branch(Box<[I::Const]>)` changed to `List`)
 - rust-lang/rust#153174 (std: add wasm64 to sync::Once and thread_parking atomics cfg guards)
 - rust-lang/rust#153485 (libcore float tests: replace macro shadowing by const-compatible macro)
 - rust-lang/rust#153495 (Fix ICE in `offset_of!` error recovery)
 - rust-lang/rust#152040 (Do not emit ConstEvaluatable goals if type-const)
 - rust-lang/rust#152741 (Suppress invalid suggestions in destructuring assignment)
 - rust-lang/rust#153189 (refactor: move `check_align` to `parse_alignment`)
 - rust-lang/rust#153230 (Roll rustfmt reviewers for in-tree rustfmt)
 - rust-lang/rust#153445 (Consider try blocks as block-like for overflowed expr)
 - rust-lang/rust#153452 (Cleanup unused diagnostic emission methods)
 - rust-lang/rust#153476 (bootstrap.py: fix typo "parallle")
 - rust-lang/rust#153483 (Preserve parentheses around `Fn` trait bounds in pretty printer)
2026-03-06 19:09:12 +00:00
Samuel Tardieu 13d91b7cce Fix unnecessary_safety_comment FP on code blocks inside inner docs (#16559)
Closes rust-lang/rust-clippy#16553

changelog: [`unnecessary_safety_comment`] fix FP on code blocks inside
inner docs
2026-03-06 17:06:48 +00:00
Guillaume Gomez ae25efb4ac Fix panic by setting the span before it is actually needed 2026-03-06 16:38:53 +01:00
Samuel Tardieu 1fe6383fc9 add manual_pop_if lint (#16582)
*[View all
comments](https://triagebot.infra.rust-lang.org/gh-comments/rust-lang/rust-clippy/pull/16582)*

Add a lint to detect when the recently added Vec::pop_if,
VecDeque::pop_front_if, and VecDeque::pop_back_if are manually
implemented.

changelog: add [`manual_pop_if`] lint
2026-03-06 13:02:26 +00:00
Samuel Tardieu f22848a09d Changelog for Clippy 1.94 (#16653)
Violets are red,
Roses are blue,
Winter feels endless…
But warm days are coming soon too.

----

Chimmi from @OwenFeik is the winner at
https://github.com/rust-lang/rust-clippy/pull/16413

<img width="3072" height="3565" alt="image"
src="https://github.com/user-attachments/assets/3c6ecc36-747d-40df-b2f5-bc141dc0b227"
/>

Sounds like an already professional balancer

----

Cats for the next release can be nominated in the comments

changelog: none

r? flip1995
2026-03-06 07:17:28 +00:00
Guillaume Gomez dbb159a432 Remove usage of LintContext::span_lint in clippy 2026-03-05 23:53:53 +01:00
Samuel Tardieu 858353ce6c Update bytes dependency in clippy_test_deps to avoid CVE warning
Pull-requests get a warning because of
[RUSTSEC-2026-0007](https://rustsec.org/advisories/RUSTSEC-2026-0007.html).
Bumping `bytes` will silence the warning.
2026-03-05 23:19:49 +01:00
Samuel Tardieu b5f63104b2 Do not materialize snippets when it is not needed to
It is not necessary to materialize snippets into `String` objects just
to check if they contain comments for example.
2026-03-05 23:19:49 +01:00
Paolo Borelli 25171f23ae add manual_pop_if lint
Add a lint to detect when the recently added Vec::pop_if,
VecDeque::pop_front_if, and VecDeque::pop_back_if are manually
implemented.

changelog: add [`manual_pop_if`] lint
2026-03-05 19:06:40 +01:00
Philipp Krones b4d2445432 Merge commit 'e645f93552c3926a0bb481a777df120b7bce986f' 2026-03-05 17:18:20 +01:00
Philipp Krones e645f93552 Rustup (#16668)
r? @ghost

changelog: none
2026-03-05 16:06:31 +00:00
Philipp Krones dfcb117050 Bump Clippy version -> 0.1.96 2026-03-05 16:59:28 +01:00
Philipp Krones 02aece114b Bump nightly version -> 2026-03-05 2026-03-05 16:59:20 +01:00
Philipp Krones eb386eca43 Merge remote-tracking branch 'upstream/master' into rustup 2026-03-05 16:59:08 +01:00
Aliaksei Semianiuk 9a224202e4 Changelog for Clippy 1.94 2026-03-05 16:54:05 +01:00
Samuel Tardieu 00a00ebaee clippy_dev: Sort lint and lint pass declarations (parsing revamp part 5/N) (#15979)
Based on rust-lang/rust-clippy#15978

This will prevent some pointless merge conflict when multiple people add
lints to the same lint pass (e.g. methods).

changelog: None
2026-03-05 15:03:04 +00:00
Samuel Tardieu 5a8a577345 Fix infinite_loop wrong suggestion inside conditional branches (#16619)
Fix rust-lang/rust-clippy#16155

Suppress the `-> !` suggestion when the loop is inside a conditional
where not all branches diverge. When every branch does diverge (e.g. `if
cond { loop {} } else { loop {} }`), the suggestion is still emitted.

changelog: [`infinite_loop`]: Fix wrong suggestion to add `-> !` when
the loop is inside a conditional branch
2026-03-05 12:44:30 +00:00
Philipp Krones 8c1c4777d6 Configure triagebot to add a backlink to Zulip when nominating a lint (#16662)
As asked in
https://github.com/rust-lang/rust-clippy/pull/16614#issuecomment-3998600387,
triagebot has been updated to able to add a comment to GitHub when
opening the nomination Zulip topic.

This PR therefore configures the nomination with the suggested text and
link to the Zulip topic.

cc @samueltardieu
r? @flip1995

---

changelog: none
2026-03-05 09:25:53 +00:00
Jason Newcomb 3cca575f67 fix(doc_paragraphs_missing_punctuation): Trim picture symbols (#16514)
FIxes rust-lang/rust-clippy#16482

changelog: [`doc_paragraphs_missing_punctuation`]: fix: No longer lints
for punctuated paragraphs with a trailing emoji.
2026-03-04 21:39:05 +00:00
Jason Newcomb 27d471a3f0 Fix redundant_closure suggests wrongly when local is derefed to callable (#16648)
Closes rust-lang/rust-clippy#16641

changelog: [`redundant_closure`] fix wrong suggestions when local is
derefed to callable
2026-03-04 21:36:52 +00:00
Urgau da23cc3688 Configure triagebot to add a backlink to Zulip when nominating a lint 2026-03-04 22:36:33 +01:00