Commit Graph

11173 Commits

Author SHA1 Message Date
Linshu Yang 93bf95b230 fix: manual_div_ceil wrongly unmangled macros 2026-03-23 02:31:45 +00:00
Linshu Yang 31f04c7098 fix: manual_is_power_of_two wrongly unmangled macros 2026-03-23 02:09:43 +00:00
Linshu Yang 3272a9b557 fix: needless_bool wrongly unmangled macros 2026-03-23 02:09:43 +00:00
Linshu Yang a255ac1d82 fix: map_with_unused_argument_over_ranges wrongly unmangled macros 2026-03-23 02:07:09 +00:00
Linshu Yang d3ca65d04a fix: manual_rotate wrongly unmangled macros 2026-03-22 23:43:38 +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 1e283ba0ce Merge remote-tracking branch 'upstream/master' into rustup 2026-03-21 13:40:20 +01: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
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
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
Samuel Tardieu 201759058d Fix ICE when using the min_generic_const_args incomplete feature 2026-03-08 11:53:45 +01: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
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
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 eb386eca43 Merge remote-tracking branch 'upstream/master' into rustup 2026-03-05 16:59:08 +01: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
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
Jason Newcomb 3393084540 Remove extra space in must_use_candidate lint output (#16651)
changelog: none

Fixes rust-lang/rust-clippy#16650
2026-03-04 21:01:35 +00:00
Samuel Tardieu 4ff2a24441 Fix ICE in swap_binop()
Make `swap_binop()` a method of `HirEqInterExpr`, and use the proper
typeck to check the type of an expression.
2026-03-03 23:24:00 +01:00
Jonathan Brouwer af041c658f Rollup merge of #153015 - joboet:atomic_alias_generic, r=jhpratt
core: make atomic primitives type aliases of `Atomic<T>`

Tracking issue: https://github.com/rust-lang/rust/issues/130539

This makes `AtomicI32` and friends type aliases of `Atomic<T>` by encoding their alignment requirements via the use of an internal `Storage` associated type. This is also used to encode that `AtomicBool` store a `u8` internally.

Modulo the `Send`/`Sync` implementations, this PR does not move any trait implementations, methods or associated functions – I'll leave that for another PR.
2026-03-02 20:10:34 +01:00
joboet 9f97c53f1c bless UI tests referencing atomic primitives 2026-03-02 00:23:24 +01:00
irelaxcn fd8bb21676 fix: question_mark suggestion caused error 2026-03-02 00:34:09 +08:00
dswij e492d02285 fix: handle core panics in all format lints (#16597)
Fixes rust-lang/rust-clippy#16411

`core::panic` was missing in the formatting arg lints

changelog: fix all format-related lints to handle `core::panic!` macro
2026-03-01 14:58:48 +00:00
Samuel Tardieu b7e135a319 Remove extra space in must_use_candidate lint output 2026-02-28 01:15:21 +01:00
BenjaminBrienen 5904d42592 fix(doc_paragraphs_missing_punctuation): Trim emojis and picture symbols when looking for punctuation 2026-02-27 15:49:29 +01:00
linshuy2 5218b85416 fix: explicit_counter_loop FP when the initializer is not integral 2026-02-27 02:35:56 +00:00
linshuy2 4b2e965f8e fix: redundant_closure suggests wrongly when local is derefed to callable 2026-02-27 02:32:14 +00:00
lapla 55225173f2 Fix infinite_loop wrong suggestion inside conditional branches 2026-02-26 13:38:49 +09:00
Samuel Tardieu 625bd5539e Fix cmp_owned suggests wrongly on PathBuf (#16628)
Closes rust-lang/rust-clippy#16448
Closes rust-lang/rust-clippy#16564

The previous implementation hardcoded bans on `str` to avoid adding `*`
when comparing with `String`, which becomes a problem for `Pathbuf` as
`PartialEq<&str>` is not yet implemented on it.

changelog: [`cmp_owned`] fix wrong suggestions on `PathBuf`
2026-02-25 19:43:28 +00:00
linshuy2 b26ef2a45d fix: cmp_owned suggests wrongly on PathBuf 2026-02-24 15:48:06 +00:00
dswij 48835956a9 Fix suboptimal_flops FN on add and sub assign (#16625)
Closes rust-lang/rust-clippy#16573

changelog: [`suboptimal_flops`] fix FN on add and sub assign
2026-02-24 14:42:58 +00:00
Philipp Krones 088022c7d4 Merge commit 'df995ede1b3e61f0e87081d9548e6cd2a3ec9095' into clippy-subtree-update 2026-02-24 12:00:51 +01:00
Jacob Adam 94554413c0 Fix the compile-test tests when setting Cargo's build.build-dir setting to a path that's distinct from target-dir
In this approach, we're using the `CARGO_BIN_EXE_clippy-driver` env var, which is set to the appropriate absolute path,
invariant across the various possible `target-dir` and `build.build-dir` configurations.

Do the same for `CARGO_CLIPPY_PATH` in tests/test_utils/mod.rs.
2026-02-24 10:21:39 +01:00
Jason Newcomb df995ede1b Fix explicit_counter_loop FN when loop counter starts at non-zero (#16620)
Closes rust-lang/rust-clippy#16612

Previous implementation hardcoded `0` as loop counter start, this PR
lifts that restriction.

changelog: [`explicit_counter_loop`] fix FN when loop counter starts at
non-zero
2026-02-23 22:28:51 +00:00
linshuy2 faf9506169 fix: suboptimal_flops FN on add and sub assign 2026-02-23 21:42:26 +00:00
Samuel Tardieu 5e242b66b9 Revert "Fix the compile-test tests when setting Cargo's build.build-dir setting to a path that's distinct from target-dir."
This reverts commit 2737b26c2e as it
prevents Clippy tests from passing when running inside the compiler
repository.
2026-02-23 20:06:17 +01:00
linshuy2 c234b12cfa fix: explicit_counter_loop FN when loop counter starts at non-zero 2026-02-23 17:49:50 +00:00
Jason Newcomb 26e5edc5e1 test: don't call test functions in main (#16589)
seems to be a remnant of some older testing scheme that is completely
unnecessary now

changelog: none
2026-02-23 15:44:29 +00:00
Jason Newcomb afece5ddf1 Do not suggest removing reborrow of a captured upvar (#16622)
changelog: [`borrow_deref_ref`]: do not suggest removing an explicit
reborrow when it targets an upvar captured by a closure

Fixes rust-lang/rust-clippy#16556

r? Jarcho
2026-02-23 15:32:13 +00:00
Samuel Tardieu 12abbc0676 Do not suggest removing reborrow of a captured upvar 2026-02-23 15:55:05 +01:00
Ada Alakbarova f56dfe4725 test: don't call test functions in main
seems to be a remnant of some older testing scheme that is completely
unnecessary now
2026-02-23 14:29:40 +01:00
Jason Newcomb 0776e01ff4 fix(needless_maybe_sized): don't lint in proc-macro-generated code (#15629)
Fixes https://github.com/rust-lang/rust-clippy/issues/13360

changelog: [`needless_maybe_sized`]: don't lint in proc-macro-generated
code
2026-02-23 01:09:15 +00:00
Jason Newcomb 38321c83e6 Add unnecessary_trailing_comma lint (#16530)
This matches `cargo fmt` behavior but for `format!(...)` -style macro
calls.

To make this PR easier to review, it moves all linting of the clippy
code to rust-lang/rust-clippy#16533

Suggest removing an unnecessary trailing comma before the closing
parenthesis in single-line format-like macro invocations (e.g. println!,
format!, write!). The lint currently only runs on format-like macros
because it relies on format-argument parsing; arbitrary user macros are
not supported to avoid incorrect suggestions.

- Lint is in the `style` group (allow-by-default)
- Single-line only: multi-line macro invocations are not linted
- Machine-applicable fix: removes the trailing comma

```rust
// catches this
debug!("Foo={}", 1,);

// suggests this
debug!("Foo={}", 1);
```

Closes rust-lang/rust-clippy#13965

changelog: [`unnecessary_trailing_comma`]: new lint to remove trailing
commas in a single-line format macro usage
2026-02-23 00:59:34 +00:00
Jason Newcomb f2713876d3 Remove no-rustfix marker for tests with valid suggestions (#16609)
changelog: none
2026-02-23 00:55:42 +00:00