Skip to content

Commit 18e1d0f

Browse files
committed
Manually add clippy::version attribute to deprecated lints
1 parent 56d7245 commit 18e1d0f

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clippy_dev/src/update_lints.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ static DEC_CLIPPY_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
1818
r#"(?x)
1919
declare_clippy_lint!\s*[\{(]
2020
(?:\s+///.*)*
21-
(?:\s*\#\[clippy::version\s*=\s*"[^"]*"\])
21+
(?:\s*\#\[clippy::version\s*=\s*"[^"]*"\])?
2222
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
2323
(?P<cat>[a-z_]+)\s*,\s*
2424
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
@@ -32,6 +32,7 @@ static DEC_DEPRECATED_LINT_RE: SyncLazy<Regex> = SyncLazy::new(|| {
3232
r#"(?x)
3333
declare_deprecated_lint!\s*[{(]\s*
3434
(?:\s+///.*)*
35+
(?:\s*\#\[clippy::version\s*=\s*"[^"]*"\])?
3536
\s+pub\s+(?P<name>[A-Z_][A-Z_0-9]*)\s*,\s*
3637
"(?P<desc>(?:[^"\\]+|\\(?s).(?-s))*)"\s*[})]
3738
"#,

clippy_lints/src/deprecated_lints.rs

+16
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ declare_deprecated_lint! {
1818
/// ### Deprecation reason
1919
/// This used to check for `assert!(a == b)` and recommend
2020
/// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
21+
#[clippy::version = "pre 1.29.0"]
2122
pub SHOULD_ASSERT_EQ,
2223
"`assert!()` will be more flexible with RFC 2011"
2324
}
@@ -29,6 +30,7 @@ declare_deprecated_lint! {
2930
/// ### Deprecation reason
3031
/// This used to check for `Vec::extend`, which was slower than
3132
/// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
33+
#[clippy::version = "pre 1.29.0"]
3234
pub EXTEND_FROM_SLICE,
3335
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
3436
}
@@ -42,6 +44,7 @@ declare_deprecated_lint! {
4244
/// an infinite iterator, which is better expressed by `iter::repeat`,
4345
/// but the method has been removed for `Iterator::step_by` which panics
4446
/// if given a zero
47+
#[clippy::version = "pre 1.29.0"]
4548
pub RANGE_STEP_BY_ZERO,
4649
"`iterator.step_by(0)` panics nowadays"
4750
}
@@ -53,6 +56,7 @@ declare_deprecated_lint! {
5356
/// ### Deprecation reason
5457
/// This used to check for `Vec::as_slice`, which was unstable with good
5558
/// stable alternatives. `Vec::as_slice` has now been stabilized.
59+
#[clippy::version = "pre 1.29.0"]
5660
pub UNSTABLE_AS_SLICE,
5761
"`Vec::as_slice` has been stabilized in 1.7"
5862
}
@@ -64,6 +68,7 @@ declare_deprecated_lint! {
6468
/// ### Deprecation reason
6569
/// This used to check for `Vec::as_mut_slice`, which was unstable with good
6670
/// stable alternatives. `Vec::as_mut_slice` has now been stabilized.
71+
#[clippy::version = "pre 1.29.0"]
6772
pub UNSTABLE_AS_MUT_SLICE,
6873
"`Vec::as_mut_slice` has been stabilized in 1.7"
6974
}
@@ -77,6 +82,7 @@ declare_deprecated_lint! {
7782
/// between non-pointer types of differing alignment is well-defined behavior (it's semantically
7883
/// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
7984
/// cast_ptr_alignment and transmute_ptr_to_ptr.
85+
#[clippy::version = "pre 1.29.0"]
8086
pub MISALIGNED_TRANSMUTE,
8187
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
8288
}
@@ -89,6 +95,7 @@ declare_deprecated_lint! {
8995
/// This lint is too subjective, not having a good reason for being in clippy.
9096
/// Additionally, compound assignment operators may be overloaded separately from their non-assigning
9197
/// counterparts, so this lint may suggest a change in behavior or the code may not compile.
98+
#[clippy::version = "1.30.0"]
9299
pub ASSIGN_OPS,
93100
"using compound assignment operators (e.g., `+=`) is harmless"
94101
}
@@ -101,6 +108,7 @@ declare_deprecated_lint! {
101108
/// The original rule will only lint for `if let`. After
102109
/// making it support to lint `match`, naming as `if let` is not suitable for it.
103110
/// So, this lint is deprecated.
111+
#[clippy::version = "pre 1.29.0"]
104112
pub IF_LET_REDUNDANT_PATTERN_MATCHING,
105113
"this lint has been changed to redundant_pattern_matching"
106114
}
@@ -114,6 +122,7 @@ declare_deprecated_lint! {
114122
/// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
115123
/// replacement has very different performance characteristics so the lint is
116124
/// deprecated.
125+
#[clippy::version = "pre 1.29.0"]
117126
pub UNSAFE_VECTOR_INITIALIZATION,
118127
"the replacement suggested by this lint had substantially different behavior"
119128
}
@@ -124,6 +133,7 @@ declare_deprecated_lint! {
124133
///
125134
/// ### Deprecation reason
126135
/// This lint has been superseded by #[must_use] in rustc.
136+
#[clippy::version = "1.39.0"]
127137
pub UNUSED_COLLECT,
128138
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
129139
}
@@ -134,6 +144,7 @@ declare_deprecated_lint! {
134144
///
135145
/// ### Deprecation reason
136146
/// Associated-constants are now preferred.
147+
#[clippy::version = "1.44.0"]
137148
pub REPLACE_CONSTS,
138149
"associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants"
139150
}
@@ -144,6 +155,7 @@ declare_deprecated_lint! {
144155
///
145156
/// ### Deprecation reason
146157
/// The regex! macro does not exist anymore.
158+
#[clippy::version = "1.47.0"]
147159
pub REGEX_MACRO,
148160
"the regex! macro has been removed from the regex crate in 2018"
149161
}
@@ -155,6 +167,7 @@ declare_deprecated_lint! {
155167
/// ### Deprecation reason
156168
/// This lint has been replaced by `manual_find_map`, a
157169
/// more specific lint.
170+
#[clippy::version = "1.51.0"]
158171
pub FIND_MAP,
159172
"this lint has been replaced by `manual_find_map`, a more specific lint"
160173
}
@@ -166,6 +179,7 @@ declare_deprecated_lint! {
166179
/// ### Deprecation reason
167180
/// This lint has been replaced by `manual_filter_map`, a
168181
/// more specific lint.
182+
#[clippy::version = "1.53.0"]
169183
pub FILTER_MAP,
170184
"this lint has been replaced by `manual_filter_map`, a more specific lint"
171185
}
@@ -178,6 +192,7 @@ declare_deprecated_lint! {
178192
/// The `avoid_breaking_exported_api` config option was added, which
179193
/// enables the `enum_variant_names` lint for public items.
180194
/// ```
195+
#[clippy::version = "1.54.0"]
181196
pub PUB_ENUM_VARIANT_NAMES,
182197
"set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items"
183198
}
@@ -189,6 +204,7 @@ declare_deprecated_lint! {
189204
/// ### Deprecation reason
190205
/// The `avoid_breaking_exported_api` config option was added, which
191206
/// enables the `wrong_self_conversion` lint for public items.
207+
#[clippy::version = "1.54.0"]
192208
pub WRONG_PUB_SELF_CONVENTION,
193209
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
194210
}

0 commit comments

Comments
 (0)