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