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:

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
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
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
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
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
bendn
35bdd25e32
remove superseded lints
2025-05-09 19:25:55 +07: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
Alexey Semenyuk
1fbfbb59e9
Fix integer_division false negative for NonZero denominators
2025-05-08 16:12:47 +05: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
be40534457
Add primitive_method_to_numeric_cast lint
2025-05-07 18:18:04 +02:00
Alex Macleod
8c045221b5
Make let_with_type_underscore help message into a suggestion
2025-05-07 15:19:40 +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
737d3b3363
Remove some unused #![feature]s
2025-05-06 14:07:39 +00:00
yanglsh
d0af404b19
fix: manual_let_else FN when diverges on simple enum variant
2025-05-06 14:42:18 +08: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
Alex Macleod
8c93668a71
Gate collapsible_if let_chains lints on edition 2024 and MSRV
2025-05-06 02:23:28 +00:00
Jason Newcomb
c1586e141f
Replace str path utils with new PathLookup type ( #14705 )
...
The `&[&str]` path based `clippy_utils` have been removed and replace
with a new type `PathLookup`:
-
[`match_trait_method`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_trait_method.html )
-
[`match_qpath`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_qpath.html )
-
[`match_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_path.html )
-
[`match_any_def_paths`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_any_def_paths.html )
-
[`match_def_path`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.match_def_path.html )
-
[`match_type`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/ty/fn.match_type.html )
-
[`get_trait_def_id`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.get_trait_def_id.html )
Internally `PathLookup` is a lazy call to `lookup_path` (the new name
for
[`def_path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.def_path_res.html )
to distinguish it from
[`path_res`](https://doc.rust-lang.org/nightly/nightly-rustc/clippy_utils/fn.path_res.html ))
The `invalid_paths` internal lint is removed, it could be reimplemented
but it feels redundant since every path should be covered by a test
anyway
### User facing changes
- `manual_saturating_arithmetic` now checks for `u32::MAX/MIN` instead
of only detecting the legacy numeric consts (`std::u32::MAX/MIN`),
`clippy::legacy_numeric_constants` will redirect usages of the legacy
versions to the new one
- `allow-invalid = true` now suppresses all invalid path warnings,
currently you can run into a warning that can't be ignored in some
situations, e.g. with `serde` without the `derive` feature
```
warning: expected a macro, found a trait
--> /home/gh-Alexendoo/temp/clippy.toml:2:5
|
2 | { path = "serde::Serialize", allow-invalid = true },
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
```
- Re-exports of primitives types like `std::primitive::*` no longer work
in `disallowed-types`, this seems acceptable since it would be unusual
to deny a primitive this way rather than writing e.g. `usize`. Type
aliases such as `c_char` are unaffected
- A similar slight performance improvement to
https://github.com/rust-lang/rust-clippy/pull/14650
```bash
$ hyperfine -w 2 -p 'touch src/cargo/lib.rs' 'cargo +master clippy'
'cargo +lazy-paths clippy'
```
```
Benchmark 1: cargo +master clippy
Time (mean ± σ): 6.829 s ± 0.064 s [User: 6.079 s, System: 0.673 s]
Range (min … max): 6.705 s … 6.907 s 10 runs
Benchmark 2: cargo +lazy-paths clippy
Time (mean ± σ): 6.765 s ± 0.064 s [User: 5.984 s, System: 0.698 s]
Range (min … max): 6.636 s … 6.834 s 10 runs
Summary
cargo +lazy-paths clippy ran
1.01 ± 0.01 times faster than cargo +master clippy
```
changelog: none
2025-05-05 21:46:40 +00:00
Jason Newcomb
f62f269658
Fix manual_unwrap_or_default FP on ref binding ( #14731 )
...
Closes rust-lang/rust-clippy#14716
changelog: [`manual_unwrap_or_default`] fix FP on ref binding
2025-05-05 21:45:13 +00:00
Alejandra González
689e62b3b2
fix: unused_async FP on default impl ( #14720 )
...
Closes rust-lang/rust-clippy#14704
changelog: [`unused_async`] fix FP on default impl
2025-05-05 00:43:30 +00:00
Alex Macleod
f23772ce8c
Move lookup_path and similar into clippy_utils::paths
2025-05-04 17:13:02 +00:00
Alex Macleod
b768fbe4bc
Replace str path utils with new PathLookup type
2025-05-04 15:26:37 +00:00
Kaido Aethermai
64880cad75
add test 3, fmt and lint
2025-05-03 15:17:03 -07:00
Quang Duong Nguyen
481abc1361
fix doc
2025-05-03 15:17:03 -07:00
Quang Duong Nguyen
91a06226a1
move the implementation under check_def_field
2025-05-03 15:17:03 -07:00
Quang Duong Nguyen
c468552097
add allow_unused config to missing_docs_in_private_items
...
add allow_unused config to missing_docs_in_private_items for underscored field
2025-05-03 15:17:03 -07:00
yanglsh
7106e21227
fix: manual_unwrap_or_default FP on ref binding
2025-05-03 23:38:52 +08:00
Manish Goregaokar
56f018286b
fix: manual_slice_fill FP on IndexMut overload ( #14719 )
...
Closes rust-lang/rust-clippy#14685
changelog: [`manual_slice_fill`] fix FP on `IndexMut` overload
2025-05-02 17:07:07 +00:00
yanglsh
33ea0b482c
fix: manual_slice_fill FP on IndexMut overload
2025-05-02 15:09:00 +08:00
dswij
a53acefef7
Remove is_normalizable ( #14717 )
...
Supersedes rust-lang/rust-clippy#12550
`layout_of` no longer contains a `delay_bug` so there's no need for this
anymore.
changelog: None
2025-05-01 16:45:14 +00:00
Philipp Krones
43797675c2
Merge remote-tracking branch 'upstream/master' into rustup
2025-05-01 09:50:42 +02:00
yanglsh
782c6065c4
fix: unused_async FP on default impl
2025-05-01 14:50:23 +08:00
Jason Newcomb
36c3617bb1
Remove is_normalizable. layout_of no longer contains a delay_bug.
2025-04-30 19:31:24 -04:00