]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/deprecated_lints.rs
Add `dev deprecate`
[rust.git] / clippy_lints / src / deprecated_lints.rs
1 // NOTE: Entries should be created with `cargo dev deprecate`
2
3 /// This struct fakes the `Lint` declaration that is usually created by `declare_lint!`. This
4 /// enables the simple extraction of the metadata without changing the current deprecation
5 /// declaration.
6 pub struct ClippyDeprecatedLint {
7     #[cfg(feature = "internal")]
8     #[allow(dead_code)]
9     desc: &'static str,
10 }
11
12 macro_rules! declare_deprecated_lint {
13     { $(#[$attr:meta])* pub $name: ident, $reason: literal} => {
14         $(#[$attr])*
15         #[allow(dead_code)]
16         pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {
17             #[cfg(feature = "internal")]
18             desc: $reason
19         };
20     }
21 }
22
23 declare_deprecated_lint! {
24     /// ### What it does
25     /// Nothing. This lint has been deprecated.
26     ///
27     /// ### Deprecation reason
28     /// This used to check for `assert!(a == b)` and recommend
29     /// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
30     #[clippy::version = "pre 1.29.0"]
31     pub SHOULD_ASSERT_EQ,
32     "`assert!()` will be more flexible with RFC 2011"
33 }
34
35 declare_deprecated_lint! {
36     /// ### What it does
37     /// Nothing. This lint has been deprecated.
38     ///
39     /// ### Deprecation reason
40     /// This used to check for `Vec::extend`, which was slower than
41     /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
42     #[clippy::version = "pre 1.29.0"]
43     pub EXTEND_FROM_SLICE,
44     "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
45 }
46
47 declare_deprecated_lint! {
48     /// ### What it does
49     /// Nothing. This lint has been deprecated.
50     ///
51     /// ### Deprecation reason
52     /// `Range::step_by(0)` used to be linted since it's
53     /// an infinite iterator, which is better expressed by `iter::repeat`,
54     /// but the method has been removed for `Iterator::step_by` which panics
55     /// if given a zero
56     #[clippy::version = "pre 1.29.0"]
57     pub RANGE_STEP_BY_ZERO,
58     "`iterator.step_by(0)` panics nowadays"
59 }
60
61 declare_deprecated_lint! {
62     /// ### What it does
63     /// Nothing. This lint has been deprecated.
64     ///
65     /// ### Deprecation reason
66     /// This used to check for `Vec::as_slice`, which was unstable with good
67     /// stable alternatives. `Vec::as_slice` has now been stabilized.
68     #[clippy::version = "pre 1.29.0"]
69     pub UNSTABLE_AS_SLICE,
70     "`Vec::as_slice` has been stabilized in 1.7"
71 }
72
73 declare_deprecated_lint! {
74     /// ### What it does
75     /// Nothing. This lint has been deprecated.
76     ///
77     /// ### Deprecation reason
78     /// This used to check for `Vec::as_mut_slice`, which was unstable with good
79     /// stable alternatives. `Vec::as_mut_slice` has now been stabilized.
80     #[clippy::version = "pre 1.29.0"]
81     pub UNSTABLE_AS_MUT_SLICE,
82     "`Vec::as_mut_slice` has been stabilized in 1.7"
83 }
84
85 declare_deprecated_lint! {
86     /// ### What it does
87     /// Nothing. This lint has been deprecated.
88     ///
89     /// ### Deprecation reason
90     /// This lint should never have applied to non-pointer types, as transmuting
91     /// between non-pointer types of differing alignment is well-defined behavior (it's semantically
92     /// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
93     /// cast_ptr_alignment and transmute_ptr_to_ptr.
94     #[clippy::version = "pre 1.29.0"]
95     pub MISALIGNED_TRANSMUTE,
96     "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
97 }
98
99 declare_deprecated_lint! {
100     /// ### What it does
101     /// Nothing. This lint has been deprecated.
102     ///
103     /// ### Deprecation reason
104     /// This lint is too subjective, not having a good reason for being in clippy.
105     /// Additionally, compound assignment operators may be overloaded separately from their non-assigning
106     /// counterparts, so this lint may suggest a change in behavior or the code may not compile.
107     #[clippy::version = "1.30.0"]
108     pub ASSIGN_OPS,
109     "using compound assignment operators (e.g., `+=`) is harmless"
110 }
111
112 declare_deprecated_lint! {
113     /// ### What it does
114     /// Nothing. This lint has been deprecated.
115     ///
116     /// ### Deprecation reason
117     /// The original rule will only lint for `if let`. After
118     /// making it support to lint `match`, naming as `if let` is not suitable for it.
119     /// So, this lint is deprecated.
120     #[clippy::version = "pre 1.29.0"]
121     pub IF_LET_REDUNDANT_PATTERN_MATCHING,
122     "this lint has been changed to redundant_pattern_matching"
123 }
124
125 declare_deprecated_lint! {
126     /// ### What it does
127     /// Nothing. This lint has been deprecated.
128     ///
129     /// ### Deprecation reason
130     /// This lint used to suggest replacing `let mut vec =
131     /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
132     /// replacement has very different performance characteristics so the lint is
133     /// deprecated.
134     #[clippy::version = "pre 1.29.0"]
135     pub UNSAFE_VECTOR_INITIALIZATION,
136     "the replacement suggested by this lint had substantially different behavior"
137 }
138
139 declare_deprecated_lint! {
140     /// ### What it does
141     /// Nothing. This lint has been deprecated.
142     ///
143     /// ### Deprecation reason
144     /// This lint has been superseded by #[must_use] in rustc.
145     #[clippy::version = "1.39.0"]
146     pub UNUSED_COLLECT,
147     "`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
148 }
149
150 declare_deprecated_lint! {
151     /// ### What it does
152     /// Nothing. This lint has been deprecated.
153     ///
154     /// ### Deprecation reason
155     /// Associated-constants are now preferred.
156     #[clippy::version = "1.44.0"]
157     pub REPLACE_CONSTS,
158     "associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants"
159 }
160
161 declare_deprecated_lint! {
162     /// ### What it does
163     /// Nothing. This lint has been deprecated.
164     ///
165     /// ### Deprecation reason
166     /// The regex! macro does not exist anymore.
167     #[clippy::version = "1.47.0"]
168     pub REGEX_MACRO,
169     "the regex! macro has been removed from the regex crate in 2018"
170 }
171
172 declare_deprecated_lint! {
173     /// ### What it does
174     /// Nothing. This lint has been deprecated.
175     ///
176     /// ### Deprecation reason
177     /// This lint has been replaced by `manual_find_map`, a
178     /// more specific lint.
179     #[clippy::version = "1.51.0"]
180     pub FIND_MAP,
181     "this lint has been replaced by `manual_find_map`, a more specific lint"
182 }
183
184 declare_deprecated_lint! {
185     /// ### What it does
186     /// Nothing. This lint has been deprecated.
187     ///
188     /// ### Deprecation reason
189     /// This lint has been replaced by `manual_filter_map`, a
190     /// more specific lint.
191     #[clippy::version = "1.53.0"]
192     pub FILTER_MAP,
193     "this lint has been replaced by `manual_filter_map`, a more specific lint"
194 }
195
196 declare_deprecated_lint! {
197     /// ### What it does
198     /// Nothing. This lint has been deprecated.
199     ///
200     /// ### Deprecation reason
201     /// The `avoid_breaking_exported_api` config option was added, which
202     /// enables the `enum_variant_names` lint for public items.
203     #[clippy::version = "1.54.0"]
204     pub PUB_ENUM_VARIANT_NAMES,
205     "set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items"
206 }
207
208 declare_deprecated_lint! {
209     /// ### What it does
210     /// Nothing. This lint has been deprecated.
211     ///
212     /// ### Deprecation reason
213     /// The `avoid_breaking_exported_api` config option was added, which
214     /// enables the `wrong_self_conversion` lint for public items.
215     #[clippy::version = "1.54.0"]
216     pub WRONG_PUB_SELF_CONVENTION,
217     "set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
218 }