Commit graph

22526 commits

Author SHA1 Message Date
Philipp Krones
2ce5451850
Changelog for Clippy 1.87 🦡 (#14748)
Violets are red,
Roses are blue,
It’s wrong on purpose —
We don’t break tradition.

<hr>

This is cat-penguin of this release [nominated
by](https://github.com/rust-lang/rust-clippy/pull/12224#issuecomment-1927555104)
@xFrednet some time ago:

![image](https://github.com/user-attachments/assets/49bd7783-9d56-4a15-b026-1c7e799ea7ba)

Cats for the next release can be traditionally nominated in the comments
:D
Please be more active and cat-minded 😻

<hr>

changelog: none

r? flip1995
2025-05-12 10:00:01 +00:00
Alexey Semenyuk
55b5c835c5 Changelog for Clippy 1.87 2025-05-12 14:50:27 +05:00
Philipp Krones
74fd9edc49
book: modify FnKind::Fn matching (#14780)
This PR update the sample code in the development guide because `ident`
was moved to the struct `Fn` in
https://github.com/rust-lang/rust/pull/138740 .

changelog: none
2025-05-12 08:42:41 +00:00
Philipp Krones
48337da4a1
Use tempfile::TempDir::keep() instead of deprecated into_path() (#14784)
`tempfile` has deprecated `TempDir::into_path()` (replacing it by
`TempDir::keep()` between version `3.3` which Clippy required and
version `3.20` which is the latest semver-compatible version. Since
Clippy doesn't use a `Cargo.lock` file, the latest version of `tempfile`
is used which leads to CI failure.

changelog: none

r? @flip1995
2025-05-12 08:27:14 +00:00
Samuel Tardieu
8f5dc85f37
Use tempfile::TempDir::keep() instead of deprecated into_path()
`tempfile` has deprecated `TempDir::into_path()` (replacing it by
`TempDir::keep()`) between version `3.3` which Clippy required and version
`3.20.0` which is the latest semver-compatible version. Since Clippy
doesn't use a `Cargo.lock` file, the latest version of `tempfile` is
used which leads to CI failure.
2025-05-12 09:01:42 +02:00
Kazuki Obata
18eb293435
update dev doc: update FnKind::Fn matching
Ident was moved to the struct Fn in https://github.com/rust-lang/rust/pull/138740
2025-05-11 16:05:31 +09:00
Alejandra González
7f6d507bba
Fix ICE in missing_const_for_fn (#14776)
The `mir_drops_elaborated_and_const_checked` query result has been
stolen already and cannot be borrowed again. Use the `optimized_mir`
query result instead.

changelog: [`missing_const_for_fn`]: fix ICE with some compilation
options

Fixes rust-lang/rust-clippy#14774

r? @Jarcho
2025-05-10 21:15:31 +00:00
Samuel Tardieu
9ed53b85b7
Fix ICE in missing_const_for_fn
The `mir_drops_elaborated_and_const_checked` query result has been
stolen already and cannot be borrowed again. Use the `optimized_mir`
query result instead.
2025-05-10 22:10:28 +02:00
dswij
f60807dfee
Resolve through local re-exports in lookup_path (#14772)
Fixes https://github.com/rust-lang/rust-clippy/issues/14767

A long standing issue revealed by
https://github.com/rust-lang/rust-clippy/pull/14397

changelog: none
2025-05-10 16:55:19 +00:00
Samuel Tardieu
5262ab2416
Fix unnecessary_unwrap emitted twice in closure (#14763) (#14770)
The problem is that `check_fn` is triggered by both function and
closure, and `visit_expr` can visit expressions in another closures
within a function or closure.

So just skip walking in a inner closure.

changelog: Fix [`unnecessary_unwrap`] emitted twice in closure which
inside in a function or another closure.

Fixes: rust-lang/rust-clippy#14763
2025-05-10 14:15:50 +00:00
relaxcn
e61886a6d9 fix unnecessary_unwrap emitted twice in closure 2025-05-10 07:12:40 +08:00
Alejandra González
3c5e403824
char::is_digit() is const-stable only since Rust 1.87 (#14771)
The `to_digit_is_some()` lint suggests using `char::is_digit()`. It
should not trigger in const contexts before Rust 1.87.

changelog: [`to_digit_is_some`]: Do not lint in const contexts when MSRV
is below 1.87
2025-05-09 23:06:29 +00:00
Samuel Tardieu
bde939058b
char::is_digit() is const-stable only since Rust 1.87
The `to_digit_is_some()` lint suggests using `char::is_digit()`. It
should not trigger in const contexts before Rust 1.87.
2025-05-10 00:20:55 +02:00
Alex Macleod
e4d82aefd9 Resolve through local re-exports in lookup_path 2025-05-09 22:13:35 +00:00
Alejandra González
16fd2a83d7
Fix integer_division false negative for NonZero denominators (#14664)
Close rust-lang/rust-clippy#14652

changelog: [`integer_division`]: fix false negative for NonZero
denominators
2025-05-09 20:50:04 +00:00
dswij
a67ee902df
unwrap.rs cleanup (#14761)
This cleans up `unwrap.rs`:

- use interned symbols instead of strings
- update names to reflect the current implementation
- replaced a cascaded `if` by a shorter `match`

changelog: none
2025-05-09 16:55:12 +00:00
Samuel Tardieu
756de2ab82
remove superseded lints (#14703)
changelog: [`transmute_float_to_int, transmute_int_to_char,
transmute_int_to_float`, `transmute_num_to_bytes`]: remove lints, now in
rustc

these lints are now mostly in rustc, so they dont need to be in clippy
anymore

https://github.com/rust-lang/rust/pull/136083#discussion_r2009897120

pending https://github.com/rust-lang/rust/pull/140431:
transmute_int_to_bool

<!-- TRIAGEBOT_START -->

<!-- TRIAGEBOT_SUMMARY_START -->

### Summary Notes

- ["Rust version of new lints should be checked" by
@samueltardieu](https://github.com/rust-lang/rust-clippy/pull/14703#issuecomment-2861982576)

Generated by triagebot, see
[help](https://forge.rust-lang.org/triagebot/note.html) for how to add
more
<!--
TRIAGEBOT_SUMMARY_DATA_START$${"entries_by_url":{"https://github.com/rust-lang/rust-clippy/pull/14703#issuecomment-2861982576":{"title":"Rust
version of new lints should be
checked","comment_url":"https://github.com/rust-lang/rust-clippy/pull/14703#issuecomment-2861982576","author":"samueltardieu"}}}$$TRIAGEBOT_SUMMARY_DATA_END
-->

<!-- TRIAGEBOT_SUMMARY_END -->
<!-- TRIAGEBOT_END -->
2025-05-09 16:12:59 +00:00
Philipp Krones
656b31768d
Allow any rust-lang team member to close an issue with rustbot (#14765)
changelog: none

It is useful, and happened in
https://github.com/rust-lang/rust-clippy/issues/12806#issuecomment-2863646739
2025-05-09 13:08:03 +00:00
Philipp Krones
4a64903640
Use cargo dev setup toolchain in install from source docs (#14766)
changelog: none
2025-05-09 13:06:10 +00:00
bendn
35bdd25e32
remove superseded lints 2025-05-09 19:25:55 +07:00
Alex Macleod
33f81c08aa Use cargo dev setup toolchain in install from source docs 2025-05-09 01:38:20 +00:00
Samuel Tardieu
3a6fcd2170
Allow any rust-lang team member to close an issue 2025-05-09 01:13:51 +02:00
Samuel Tardieu
d8726caacc
fix false negative for unnecessary_unwrap (#14758)
changelog: Fix [`unnecessary_unwrap`] false negative when any assignment
occurs in `if` branch (regardless of any variable).

Fixes: rust-lang/rust-clippy#14725
2025-05-08 22:12:02 +00:00
Manish Goregaokar
33519b7c99
Set Manish in vacation mode (#14762)
changelog: none

r? @Manishearth
2025-05-08 19:50:09 +00:00
Samuel Tardieu
1044e5bbcc Set Manish in vacation mode 2025-05-08 21:40:20 +02:00
Samuel Tardieu
4cbd116460 unwrap.rs: internal naming cleanup
Since its conception, the lint has been extended from `Option`
only to `Option` and `Result`, but some function names and comment still
references only `Option`.

Also, one cascaded `if` was replaced by a shorter `match`.
2025-05-08 21:02:53 +02:00
Samuel Tardieu
668a292ca3 unwrap.rs: replace some strings usage by interned symbols 2025-05-08 21:02:46 +02:00
relaxcn
b73d3b4384 fix issue-14725 2025-05-09 01:21:14 +08:00
Philipp Krones
e04158caed
triagebot: canonicalize-issue-linksissue-links (#14751)
The feature [has been
renamed](https://forge.rust-lang.org/triagebot/canonicalize-issue-links.html).

changelog: none
2025-05-08 11:45:29 +00:00
Alexey Semenyuk
1fbfbb59e9 Fix integer_division false negative for NonZero denominators 2025-05-08 16:12:47 +05:00
Samuel Tardieu
d17eeb5d83 triagebot: canonicalize-issue-linksissue-links
The feature has been renamed in triagebot
(https://forge.rust-lang.org/triagebot/canonicalize-issue-links.html).
2025-05-08 00:04:38 +02:00
dswij
f88f9a9dc5
Fix manual_let_else FN when diverges on simple enum variant (#14732)
Closes rust-lang/rust-clippy#14598

Implemented checks for simple enum variants when checking if match arms
are disjointed.

changelog: [`manual_let_else`] fix FN when diverges on simple enum
variant
2025-05-07 16:33:07 +00:00
Samuel Tardieu
50cff118d8
Make let_with_type_underscore help message into a suggestion (#14749)
changelog: none
2025-05-07 16:26:54 +00:00
Jason Newcomb
34cd9486c9
Fix diagnostic paths printed by dogfood test (#14746)
Where you would previously see

```
error: some lint
   --> src/lib.rs:1:2
```

it will now print

```
error: some lint
   --> clippy_lints/src/lib.rs:1:2
```

Ensuring you can click the link in the terminal

A workaround for us not being in a workspace

changelog: none
2025-05-07 15:24:46 +00:00
Alex Macleod
8c045221b5 Make let_with_type_underscore help message into a suggestion 2025-05-07 15:19:40 +00:00
Alex Macleod
772ea35935 Fix diagnostic paths printed by dogfood test 2025-05-07 14:32:23 +00:00
Manish Goregaokar
ca6281628e
Replace Symbol::as_str usage in match expressions (#14745)
We could do with a way to make matching on the `assert_*` macro kind
easier, this came up a bunch here. I'll take a look at that as a follow
up

changelog: none
2025-05-07 14:09:53 +00:00
Alex Macleod
5aac708398 Replace Symbol::as_str usage in match expressions 2025-05-07 13:52:11 +00:00
Jason Newcomb
ca78fb4031
unwrap_used, expect_used: accept macro result as receiver (#14575)
changelog: [`unwrap_used`, `expect_used`]: lint even when the receiver
is a macro expansion result

This also paves the way for expanding more method call lints to expanded
receivers or arguments.

Fixes rust-lang/rust-clippy#13455
2025-05-07 08:09:47 +00:00
Samuel Tardieu
999db5cdc6 unwrap_used, expect_used: accept macro result as receiver 2025-05-07 10:04:52 +02:00
Manish Goregaokar
fc811f7e2e
item_name_repetitions: exclude enum variants with identical path components (#14619)
fix rust-lang/rust-clippy#13637

As suggested in the PR above, we should not lint enum variants
containing matching path names.

changelog: [`item_name_repetitions`]: exclude enum variants with
identical path components
2025-05-06 18:30:14 +00:00
Samuel Tardieu
73dd05cc7a
add allow_unused config to missing_docs_in_private_items (#14453)
fixes #14413
add allow_unused config to missing_docs_in_private_items for underscored
field

changelog: [`missing_docs_in_private_items`]: add allow_unused config to
missing_docs_in_private_items for underscored field

Explaination (quoted from the issue's author): When writing structures
that must adhere to a specific format (such as memory mapped I/O
structures) there are inevitably fields that are "reserved" by
specifications and thus need no documentation. In cases where private
docs are preferred but reserved fields need no explanation, having to
#[allow/expect] this lint removes the ability to check for otherwise
used fields' documentation.
2025-05-06 17:18:14 +00:00
Alex Macleod
cf6bebb343
Remove some unused #![feature]s (#14738)
Mostly `let_chains` now that it's stable on 2024

changelog: none
2025-05-06 14:12:20 +00:00
Alex Macleod
737d3b3363 Remove some unused #![feature]s 2025-05-06 14:07:39 +00:00
Alex Macleod
94aa0d9a75 Update clippy_lints_internal to 2024 edition 2025-05-06 14:07:14 +00:00
yanglsh
d0af404b19 fix: manual_let_else FN when diverges on simple enum variant 2025-05-06 14:42:18 +08:00
Samuel Tardieu
7fdded3e37
Fix collapsible_if FP on block stmt before expr (#14730)
Closes rust-lang/rust-clippy#14722

changelog: [`collapsible_if`] fix FP on block stmt before expr
2025-05-06 06:33:10 +00:00
yanglsh
e7acf5c9b9 fix: collapsible_if FP on block stmt before expr 2025-05-06 14:25:21 +08:00
Samuel Tardieu
50e0bf1b71
Gate collapsible_if let_chains lints on edition 2024 and MSRV (#14723)
The MSRV being for crates targeting 1.85-1.87 on edition 2024

This enables the lint for regular nightly users without the feature gate
enabled

r? @samueltardieu

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

changelog: none
2025-05-06 05:40:37 +00:00
Aaron Ang
e89cf4d389 item_name_repetitions: exclude enum variants with identical path components 2025-05-05 20:15:50 -07:00