1 // NOTE: if you add a deprecated lint in this file, please add a corresponding test in
2 // tests/ui/deprecated.rs
4 /// This struct fakes the `Lint` declaration that is usually created by `declare_lint!`. This
5 /// enables the simple extraction of the metadata without changing the current deprecation
7 pub struct ClippyDeprecatedLint;
9 macro_rules! declare_deprecated_lint {
10 { $(#[$attr:meta])* pub $name: ident, $_reason: expr} => {
13 pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {};
17 declare_deprecated_lint! {
19 /// Nothing. This lint has been deprecated.
21 /// ### Deprecation reason
22 /// This used to check for `assert!(a == b)` and recommend
23 /// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
24 #[clippy::version = "pre 1.29.0"]
26 "`assert!()` will be more flexible with RFC 2011"
29 declare_deprecated_lint! {
31 /// Nothing. This lint has been deprecated.
33 /// ### Deprecation reason
34 /// This used to check for `Vec::extend`, which was slower than
35 /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
36 #[clippy::version = "pre 1.29.0"]
37 pub EXTEND_FROM_SLICE,
38 "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
41 declare_deprecated_lint! {
43 /// Nothing. This lint has been deprecated.
45 /// ### Deprecation reason
46 /// `Range::step_by(0)` used to be linted since it's
47 /// an infinite iterator, which is better expressed by `iter::repeat`,
48 /// but the method has been removed for `Iterator::step_by` which panics
50 #[clippy::version = "pre 1.29.0"]
51 pub RANGE_STEP_BY_ZERO,
52 "`iterator.step_by(0)` panics nowadays"
55 declare_deprecated_lint! {
57 /// Nothing. This lint has been deprecated.
59 /// ### Deprecation reason
60 /// This used to check for `Vec::as_slice`, which was unstable with good
61 /// stable alternatives. `Vec::as_slice` has now been stabilized.
62 #[clippy::version = "pre 1.29.0"]
63 pub UNSTABLE_AS_SLICE,
64 "`Vec::as_slice` has been stabilized in 1.7"
67 declare_deprecated_lint! {
69 /// Nothing. This lint has been deprecated.
71 /// ### Deprecation reason
72 /// This used to check for `Vec::as_mut_slice`, which was unstable with good
73 /// stable alternatives. `Vec::as_mut_slice` has now been stabilized.
74 #[clippy::version = "pre 1.29.0"]
75 pub UNSTABLE_AS_MUT_SLICE,
76 "`Vec::as_mut_slice` has been stabilized in 1.7"
79 declare_deprecated_lint! {
81 /// Nothing. This lint has been deprecated.
83 /// ### Deprecation reason
84 /// This lint should never have applied to non-pointer types, as transmuting
85 /// between non-pointer types of differing alignment is well-defined behavior (it's semantically
86 /// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
87 /// cast_ptr_alignment and transmute_ptr_to_ptr.
88 #[clippy::version = "pre 1.29.0"]
89 pub MISALIGNED_TRANSMUTE,
90 "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
93 declare_deprecated_lint! {
95 /// Nothing. This lint has been deprecated.
97 /// ### Deprecation reason
98 /// This lint is too subjective, not having a good reason for being in clippy.
99 /// Additionally, compound assignment operators may be overloaded separately from their non-assigning
100 /// counterparts, so this lint may suggest a change in behavior or the code may not compile.
101 #[clippy::version = "1.30.0"]
103 "using compound assignment operators (e.g., `+=`) is harmless"
106 declare_deprecated_lint! {
108 /// Nothing. This lint has been deprecated.
110 /// ### Deprecation reason
111 /// The original rule will only lint for `if let`. After
112 /// making it support to lint `match`, naming as `if let` is not suitable for it.
113 /// So, this lint is deprecated.
114 #[clippy::version = "pre 1.29.0"]
115 pub IF_LET_REDUNDANT_PATTERN_MATCHING,
116 "this lint has been changed to redundant_pattern_matching"
119 declare_deprecated_lint! {
121 /// Nothing. This lint has been deprecated.
123 /// ### Deprecation reason
124 /// This lint used to suggest replacing `let mut vec =
125 /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
126 /// replacement has very different performance characteristics so the lint is
128 #[clippy::version = "pre 1.29.0"]
129 pub UNSAFE_VECTOR_INITIALIZATION,
130 "the replacement suggested by this lint had substantially different behavior"
133 declare_deprecated_lint! {
135 /// Nothing. This lint has been deprecated.
137 /// ### Deprecation reason
138 /// This lint has been superseded by #[must_use] in rustc.
139 #[clippy::version = "1.39.0"]
141 "`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
144 declare_deprecated_lint! {
146 /// Nothing. This lint has been deprecated.
148 /// ### Deprecation reason
149 /// Associated-constants are now preferred.
150 #[clippy::version = "1.44.0"]
152 "associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants"
155 declare_deprecated_lint! {
157 /// Nothing. This lint has been deprecated.
159 /// ### Deprecation reason
160 /// The regex! macro does not exist anymore.
161 #[clippy::version = "1.47.0"]
163 "the regex! macro has been removed from the regex crate in 2018"
166 declare_deprecated_lint! {
168 /// Nothing. This lint has been deprecated.
170 /// ### Deprecation reason
171 /// This lint has been replaced by `manual_find_map`, a
172 /// more specific lint.
173 #[clippy::version = "1.51.0"]
175 "this lint has been replaced by `manual_find_map`, a more specific lint"
178 declare_deprecated_lint! {
180 /// Nothing. This lint has been deprecated.
182 /// ### Deprecation reason
183 /// This lint has been replaced by `manual_filter_map`, a
184 /// more specific lint.
185 #[clippy::version = "1.53.0"]
187 "this lint has been replaced by `manual_filter_map`, a more specific lint"
190 declare_deprecated_lint! {
192 /// Nothing. This lint has been deprecated.
194 /// ### Deprecation reason
195 /// The `avoid_breaking_exported_api` config option was added, which
196 /// enables the `enum_variant_names` lint for public items.
197 #[clippy::version = "1.54.0"]
198 pub PUB_ENUM_VARIANT_NAMES,
199 "set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items"
202 declare_deprecated_lint! {
204 /// Nothing. This lint has been deprecated.
206 /// ### Deprecation reason
207 /// The `avoid_breaking_exported_api` config option was added, which
208 /// enables the `wrong_self_conversion` lint for public items.
209 #[clippy::version = "1.54.0"]
210 pub WRONG_PUB_SELF_CONVENTION,
211 "set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"