Skip to content

Commit 1a7e97f

Browse files
committed
Auto merge of #119387 - flip1995:clippy-subtree-sync, r=matthiaskrgr
Clippy subtree update r? `@Manishearth`
2 parents b74f5c4 + 0217ac9 commit 1a7e97f

File tree

119 files changed

+2536
-326
lines changed

Some content is hidden

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

119 files changed

+2536
-326
lines changed

Cargo.lock

+5-5
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b"
537537

538538
[[package]]
539539
name = "clippy"
540-
version = "0.1.76"
540+
version = "0.1.77"
541541
dependencies = [
542542
"anstream",
543543
"clippy_config",
@@ -565,7 +565,7 @@ dependencies = [
565565

566566
[[package]]
567567
name = "clippy_config"
568-
version = "0.1.76"
568+
version = "0.1.77"
569569
dependencies = [
570570
"rustc-semver",
571571
"serde",
@@ -588,7 +588,7 @@ dependencies = [
588588

589589
[[package]]
590590
name = "clippy_lints"
591-
version = "0.1.76"
591+
version = "0.1.77"
592592
dependencies = [
593593
"arrayvec",
594594
"cargo_metadata 0.15.4",
@@ -613,7 +613,7 @@ dependencies = [
613613

614614
[[package]]
615615
name = "clippy_utils"
616-
version = "0.1.76"
616+
version = "0.1.77"
617617
dependencies = [
618618
"arrayvec",
619619
"clippy_config",
@@ -984,7 +984,7 @@ checksum = "a0afaad2b26fa326569eb264b1363e8ae3357618c43982b3f285f0774ce76b69"
984984

985985
[[package]]
986986
name = "declare_clippy_lint"
987-
version = "0.1.76"
987+
version = "0.1.77"
988988
dependencies = [
989989
"itertools",
990990
"quote",

src/tools/clippy/CHANGELOG.md

+65-3
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,68 @@ document.
66

77
## Unreleased / Beta / In Rust Nightly
88

9-
[7671c283...master](https://github.com/rust-lang/rust-clippy/compare/7671c283...master)
9+
[09ac14c9...master](https://github.com/rust-lang/rust-clippy/compare/09ac14c9...master)
10+
11+
## Rust 1.75
12+
13+
Current stable, released 2023-12-28
14+
15+
[View all 69 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-09-25T11%3A47%3A47Z..2023-11-02T16%3A41%3A59Z+base%3Amaster)
16+
17+
### New Lints
18+
19+
* [`unused_enumerate_index`]
20+
[#10404](https://github.com/rust-lang/rust-clippy/pull/10404)
21+
* [`unnecessary_fallible_conversions`]
22+
[#11669](https://github.com/rust-lang/rust-clippy/pull/11669)
23+
* [`waker_clone_wake`]
24+
[#11698](https://github.com/rust-lang/rust-clippy/pull/11698)
25+
* [`struct_field_names`]
26+
[#11496](https://github.com/rust-lang/rust-clippy/pull/11496)
27+
* [`into_iter_without_iter`]
28+
[#11587](https://github.com/rust-lang/rust-clippy/pull/11587)
29+
* [`iter_without_into_iter`]
30+
[#11527](https://github.com/rust-lang/rust-clippy/pull/11527)
31+
* [`manual_hash_one`]
32+
[#11556](https://github.com/rust-lang/rust-clippy/pull/11556)
33+
34+
35+
### Moves and Deprecations
36+
37+
* Moved [`read_zero_byte_vec`] to `nursery` (Now allow-by-default)
38+
[#11727](https://github.com/rust-lang/rust-clippy/pull/11727)
39+
* Moved [`missing_enforced_import_renames`] to `style` (Now warn-by-default)
40+
[#11539](https://github.com/rust-lang/rust-clippy/pull/11539)
41+
* Moved [`needless_raw_string_hashes`] to `pedantic` (Now allow-by-default)
42+
[#11415](https://github.com/rust-lang/rust-clippy/pull/11415)
43+
* Moved [`needless_pass_by_ref_mut`] to `nursery` (Now allow-by-default)
44+
[#11596](https://github.com/rust-lang/rust-clippy/pull/11596)
45+
46+
### Enhancements
47+
48+
* [`declare_interior_mutable_const`] and [`borrow_interior_mutable_const`]: Now check the
49+
[`ignore-interior-mutability`] config value
50+
[#11678](https://github.com/rust-lang/rust-clippy/pull/11678)
51+
52+
### Suggestion Fixes/Improvements
53+
54+
* [`items_after_test_module`]: The suggestion is now machine-applicable
55+
[#11611](https://github.com/rust-lang/rust-clippy/pull/11611)
56+
57+
### ICE Fixes
58+
59+
* [`redundant_locals`]: No longer crashes if variables are rebound above macros
60+
[#11623](https://github.com/rust-lang/rust-clippy/pull/11623)
61+
* [`implicit_hasher`]: No longer lints inside macros, which could cause ICEs
62+
[#11593](https://github.com/rust-lang/rust-clippy/pull/11593)
63+
64+
### Documentation Improvements
65+
66+
* `cargo clippy --help` now uses colors for readability :tada:
1067

1168
## Rust 1.74
1269

13-
Current stable, released 2023-11-16
70+
Released 2023-11-16
1471

1572
[View all 94 merged pull requests](https://github.com/rust-lang/rust-clippy/pulls?q=merged%3A2023-08-11T15%3A29%3A18Z..2023-09-25T08%3A48%3A22Z+base%3Amaster)
1673

@@ -51,7 +108,7 @@ Current stable, released 2023-11-16
51108
### Enhancements
52109

53110
* [`undocumented_unsafe_blocks`]: The config values [`accept-comment-above-statement`] and
54-
[`accept-comment-above-attributes`] to `true` by default
111+
[`accept-comment-above-attributes`] are now `true` by default
55112
[#11170](https://github.com/rust-lang/rust-clippy/pull/11170)
56113
* [`explicit_iter_loop`]: Added [`enforce-iter-loop-reborrow`] to disable reborrow linting by default
57114
[#11418](https://github.com/rust-lang/rust-clippy/pull/11418)
@@ -5044,6 +5101,7 @@ Released 2018-09-13
50445101
[`duplicate_mod`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_mod
50455102
[`duplicate_underscore_argument`]: https://rust-lang.github.io/rust-clippy/master/index.html#duplicate_underscore_argument
50465103
[`duration_subsec`]: https://rust-lang.github.io/rust-clippy/master/index.html#duration_subsec
5104+
[`eager_transmute`]: https://rust-lang.github.io/rust-clippy/master/index.html#eager_transmute
50475105
[`else_if_without_else`]: https://rust-lang.github.io/rust-clippy/master/index.html#else_if_without_else
50485106
[`empty_drop`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_drop
50495107
[`empty_enum`]: https://rust-lang.github.io/rust-clippy/master/index.html#empty_enum
@@ -5177,6 +5235,8 @@ Released 2018-09-13
51775235
[`items_after_test_module`]: https://rust-lang.github.io/rust-clippy/master/index.html#items_after_test_module
51785236
[`iter_cloned_collect`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_cloned_collect
51795237
[`iter_count`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_count
5238+
[`iter_filter_is_ok`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_filter_is_ok
5239+
[`iter_filter_is_some`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_filter_is_some
51805240
[`iter_kv_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_kv_map
51815241
[`iter_next_loop`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_loop
51825242
[`iter_next_slice`]: https://rust-lang.github.io/rust-clippy/master/index.html#iter_next_slice
@@ -5470,6 +5530,7 @@ Released 2018-09-13
54705530
[`reserve_after_initialization`]: https://rust-lang.github.io/rust-clippy/master/index.html#reserve_after_initialization
54715531
[`rest_pat_in_fully_bound_structs`]: https://rust-lang.github.io/rust-clippy/master/index.html#rest_pat_in_fully_bound_structs
54725532
[`result_expect_used`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_expect_used
5533+
[`result_filter_map`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_filter_map
54735534
[`result_large_err`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_large_err
54745535
[`result_map_or_into_option`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_or_into_option
54755536
[`result_map_unit_fn`]: https://rust-lang.github.io/rust-clippy/master/index.html#result_map_unit_fn
@@ -5582,6 +5643,7 @@ Released 2018-09-13
55825643
[`type_id_on_box`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_id_on_box
55835644
[`type_repetition_in_bounds`]: https://rust-lang.github.io/rust-clippy/master/index.html#type_repetition_in_bounds
55845645
[`unchecked_duration_subtraction`]: https://rust-lang.github.io/rust-clippy/master/index.html#unchecked_duration_subtraction
5646+
[`unconditional_recursion`]: https://rust-lang.github.io/rust-clippy/master/index.html#unconditional_recursion
55855647
[`undocumented_unsafe_blocks`]: https://rust-lang.github.io/rust-clippy/master/index.html#undocumented_unsafe_blocks
55865648
[`undropped_manually_drops`]: https://rust-lang.github.io/rust-clippy/master/index.html#undropped_manually_drops
55875649
[`unicode_not_nfc`]: https://rust-lang.github.io/rust-clippy/master/index.html#unicode_not_nfc

src/tools/clippy/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy"
3-
version = "0.1.76"
3+
version = "0.1.77"
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/book/src/lint_configuration.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ default configuration of Clippy. By default, any configuration will replace the
212212
* `doc-valid-idents = ["ClipPy"]` would replace the default list with `["ClipPy"]`.
213213
* `doc-valid-idents = ["ClipPy", ".."]` would append `ClipPy` to the default list.
214214

215-
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenDNS", "WebGL", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
215+
**Default Value:** `["KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "DirectX", "ECMAScript", "GPLv2", "GPLv3", "GitHub", "GitLab", "IPv4", "IPv6", "ClojureScript", "CoffeeScript", "JavaScript", "PureScript", "TypeScript", "WebAssembly", "NaN", "NaNs", "OAuth", "GraphQL", "OCaml", "OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenDNS", "WebGL", "WebGL2", "WebGPU", "TensorFlow", "TrueType", "iOS", "macOS", "FreeBSD", "TeX", "LaTeX", "BibTeX", "BibLaTeX", "MinGW", "CamelCase"]`
216216

217217
---
218218
**Affected lints:**

src/tools/clippy/clippy_config/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_config"
3-
version = "0.1.76"
3+
version = "0.1.77"
44
edition = "2021"
55

66
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const DEFAULT_DOC_VALID_IDENTS: &[&str] = &[
2727
"OAuth", "GraphQL",
2828
"OCaml",
2929
"OpenGL", "OpenMP", "OpenSSH", "OpenSSL", "OpenStreetMap", "OpenDNS",
30-
"WebGL",
30+
"WebGL", "WebGL2", "WebGPU",
3131
"TensorFlow",
3232
"TrueType",
3333
"iOS", "macOS", "FreeBSD",
@@ -640,7 +640,8 @@ impl Conf {
640640
}
641641
},
642642
Err(error) => {
643-
sess.dcx().err(format!("error finding Clippy's configuration file: {error}"));
643+
sess.dcx()
644+
.err(format!("error finding Clippy's configuration file: {error}"));
644645
},
645646
}
646647

src/tools/clippy/clippy_config/src/msrvs.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ msrv_aliases! {
4141
1,35,0 { OPTION_COPIED, RANGE_CONTAINS }
4242
1,34,0 { TRY_FROM }
4343
1,30,0 { ITERATOR_FIND_MAP, TOOL_ATTRIBUTES }
44+
1,29,0 { ITER_FLATTEN }
4445
1,28,0 { FROM_BOOL }
4546
1,27,0 { ITERATOR_TRY_FOLD }
4647
1,26,0 { RANGE_INCLUSIVE, STRING_RETAIN }
@@ -106,7 +107,8 @@ impl Msrv {
106107

107108
if let Some(msrv_attr) = msrv_attrs.next() {
108109
if let Some(duplicate) = msrv_attrs.last() {
109-
sess.dcx().struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
110+
sess.dcx()
111+
.struct_span_err(duplicate.span, "`clippy::msrv` is defined multiple times")
110112
.span_note(msrv_attr.span, "first definition found here")
111113
.emit();
112114
}
@@ -116,7 +118,8 @@ impl Msrv {
116118
return Some(version);
117119
}
118120

119-
sess.dcx().span_err(msrv_attr.span, format!("`{msrv}` is not a valid Rust version"));
121+
sess.dcx()
122+
.span_err(msrv_attr.span, format!("`{msrv}` is not a valid Rust version"));
120123
} else {
121124
sess.dcx().span_err(msrv_attr.span, "bad clippy attribute");
122125
}

src/tools/clippy/clippy_lints/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "clippy_lints"
3-
version = "0.1.76"
3+
version = "0.1.77"
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/assertions_on_constants.rs

+12-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
use clippy_utils::consts::{constant, Constant};
1+
use clippy_utils::consts::{constant_with_source, Constant, ConstantSource};
22
use clippy_utils::diagnostics::span_lint_and_help;
33
use clippy_utils::macros::{find_assert_args, root_macro_call_first_node, PanicExpn};
4-
use rustc_hir::Expr;
4+
use rustc_hir::{Expr, Item, ItemKind, Node};
55
use rustc_lint::{LateContext, LateLintPass};
66
use rustc_session::declare_lint_pass;
77
use rustc_span::sym;
@@ -42,9 +42,18 @@ impl<'tcx> LateLintPass<'tcx> for AssertionsOnConstants {
4242
let Some((condition, panic_expn)) = find_assert_args(cx, e, macro_call.expn) else {
4343
return;
4444
};
45-
let Some(Constant::Bool(val)) = constant(cx, cx.typeck_results(), condition) else {
45+
let Some((Constant::Bool(val), source)) = constant_with_source(cx, cx.typeck_results(), condition) else {
4646
return;
4747
};
48+
if let ConstantSource::Constant = source
49+
&& let Some(node) = cx.tcx.hir().find_parent(e.hir_id)
50+
&& let Node::Item(Item {
51+
kind: ItemKind::Const(..),
52+
..
53+
}) = node
54+
{
55+
return;
56+
}
4857
if val {
4958
span_lint_and_help(
5059
cx,

src/tools/clippy/clippy_lints/src/async_yields_async.rs

+1-3
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,7 @@ use clippy_utils::diagnostics::span_lint_hir_and_then;
22
use clippy_utils::source::snippet;
33
use clippy_utils::ty::implements_trait;
44
use rustc_errors::Applicability;
5-
use rustc_hir::{
6-
Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, QPath,
7-
};
5+
use rustc_hir::{Closure, ClosureKind, CoroutineDesugaring, CoroutineKind, CoroutineSource, Expr, ExprKind, QPath};
86
use rustc_lint::{LateContext, LateLintPass};
97
use rustc_session::declare_lint_pass;
108

src/tools/clippy/clippy_lints/src/declared_lints.rs

+5
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
369369
crate::methods::ITERATOR_STEP_BY_ZERO_INFO,
370370
crate::methods::ITER_CLONED_COLLECT_INFO,
371371
crate::methods::ITER_COUNT_INFO,
372+
crate::methods::ITER_FILTER_IS_OK_INFO,
373+
crate::methods::ITER_FILTER_IS_SOME_INFO,
372374
crate::methods::ITER_KV_MAP_INFO,
373375
crate::methods::ITER_NEXT_SLICE_INFO,
374376
crate::methods::ITER_NTH_INFO,
@@ -419,6 +421,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
419421
crate::methods::READ_LINE_WITHOUT_TRIM_INFO,
420422
crate::methods::REDUNDANT_AS_STR_INFO,
421423
crate::methods::REPEAT_ONCE_INFO,
424+
crate::methods::RESULT_FILTER_MAP_INFO,
422425
crate::methods::RESULT_MAP_OR_INTO_OPTION_INFO,
423426
crate::methods::SEARCH_IS_SOME_INFO,
424427
crate::methods::SEEK_FROM_CURRENT_INFO,
@@ -650,6 +653,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
650653
crate::trait_bounds::TRAIT_DUPLICATION_IN_BOUNDS_INFO,
651654
crate::trait_bounds::TYPE_REPETITION_IN_BOUNDS_INFO,
652655
crate::transmute::CROSSPOINTER_TRANSMUTE_INFO,
656+
crate::transmute::EAGER_TRANSMUTE_INFO,
653657
crate::transmute::TRANSMUTES_EXPRESSIBLE_AS_PTR_CASTS_INFO,
654658
crate::transmute::TRANSMUTE_BYTES_TO_STR_INFO,
655659
crate::transmute::TRANSMUTE_FLOAT_TO_INT_INFO,
@@ -676,6 +680,7 @@ pub(crate) static LINTS: &[&crate::LintInfo] = &[
676680
crate::types::REDUNDANT_ALLOCATION_INFO,
677681
crate::types::TYPE_COMPLEXITY_INFO,
678682
crate::types::VEC_BOX_INFO,
683+
crate::unconditional_recursion::UNCONDITIONAL_RECURSION_INFO,
679684
crate::undocumented_unsafe_blocks::UNDOCUMENTED_UNSAFE_BLOCKS_INFO,
680685
crate::undocumented_unsafe_blocks::UNNECESSARY_SAFETY_COMMENT_INFO,
681686
crate::unicode::INVISIBLE_CHARACTERS_INFO,

src/tools/clippy/clippy_lints/src/default_constructed_unit_structs.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ declare_clippy_lint! {
4242
#[clippy::version = "1.71.0"]
4343
pub DEFAULT_CONSTRUCTED_UNIT_STRUCTS,
4444
complexity,
45-
"unit structs can be contructed without calling `default`"
45+
"unit structs can be constructed without calling `default`"
4646
}
4747
declare_lint_pass!(DefaultConstructedUnitStructs => [DEFAULT_CONSTRUCTED_UNIT_STRUCTS]);
4848

src/tools/clippy/clippy_lints/src/format_push_string.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ fn is_format(cx: &LateContext<'_>, e: &Expr<'_>) -> bool {
5757
Some(higher::IfLetOrMatch::Match(_, arms, MatchSource::Normal)) => {
5858
arms.iter().any(|arm| is_format(cx, arm.body))
5959
},
60-
Some(higher::IfLetOrMatch::IfLet(_, _, then, r#else)) => {
60+
Some(higher::IfLetOrMatch::IfLet(_, _, then, r#else, _)) => {
6161
is_format(cx, then) || r#else.is_some_and(|e| is_format(cx, e))
6262
},
6363
_ => false,

src/tools/clippy/clippy_lints/src/implied_bounds_in_impls.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn try_resolve_type<'tcx>(
158158

159159
/// This function tries to, for all generic type parameters in a supertrait predicate `trait ...<U>:
160160
/// GenericTrait<U>`, check if the substituted type in the implied-by bound matches with what's
161-
/// subtituted in the implied bound.
161+
/// substituted in the implied bound.
162162
///
163163
/// Consider this example.
164164
/// ```rust,ignore

src/tools/clippy/clippy_lints/src/indexing_slicing.rs

+17-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,23 @@ impl<'tcx> LateLintPass<'tcx> for IndexingSlicing {
170170
return;
171171
}
172172
// Index is a constant uint.
173-
if constant(cx, cx.typeck_results(), index).is_some() {
173+
if let Some(constant) = constant(cx, cx.typeck_results(), index) {
174+
// only `usize` index is legal in rust array index
175+
// leave other type to rustc
176+
if let Constant::Int(off) = constant
177+
&& let ty::Uint(utype) = cx.typeck_results().expr_ty(index).kind()
178+
&& *utype == ty::UintTy::Usize
179+
&& let ty::Array(_, s) = ty.kind()
180+
&& let Some(size) = s.try_eval_target_usize(cx.tcx, cx.param_env)
181+
{
182+
// get constant offset and check whether it is in bounds
183+
let off = usize::try_from(off).unwrap();
184+
let size = usize::try_from(size).unwrap();
185+
186+
if off >= size {
187+
span_lint(cx, OUT_OF_BOUNDS_INDEXING, expr.span, "index is out of bounds");
188+
}
189+
}
174190
// Let rustc's `const_err` lint handle constant `usize` indexing on arrays.
175191
return;
176192
}

src/tools/clippy/clippy_lints/src/ineffective_open_options.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ declare_clippy_lint! {
1616
///
1717
/// ### Why is this bad?
1818
/// `.append(true)` already enables `write(true)`, making this one
19-
/// superflous.
19+
/// superfluous.
2020
///
2121
/// ### Example
2222
/// ```no_run

src/tools/clippy/clippy_lints/src/iter_without_into_iter.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ declare_clippy_lint! {
4949
/// }
5050
/// }
5151
/// ```
52-
#[clippy::version = "1.74.0"]
52+
#[clippy::version = "1.75.0"]
5353
pub ITER_WITHOUT_INTO_ITER,
5454
pedantic,
5555
"implementing `iter(_mut)` without an associated `IntoIterator for (&|&mut) Type` impl"
@@ -101,7 +101,7 @@ declare_clippy_lint! {
101101
/// }
102102
/// }
103103
/// ```
104-
#[clippy::version = "1.74.0"]
104+
#[clippy::version = "1.75.0"]
105105
pub INTO_ITER_WITHOUT_ITER,
106106
pedantic,
107107
"implementing `IntoIterator for (&|&mut) Type` without an inherent `iter(_mut)` method"

0 commit comments

Comments
 (0)