Skip to content

Commit 63cb410

Browse files
committed
Manually add clippy::version attribute to deprecated lints
1 parent 23ed792 commit 63cb410

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

clippy_dev/src/update_lints.rs

Lines changed: 2 additions & 1 deletion
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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ declare_deprecated_lint! {
2121
/// ### Deprecation reason
2222
/// This used to check for `assert!(a == b)` and recommend
2323
/// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
24+
#[clippy::version = "pre 1.29.0"]
2425
pub SHOULD_ASSERT_EQ,
2526
"`assert!()` will be more flexible with RFC 2011"
2627
}
@@ -32,6 +33,7 @@ declare_deprecated_lint! {
3233
/// ### Deprecation reason
3334
/// This used to check for `Vec::extend`, which was slower than
3435
/// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
36+
#[clippy::version = "pre 1.29.0"]
3537
pub EXTEND_FROM_SLICE,
3638
"`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
3739
}
@@ -45,6 +47,7 @@ declare_deprecated_lint! {
4547
/// an infinite iterator, which is better expressed by `iter::repeat`,
4648
/// but the method has been removed for `Iterator::step_by` which panics
4749
/// if given a zero
50+
#[clippy::version = "pre 1.29.0"]
4851
pub RANGE_STEP_BY_ZERO,
4952
"`iterator.step_by(0)` panics nowadays"
5053
}
@@ -56,6 +59,7 @@ declare_deprecated_lint! {
5659
/// ### Deprecation reason
5760
/// This used to check for `Vec::as_slice`, which was unstable with good
5861
/// stable alternatives. `Vec::as_slice` has now been stabilized.
62+
#[clippy::version = "pre 1.29.0"]
5963
pub UNSTABLE_AS_SLICE,
6064
"`Vec::as_slice` has been stabilized in 1.7"
6165
}
@@ -67,6 +71,7 @@ declare_deprecated_lint! {
6771
/// ### Deprecation reason
6872
/// This used to check for `Vec::as_mut_slice`, which was unstable with good
6973
/// stable alternatives. `Vec::as_mut_slice` has now been stabilized.
74+
#[clippy::version = "pre 1.29.0"]
7075
pub UNSTABLE_AS_MUT_SLICE,
7176
"`Vec::as_mut_slice` has been stabilized in 1.7"
7277
}
@@ -80,6 +85,7 @@ declare_deprecated_lint! {
8085
/// between non-pointer types of differing alignment is well-defined behavior (it's semantically
8186
/// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
8287
/// cast_ptr_alignment and transmute_ptr_to_ptr.
88+
#[clippy::version = "pre 1.29.0"]
8389
pub MISALIGNED_TRANSMUTE,
8490
"this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
8591
}
@@ -92,6 +98,7 @@ declare_deprecated_lint! {
9298
/// This lint is too subjective, not having a good reason for being in clippy.
9399
/// Additionally, compound assignment operators may be overloaded separately from their non-assigning
94100
/// counterparts, so this lint may suggest a change in behavior or the code may not compile.
101+
#[clippy::version = "1.30.0"]
95102
pub ASSIGN_OPS,
96103
"using compound assignment operators (e.g., `+=`) is harmless"
97104
}
@@ -104,6 +111,7 @@ declare_deprecated_lint! {
104111
/// The original rule will only lint for `if let`. After
105112
/// making it support to lint `match`, naming as `if let` is not suitable for it.
106113
/// So, this lint is deprecated.
114+
#[clippy::version = "pre 1.29.0"]
107115
pub IF_LET_REDUNDANT_PATTERN_MATCHING,
108116
"this lint has been changed to redundant_pattern_matching"
109117
}
@@ -117,6 +125,7 @@ declare_deprecated_lint! {
117125
/// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
118126
/// replacement has very different performance characteristics so the lint is
119127
/// deprecated.
128+
#[clippy::version = "pre 1.29.0"]
120129
pub UNSAFE_VECTOR_INITIALIZATION,
121130
"the replacement suggested by this lint had substantially different behavior"
122131
}
@@ -127,6 +136,7 @@ declare_deprecated_lint! {
127136
///
128137
/// ### Deprecation reason
129138
/// This lint has been superseded by #[must_use] in rustc.
139+
#[clippy::version = "1.39.0"]
130140
pub UNUSED_COLLECT,
131141
"`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
132142
}
@@ -137,6 +147,7 @@ declare_deprecated_lint! {
137147
///
138148
/// ### Deprecation reason
139149
/// Associated-constants are now preferred.
150+
#[clippy::version = "1.44.0"]
140151
pub REPLACE_CONSTS,
141152
"associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants"
142153
}
@@ -147,6 +158,7 @@ declare_deprecated_lint! {
147158
///
148159
/// ### Deprecation reason
149160
/// The regex! macro does not exist anymore.
161+
#[clippy::version = "1.47.0"]
150162
pub REGEX_MACRO,
151163
"the regex! macro has been removed from the regex crate in 2018"
152164
}
@@ -158,6 +170,7 @@ declare_deprecated_lint! {
158170
/// ### Deprecation reason
159171
/// This lint has been replaced by `manual_find_map`, a
160172
/// more specific lint.
173+
#[clippy::version = "1.51.0"]
161174
pub FIND_MAP,
162175
"this lint has been replaced by `manual_find_map`, a more specific lint"
163176
}
@@ -169,6 +182,7 @@ declare_deprecated_lint! {
169182
/// ### Deprecation reason
170183
/// This lint has been replaced by `manual_filter_map`, a
171184
/// more specific lint.
185+
#[clippy::version = "1.53.0"]
172186
pub FILTER_MAP,
173187
"this lint has been replaced by `manual_filter_map`, a more specific lint"
174188
}
@@ -181,6 +195,7 @@ declare_deprecated_lint! {
181195
/// The `avoid_breaking_exported_api` config option was added, which
182196
/// enables the `enum_variant_names` lint for public items.
183197
/// ```
198+
#[clippy::version = "1.54.0"]
184199
pub PUB_ENUM_VARIANT_NAMES,
185200
"set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items"
186201
}
@@ -192,6 +207,7 @@ declare_deprecated_lint! {
192207
/// ### Deprecation reason
193208
/// The `avoid_breaking_exported_api` config option was added, which
194209
/// enables the `wrong_self_conversion` lint for public items.
210+
#[clippy::version = "1.54.0"]
195211
pub WRONG_PUB_SELF_CONVENTION,
196212
"set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
197213
}

0 commit comments

Comments
 (0)