Commit graph

22541 commits

Author SHA1 Message Date
Philipp Krones
54aa120f18
Update "Changelog update walkthrough" section (#14785)
Update "Changelog update walkthrough" section based on
rust-lang/rust-clippy#14748 discussion

changelog: none
2025-05-12 19:29:36 +00:00
Alexey Semenyuk
2215282fa4 Update Changelog update walkthrough docs section 2025-05-12 22:15:53 +05:00
llogiq
83248e57e9
Fix messages for type_repetition_in_bounds (#14752)
changelog: [`type_repetition_in_bounds`]: include all generic bounds in
suggestion, clearer message which now includes the repeated type name

Fixes rust-lang/rust-clippy#14744
2025-05-12 16:37:11 +00:00
Samuel Tardieu
c6a23f8fbd
Include all bounds in bounds consolidation
Also, include the type name in the lint message, and simplify the span
computation.
2025-05-12 18:32:17 +02:00
llogiq
459364b971
return_and_then: only lint returning expressions (#14783)
If an expression is not going to return from the current function of
closure, it should not get linted.

This also allows `return` expression to be linted, in addition to the
final expression. Those require blockification and proper indentation.

changelog: [`return_and_then`]: only lint returning expressions

Fixes rust-lang/rust-clippy#14781
2025-05-12 16:01:55 +00:00
llogiq
62ba9969a4
Fix clippy::version of elidable_lifetime_names to 1.87 (#14654)
relates to rust-lang/rust-clippy#14653

changelog: [`elidable_lifetime_names`]: Fix clippy version that this
lint was introduced in.

It might be good to have some automation to check that the version is
correct.
IIUC the version should be the current nightly version at the time a PR
is merged.
If a release happens while a PR is open, the version needs to be bumped
- this is easy to forget.
2025-05-12 15:53:05 +00:00
llogiq
b363499457
Add new confusing_method_to_numeric_cast lint (#13979)
Fixes https://github.com/rust-lang/rust-clippy/issues/13973.

I don't think we can make `fn_to_numeric_cast_any` to be emitted in some
special cases. Its category cannot be changed at runtime.

I think in this case, the best might be a specialized new lint so we can
target exactly what we want.

----

changelog: Add new `confusing_method_to_numeric_cast` lint
2025-05-12 15:27:33 +00:00
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
Samuel Tardieu
c040e9f6fc
return_and_then: only lint returning expressions
If an expression is not going to return from the current function of
closure, it should not get linted.

This also allows `return` expression to be linted, in addition to the
final expression. Those require blockification and proper indentation.
2025-05-11 18:43:01 +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
Guillaume Gomez
a94abae911 Clarify docs of CONFUSING_METHOD_TO_NUMERIC_CAST 2025-05-07 21:42:21 +02:00
Guillaume Gomez
06fa0452eb Rename lint into confusing_method_to_numeric_cast 2025-05-07 21:38: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
Guillaume Gomez
c680419425 Add UI test for primitive_method_to_numeric_cast 2025-05-07 18:18:06 +02:00
Guillaume Gomez
be40534457 Add primitive_method_to_numeric_cast lint 2025-05-07 18:18:04 +02: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