Skip to content

Commit bb88319

Browse files
committed
Auto merge of #149884 - flip1995:clippy-subtree-update, r=samueltardieu
Clippy subtree update r? `@Manishearth` Cargo.lock update due to Clippy version bump.
2 parents 5b150d2 + 26c164f commit bb88319

File tree

98 files changed

+4094
-1116
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+4094
-1116
lines changed

Cargo.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -621,7 +621,7 @@ checksum = "a1d728cc89cf3aee9ff92b05e62b19ee65a02b5702cff7d5a377e32c6ae29d8d"
621621

622622
[[package]]
623623
name = "clippy"
624-
version = "0.1.93"
624+
version = "0.1.94"
625625
dependencies = [
626626
"anstream",
627627
"askama",
@@ -648,7 +648,7 @@ dependencies = [
648648

649649
[[package]]
650650
name = "clippy_config"
651-
version = "0.1.93"
651+
version = "0.1.94"
652652
dependencies = [
653653
"clippy_utils",
654654
"itertools",
@@ -671,7 +671,7 @@ dependencies = [
671671

672672
[[package]]
673673
name = "clippy_lints"
674-
version = "0.1.93"
674+
version = "0.1.94"
675675
dependencies = [
676676
"arrayvec",
677677
"cargo_metadata 0.18.1",
@@ -703,7 +703,7 @@ dependencies = [
703703

704704
[[package]]
705705
name = "clippy_utils"
706-
version = "0.1.93"
706+
version = "0.1.94"
707707
dependencies = [
708708
"arrayvec",
709709
"itertools",
@@ -1107,7 +1107,7 @@ dependencies = [
11071107

11081108
[[package]]
11091109
name = "declare_clippy_lint"
1110-
version = "0.1.93"
1110+
version = "0.1.94"
11111111

11121112
[[package]]
11131113
name = "derive-where"

src/tools/clippy/CHANGELOG.md

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,83 @@ document.
66

77
## Unreleased / Beta / In Rust Nightly
88

9-
[e9b7045...master](https://github.com/rust-lang/rust-clippy/compare/e9b7045...master)
9+
[d9fb15c...master](https://github.com/rust-lang/rust-clippy/compare/d9fb15c...master)
10+
11+
## Rust 1.92
12+
13+
Current stable, released 2025-12-11
14+
15+
[View all 124 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2025-09-05T18%3A24%3A03Z..2025-10-16T14%3A13%3A43Z+base%3Amaster)
16+
17+
### New Lints
18+
19+
* Added [`unnecessary_option_map_or_else`] to `suspicious`
20+
[#14662](https://github.com/rust-lang/rust-clippy/pull/14662)
21+
* Added [`replace_box`] to `perf`
22+
[#14953](https://github.com/rust-lang/rust-clippy/pull/14953)
23+
* Added [`volatile_composites`] to `nursery`
24+
[#15686](https://github.com/rust-lang/rust-clippy/pull/15686)
25+
* Added [`self_only_used_in_recursion`] to `pedantic`
26+
[#14787](https://github.com/rust-lang/rust-clippy/pull/14787)
27+
* Added [`redundant_iter_cloned`] to `perf`
28+
[#15277](https://github.com/rust-lang/rust-clippy/pull/15277)
29+
30+
### Moves and Deprecations
31+
32+
* Renamed [`unchecked_duration_subtraction`] to [`unchecked_time_subtraction`]
33+
[#13800](https://github.com/rust-lang/rust-clippy/pull/13800)
34+
35+
### Enhancements
36+
37+
* [`mutex_atomic`] and [`mutex_integer`] overhauled to only lint definitions, not uses; added suggestions
38+
and better help messages
39+
[#15632](https://github.com/rust-lang/rust-clippy/pull/15632)
40+
* [`manual_rotate`] now recognizes non-const rotation amounts
41+
[#15402](https://github.com/rust-lang/rust-clippy/pull/15402)
42+
* [`multiple_inherent_impl`] added `inherent-impl-lint-scope` config option (`module`, `file`,
43+
or `crate`)
44+
[#15843](https://github.com/rust-lang/rust-clippy/pull/15843)
45+
* [`use_self`] now checks structs and enums
46+
[#15566](https://github.com/rust-lang/rust-clippy/pull/15566)
47+
* [`while_let_loop`] extended to lint on `loop { let else }`
48+
[#15701](https://github.com/rust-lang/rust-clippy/pull/15701)
49+
* [`mut_mut`] overhauled with structured suggestions and improved documentation
50+
[#15417](https://github.com/rust-lang/rust-clippy/pull/15417)
51+
* [`nonstandard_macro_braces`] now suggests trailing semicolon when needed
52+
[#15593](https://github.com/rust-lang/rust-clippy/pull/15593)
53+
* [`ptr_offset_with_cast`] now respects MSRV when suggesting fix, and lints more cases
54+
[#15613](https://github.com/rust-lang/rust-clippy/pull/15613)
55+
* [`cast_sign_loss`] and [`cast_possible_wrap`] added suggestions using `cast_{un,}signed()` methods
56+
(MSRV 1.87+)
57+
[#15384](https://github.com/rust-lang/rust-clippy/pull/15384)
58+
* [`unchecked_time_subtraction`] extended to include `Duration - Duration` operations
59+
[#13800](https://github.com/rust-lang/rust-clippy/pull/13800)
60+
* [`filter_next`] now suggests replacing `filter().next_back()` with `rfind()` for
61+
`DoubleEndedIterator`
62+
[#15748](https://github.com/rust-lang/rust-clippy/pull/15748)
63+
64+
### False Positive Fixes
65+
66+
* [`unnecessary_safety_comment`] fixed FPs with comments above attributes
67+
[#15678](https://github.com/rust-lang/rust-clippy/pull/15678)
68+
* [`manual_unwrap_or`] fixed FP edge case
69+
[#15812](https://github.com/rust-lang/rust-clippy/pull/15812)
70+
* [`needless_continue`] fixed FP when match type is not unit or never
71+
[#15547](https://github.com/rust-lang/rust-clippy/pull/15547)
72+
* [`if_then_some_else_none`] fixed FP when return exists in block expr
73+
[#15783](https://github.com/rust-lang/rust-clippy/pull/15783)
74+
* [`new_without_default`] fixed to copy `#[cfg]` onto `impl Default` and fixed FP on private type
75+
with trait impl
76+
[#15720](https://github.com/rust-lang/rust-clippy/pull/15720)
77+
[#15782](https://github.com/rust-lang/rust-clippy/pull/15782)
78+
* [`question_mark`] fixed FP on variables used after
79+
[#15644](https://github.com/rust-lang/rust-clippy/pull/15644)
80+
* [`needless_return`] fixed FP with `cfg`d code after `return`
81+
[#15669](https://github.com/rust-lang/rust-clippy/pull/15669)
82+
* [`useless_attribute`] fixed FP on `deprecated_in_future`
83+
[#15645](https://github.com/rust-lang/rust-clippy/pull/15645)
84+
* [`double_parens`] fixed FP when macros are involved
85+
[#15420](https://github.com/rust-lang/rust-clippy/pull/15420)
1086

1187
## Rust 1.91
1288

@@ -6280,6 +6356,7 @@ Released 2018-09-13
62806356
[`cyclomatic_complexity`]: https://rust-lang.github.io/rust-clippy/master/index.html#cyclomatic_complexity
62816357
[`dbg_macro`]: https://rust-lang.github.io/rust-clippy/master/index.html#dbg_macro
62826358
[`debug_assert_with_mut_call`]: https://rust-lang.github.io/rust-clippy/master/index.html#debug_assert_with_mut_call
6359+
[`decimal_bitwise_operands`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_bitwise_operands
62836360
[`decimal_literal_representation`]: https://rust-lang.github.io/rust-clippy/master/index.html#decimal_literal_representation
62846361
[`declare_interior_mutable_const`]: https://rust-lang.github.io/rust-clippy/master/index.html#declare_interior_mutable_const
62856362
[`default_constructed_unit_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#default_constructed_unit_structs
@@ -6541,6 +6618,7 @@ Released 2018-09-13
65416618
[`manual_flatten`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_flatten
65426619
[`manual_hash_one`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_hash_one
65436620
[`manual_ignore_case_cmp`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ignore_case_cmp
6621+
[`manual_ilog2`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_ilog2
65446622
[`manual_inspect`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_inspect
65456623
[`manual_instant_elapsed`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_instant_elapsed
65466624
[`manual_is_ascii_check`]: https://rust-lang.github.io/rust-clippy/master/index.html#manual_is_ascii_check
@@ -6686,6 +6764,7 @@ Released 2018-09-13
66866764
[`needless_return`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
66876765
[`needless_return_with_question_mark`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_return_with_question_mark
66886766
[`needless_splitn`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_splitn
6767+
[`needless_type_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_type_cast
66896768
[`needless_update`]: https://rust-lang.github.io/rust-clippy/master/index.html#needless_update
66906769
[`neg_cmp_op_on_partial_ord`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_cmp_op_on_partial_ord
66916770
[`neg_multiply`]: https://rust-lang.github.io/rust-clippy/master/index.html#neg_multiply
@@ -6765,6 +6844,7 @@ Released 2018-09-13
67656844
[`ptr_as_ptr`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_as_ptr
67666845
[`ptr_cast_constness`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_cast_constness
67676846
[`ptr_eq`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_eq
6847+
[`ptr_offset_by_literal`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_by_literal
67686848
[`ptr_offset_with_cast`]: https://rust-lang.github.io/rust-clippy/master/index.html#ptr_offset_with_cast
67696849
[`pub_enum_variant_names`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_enum_variant_names
67706850
[`pub_underscore_fields`]: https://rust-lang.github.io/rust-clippy/master/index.html#pub_underscore_fields
@@ -7081,6 +7161,7 @@ Released 2018-09-13
70817161
[`allow-expect-in-consts`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-consts
70827162
[`allow-expect-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-expect-in-tests
70837163
[`allow-indexing-slicing-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-indexing-slicing-in-tests
7164+
[`allow-large-stack-frames-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-large-stack-frames-in-tests
70847165
[`allow-mixed-uninlined-format-args`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-mixed-uninlined-format-args
70857166
[`allow-one-hash-in-raw-strings`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-one-hash-in-raw-strings
70867167
[`allow-panic-in-tests`]: https://doc.rust-lang.org/clippy/lint_configuration.html#allow-panic-in-tests

src/tools/clippy/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.93"
3+
version = "0.1.94"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

src/tools/clippy/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
A collection of lints to catch common mistakes and improve your [Rust](https://github.com/rust-lang/rust) code.
66

7-
[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
7+
[There are over 800 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
88

99
Lints are divided into categories, each with a default [lint level](https://doc.rust-lang.org/rustc/lints/levels.html).
1010
You can choose how much Clippy is supposed to ~~annoy~~ help you by changing the lint level by category.

src/tools/clippy/book/src/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
A collection of lints to catch common mistakes and improve your
66
[Rust](https://github.com/rust-lang/rust) code.
77

8-
[There are over 750 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
8+
[There are over 800 lints included in this crate!](https://rust-lang.github.io/rust-clippy/master/index.html)
99

1010
Lints are divided into categories, each with a default [lint
1111
level](https://doc.rust-lang.org/rustc/lints/levels.html). You can choose how

src/tools/clippy/book/src/lint_configuration.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,16 @@ Whether `indexing_slicing` should be allowed in test functions or `#[cfg(test)]`
111111
* [`indexing_slicing`](https://rust-lang.github.io/rust-clippy/master/index.html#indexing_slicing)
112112

113113

114+
## `allow-large-stack-frames-in-tests`
115+
Whether functions inside `#[cfg(test)]` modules or test functions should be checked.
116+
117+
**Default Value:** `true`
118+
119+
---
120+
**Affected lints:**
121+
* [`large_stack_frames`](https://rust-lang.github.io/rust-clippy/master/index.html#large_stack_frames)
122+
123+
114124
## `allow-mixed-uninlined-format-args`
115125
Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)`
116126

src/tools/clippy/clippy_config/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_config"
3-
version = "0.1.93"
3+
version = "0.1.94"
44
edition = "2024"
55
publish = false
66

src/tools/clippy/clippy_config/src/conf.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,9 @@ define_Conf! {
373373
/// Whether `indexing_slicing` should be allowed in test functions or `#[cfg(test)]`
374374
#[lints(indexing_slicing)]
375375
allow_indexing_slicing_in_tests: bool = false,
376+
/// Whether functions inside `#[cfg(test)]` modules or test functions should be checked.
377+
#[lints(large_stack_frames)]
378+
allow_large_stack_frames_in_tests: bool = true,
376379
/// Whether to allow mixed uninlined format args, e.g. `format!("{} {}", a, foo.bar)`
377380
#[lints(uninlined_format_args)]
378381
allow_mixed_uninlined_format_args: bool = true,

src/tools/clippy/clippy_lints/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.93"
3+
version = "0.1.94"
44
description = "A bunch of helpful lints to avoid common pitfalls in Rust"
55
repository = "https://github.com/rust-lang/rust-clippy"
66
readme = "README.md"

src/tools/clippy/clippy_lints/src/casts/mod.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ mod fn_to_numeric_cast;
1919
mod fn_to_numeric_cast_any;
2020
mod fn_to_numeric_cast_with_truncation;
2121
mod manual_dangling_ptr;
22+
mod needless_type_cast;
2223
mod ptr_as_ptr;
2324
mod ptr_cast_constness;
2425
mod ref_as_ptr;
@@ -813,6 +814,32 @@ declare_clippy_lint! {
813814
"casting a primitive method pointer to any integer type"
814815
}
815816

817+
declare_clippy_lint! {
818+
/// ### What it does
819+
/// Checks for bindings (constants, statics, or let bindings) that are defined
820+
/// with one numeric type but are consistently cast to a different type in all usages.
821+
///
822+
/// ### Why is this bad?
823+
/// If a binding is always cast to a different type when used, it would be clearer
824+
/// and more efficient to define it with the target type from the start.
825+
///
826+
/// ### Example
827+
/// ```no_run
828+
/// const SIZE: u16 = 15;
829+
/// let arr: [u8; SIZE as usize] = [0; SIZE as usize];
830+
/// ```
831+
///
832+
/// Use instead:
833+
/// ```no_run
834+
/// const SIZE: usize = 15;
835+
/// let arr: [u8; SIZE] = [0; SIZE];
836+
/// ```
837+
#[clippy::version = "1.93.0"]
838+
pub NEEDLESS_TYPE_CAST,
839+
pedantic,
840+
"binding defined with one type but always cast to another"
841+
}
842+
816843
pub struct Casts {
817844
msrv: Msrv,
818845
}
@@ -851,6 +878,7 @@ impl_lint_pass!(Casts => [
851878
AS_POINTER_UNDERSCORE,
852879
MANUAL_DANGLING_PTR,
853880
CONFUSING_METHOD_TO_NUMERIC_CAST,
881+
NEEDLESS_TYPE_CAST,
854882
]);
855883

856884
impl<'tcx> LateLintPass<'tcx> for Casts {
@@ -920,4 +948,8 @@ impl<'tcx> LateLintPass<'tcx> for Casts {
920948
cast_slice_different_sizes::check(cx, expr, self.msrv);
921949
ptr_cast_constness::check_null_ptr_cast_method(cx, expr);
922950
}
951+
952+
fn check_body(&mut self, cx: &LateContext<'tcx>, body: &rustc_hir::Body<'tcx>) {
953+
needless_type_cast::check(cx, body);
954+
}
923955
}

0 commit comments

Comments
 (0)