Commit Graph

24501 Commits

Author SHA1 Message Date
Samuel Tardieu a55845cd61 Fix println_empty_string suggestion caused error (#16201)
Closes: rust-lang/rust-clippy#16167
changelog: [`println_empty_string`]: fix suggestion caused error when
there is a comma after arg.

Closes: rust-lang/rust-clippy#16251
changelog: [`writeln_empty_string`]: fix suggestion caused error when
there is a comma in the comment before arg.
2025-12-19 18:00:53 +00:00
irelaxcn 675fd681aa Fix println_empty_string suggestion caused error when there is a , after arg.
Make `writeln_empty_string` don't provide an auto-fix suggestion when
there is a comment in the macro call span.
2025-12-20 01:38:31 +08:00
Samuel Tardieu e28dabc0fb Fix an incorrect error message regarding the size of usize and isize in cast_precision_loss. (#14966)
When trying to cast a `usize` or `isize` using `as` to a type of
potentially smaller size the `cast_precision_loss` would claim that the
size of `usize` is "32 or 64 bits". It is now corrected to "16, 32, or
64 bits".

changelog: [`cast_precision_loss`]: fix the error messages claim
regarding the size of `usize` and `isize`.
2025-12-19 15:50:51 +00:00
Nelli Skogman a287c66721 Fix an incorrect error message regarding the size of isize and usize 2025-12-19 16:43:48 +01:00
Samuel Tardieu 1c59941b19 Set myself on vacation (#16266)
Expecting a slow rythm until about Jan. 2.

changelog: none
r? ghost
2025-12-19 14:26:24 +00:00
Samuel Tardieu a45b2ba60b Set myself on vacation 2025-12-19 15:20:39 +01:00
llogiq 533cbc57ba Reenable some tests on "apple" targets (#16264)
Those tests appear to be passing on "apple" targets as well.

changelog: none
2025-12-19 10:06:33 +00:00
Samuel Tardieu 76457e60d7 Reenable some tests on "apple" targets
Those tests appear to be passing on "apple" targets as well.
2025-12-19 10:40:49 +01:00
llogiq 34fab5cd37 Allow multiline suggestions in map-unwrap-or (#16114)
I recently got a `map-unwrap-or` warning with no suggestion, and was
very confused because I couldn't tell what the lint was flagging.

It turned out the "else" part had multiple lines, so the lint decided
not to include a suggestion.

Please look at this PR's stderr file, and decide whether you like it.
Then look at [its
predecessor](https://github.com/rust-lang/rust-clippy/blob/24e16f992c2dda1904fe8d4a94b391513832ce60/tests/ui/map_unwrap_or.stderr),
and decide whether you like it.

IMHO, the one with the suggestions is much more informative, even if not
as pretty.

changelog: Allow multiline suggestions in `map-unwrap-or`
2025-12-18 16:45:50 +00:00
dswij f245d85a2f transmuting_null: Check const integer casts (#16227)
Additionally removed the comment about MIR const propagation as it is
now outdated

changelog: [`transmuting_null`]: now checks const integers being casted
to pointers
2025-12-18 15:43:05 +00:00
llogiq 741b684c90 New lint - same_length_and_capacity (#15656)
Fixes rust-lang/rust-clippy#5955

I understand that there's a feature freeze right now. I had started
working on this before I was aware of the feature freeze. I don't mind
waiting as long as I need to for feedback.

changelog: [`same_length_and_capacity`]: adds a new lint that checks for
usages of `from_raw_parts` where the same expression is passed for the
length and the capacity

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

-
[Feature-freeze](https://github.com/rust-lang/rust-clippy/pull/15656#issuecomment-3276620004)
by [github-actions[bot]](https://github.com/github-actions[bot])

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

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-12-18 13:55:44 +00:00
llogiq 6110c8074a Fix needless_type_cast suggesting invalid code for non-literal initializers (#16248)
When the initializer is a function call or suffixed literal (e.g.,
`size_of::<T>()` or `10u8`), suggest casting the initializer too, since
changing only the type annotation would fail to compile. Fixes
rust-lang/rust-clippy#16240

```
changelog: [`needless_type_cast`]: Fix suggesting invalid code for non-literal initializers
```
2025-12-18 07:03:43 +00:00
Samuel Onoja 0f17de76b8 skip needless_type_cast for single-use non-coercible casts 2025-12-17 16:23:28 +01:00
Samuel Tardieu 37330eb80a New internal lint: repeated_is_diagnostic_item (#15937)
As described in
https://github.com/rust-lang/rust-clippy/pull/15528#issuecomment-3214018887

changelog: none
2025-12-17 12:36:12 +00:00
Ada Alakbarova 29659288ff feat(repeated_is_diagnostic_item): new internal lint 2025-12-17 12:20:51 +01:00
Ada Alakbarova 3e55ab1adf dogfood the lint
This commit is put before the one that actually introduces the lint,
since, were they put in the opposite order, the first commit wouldn't
pass dogfood
2025-12-17 12:20:51 +01:00
Samuel Tardieu 020c7cffa3 Fix empty_enum_variants_with_brackets misses removing brackets in patterns (#16160)
Closes rust-lang/rust-clippy#16157

changelog: [`empty_enum_variants_with_brackets`] fix missing to remove
brackets in patterns
2025-12-16 23:44:30 +00:00
Jason Newcomb 498d4bf2ea Move collapsible_else_if to pedantic (#16211)
Looks like a good number of people disagree with this lint so it
shouldn't be on by default

Fixes https://github.com/rust-lang/rust-clippy/issues/16209

changelog: [`collapsible_else_if`]: move to `pedantic`
2025-12-16 20:32:43 +00:00
Linshu Yang 96423581b2 Make empty_enum_variants_with_brackets to support empty variant with braces 2025-12-16 20:13:53 +00:00
llogiq 40ad1a6ce2 Move needless_type_cast lint to nursery (#16246)
changelog: [`needless_type_cast`]: move into nursery until bugs are
ironed out

[Zulip
thread](https://rust-lang.zulipchat.com/#narrow/channel/257328-clippy/topic/Moving.20.60needless_type_cast.60.20to.20.60nursery.60)
2025-12-16 06:07:45 +00:00
Catherine Flores c614b57d0a Do not look for disallowed methods inside desugared code (#16186)
changelog: [`disallowed_methods`]: do not check compiler-generated code

Fixes rust-lang/rust-clippy#16185
2025-12-16 00:21:09 +00:00
Jason Newcomb acc50245d2 Parent of struct constructor is the struct itself (#16245)
The `Fn`/`AssocFn` cases were not tested anywhere, and according to the
comments inside `TyCtxt::res_generic_def_id()` could have made the
`TyCtxt::generics_of()` call also trigger an ICE.

changelog: [`needless_type_cast`]: do not ICE on struct constructor

Fixes rust-lang/rust-clippy#16243
2025-12-15 20:38:36 +00:00
Samuel Tardieu 344ddcf9f2 Move needless_type_cast lint to nursery
The lint is new and already has several bugs filed against it, including
an ICE.
2025-12-15 20:13:34 +01:00
Samuel Tardieu ebfe9698f0 Parent of struct constructor is the struct itself
Also, the `Fn`/`AssocFn` cases were not tested anywhere, and according
to the comments inside `TyCtxt::res_generic_def_id()` could have made
the `TyCtxt::generics_of()` call also trigger an ICE.
2025-12-15 19:18:49 +01:00
Alejandra González d93e1eb294 Fix branches-sharing-code suggests wrongly on const and static (#15522)
Closes rust-lang/rust-clippy#15347

changelog: [`branches-sharing-code`] fix wrong suggestions on `const`
and `static`
2025-12-15 17:26:29 +00:00
Jason Newcomb 4d4789cdec Count unsafe operations and macro calls once towards the innermost unsafe block (#16117)
changelog: [`multiple_unsafe_ops_per_block`]: count unsafe operations
only towards the innermost unsafe block

Fixes rust-lang/rust-clippy#16116

r? Jarcho
2025-12-15 14:57:23 +00:00
Samuel Tardieu 099062d6b0 Fix set-contains-or-insert FP when set is mutated before insert (#16009)
Closes rust-lang/rust-clippy#15990

changelog: [`set-contains-or-insert`] fix FP when set is mutated before
`insert`
2025-12-15 13:19:09 +00:00
Samuel Tardieu 95d5990b99 Fix map_entry suggests wrongly for insert with cfg-ed out code (#15800)
Closes rust-lang/rust-clippy#15781

changelog: [`map_entry`] fix wrong suggestions for insert with cfg-ed
out code
2025-12-15 13:10:42 +00:00
Samuel Tardieu 924f153dcd Fix match_like_matches_macro wrongly unmangled macros (#16018)
Closes rust-lang/rust-clippy#16015

changelog: [`match_like_matches_macro`] fix wrongly unmangled macros
2025-12-15 12:49:30 +00:00
Samuel Tardieu 893677fc14 feat(format_push_string): give a (possibly incomplete) suggestion (#16093)
Resolves https://github.com/rust-lang/rust-clippy/issues/8824

Supersedes https://github.com/rust-lang/rust-clippy/pull/15828 -- I
wasn't able to get `TyCtxt::in_scope_traits` to work, so here's a more
basic implementation that just adds a note about the possible need to
import `std::fmt::Write`.

changelog: [`format_push_string`]: add a suggestion
2025-12-15 12:46:15 +00:00
Jason Newcomb d36794f5ec Add iterator reduction coverage to never_loop (#16222)
Fixes rust-lang/rust-clippy#16061.

Extend `never_loop` to also lint iterator reduction methods (e.g.
`for_each`, `try_for_each`, `fold`, `try_fold`, `reduce`, `all`, `any`)
when the closure’s body diverges (return type `!`). Add a UI test
`never_loop_iterator_reduction` to cover these cases.

Testing:
- TESTNAME=never_loop_iterator_reduction cargo uitest

changelog: [`never_loop`]: lint diverging iterator reduction closures
like `for_each` and `fold`
2025-12-15 12:00:31 +00:00
Cuong Le c59da4f809 loops: reuse iterator checks for unused_enumerate_index 2025-12-15 15:11:48 +07:00
dswij 80fce9b0f5 Fix if_not_else wrong unmangled macros (#15931)
Closes rust-lang/rust-clippy#15924

changelog: [`if_not_else`] fix wrongly unmangled macros
2025-12-14 03:58:00 +00:00
Cuong Le 9dca2a8ad3 Refactor loops MethodCall handling into single match 2025-12-14 09:56:35 +07:00
Jason Newcomb 9a089b63a0 Fix unchecked_time_subtraction FN on Ops::sub method call (#16233)
Closes rust-lang/rust-clippy#16230
Closes rust-lang/rust-clippy#16234
Closes rust-lang/rust-clippy#16236

changelog: [`unchecked_time_subtraction`] fix FN on `Ops::sub` method
call
2025-12-13 22:19:32 +00:00
Linshu Yang e0a74c3335 fix: manual_instant_elapsed wrongly unmangled macros 2025-12-13 20:57:44 +00:00
Linshu Yang e95ceddbc6 fix: unchecked_time_subtraction wrongly unmangled macros 2025-12-13 20:44:14 +00:00
Linshu Yang 075548e9e9 fix: unchecked_time_subtraction FN on Ops::sub method call 2025-12-13 20:44:10 +00:00
Jason Newcomb f206ef8452 Fix clippy::ref_as_ptr for non-temporary references in let/const (#16214)
Fix `ref_as_ptr` false positives for temporary values and
let/static/const initializers.

Fixes rust-lang/rust-clippy#16220

changelog: [`ref_as_ptr`]: Only lint on non-temporary expressions)
2025-12-13 18:42:05 +00:00
abd002 aefb01b852 Fix clippy::ref_as_ptr for non-temporary references in let/const 2025-12-13 19:27:43 +02:00
Cuong Le 51580d3835 Refine never_loop iterator reduction check 2025-12-13 21:34:20 +07:00
Jason Newcomb d06ae84771 feat(unnecessary_fold): lint on folds with Add::add/Mul::mul (#16124)
Resurrects https://github.com/rust-lang/rust-clippy/pull/13475

changelog: [`unnecessary_fold`]: lint on `fold`s with
`Add::add`/`Mul::mul`
2025-12-12 18:39:22 +00:00
Jason Newcomb 89aeed1c24 Fix if_then_some_else_none FP when encountering await codes (#16178)
changelog: Fix FP of [`if_then_some_else_none`] when the `then` block
contains `await` codes.

That is because `bool:then` doesn't work with await code.

Closes: rust-lang/rust-clippy#16176
2025-12-12 15:44:52 +00:00
Coca 8f9a93d0fd transmuting_null: Check const integer casts
changelog: [`transmuting_null`]: now checks const integers being casted
to pointers
2025-12-12 14:29:28 +00:00
Cuong Le fefd58b32b Clean up unused try_reduce entry in sym 2025-12-12 10:37:34 +07:00
Cuong Le 89a848c439 Fix fmt and dogfood lints for never_loop iterator reduction 2025-12-12 10:24:49 +07:00
Cuong Le 36201bdf3e Add iterator reduction coverage to never_loop 2025-12-12 10:01:58 +07:00
Philipp Krones 9e3e9649cb Rustup (#16217)
r? @ghost

changelog: none
2025-12-11 18:00:44 +00:00
Philipp Krones 1ff4682590 Bump Clippy version -> 0.1.94 2025-12-11 18:48:15 +01:00
Philipp Krones 42c8b68ee9 Bump nightly version -> 2025-12-11 2025-12-11 18:48:10 +01:00