]> git.lizzy.rs Git - rust.git/blob - src/tools/clippy/clippy_lints/src/deprecated_lints.rs
Replace `&mut DiagnosticBuilder`, in signatures, with `&mut Diagnostic`.
[rust.git] / src / tools / clippy / clippy_lints / src / deprecated_lints.rs
1 // NOTE: if you add a deprecated lint in this file, please add a corresponding test in
2 // tests/ui/deprecated.rs
3
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
6 /// declaration.
7 pub struct ClippyDeprecatedLint;
8
9 macro_rules! declare_deprecated_lint {
10     { $(#[$attr:meta])* pub $name: ident, $_reason: expr} => {
11         $(#[$attr])*
12         #[allow(dead_code)]
13         pub static $name: ClippyDeprecatedLint = ClippyDeprecatedLint {};
14     }
15 }
16
17 declare_deprecated_lint! {
18     /// ### What it does
19     /// Nothing. This lint has been deprecated.
20     ///
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"]
25     pub SHOULD_ASSERT_EQ,
26     "`assert!()` will be more flexible with RFC 2011"
27 }
28
29 declare_deprecated_lint! {
30     /// ### What it does
31     /// Nothing. This lint has been deprecated.
32     ///
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"
39 }
40
41 declare_deprecated_lint! {
42     /// ### What it does
43     /// Nothing. This lint has been deprecated.
44     ///
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
49     /// if given a zero
50     #[clippy::version = "pre 1.29.0"]
51     pub RANGE_STEP_BY_ZERO,
52     "`iterator.step_by(0)` panics nowadays"
53 }
54
55 declare_deprecated_lint! {
56     /// ### What it does
57     /// Nothing. This lint has been deprecated.
58     ///
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"
65 }
66
67 declare_deprecated_lint! {
68     /// ### What it does
69     /// Nothing. This lint has been deprecated.
70     ///
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"
77 }
78
79 declare_deprecated_lint! {
80     /// ### What it does
81     /// Nothing. This lint has been deprecated.
82     ///
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"
91 }
92
93 declare_deprecated_lint! {
94     /// ### What it does
95     /// Nothing. This lint has been deprecated.
96     ///
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"]
102     pub ASSIGN_OPS,
103     "using compound assignment operators (e.g., `+=`) is harmless"
104 }
105
106 declare_deprecated_lint! {
107     /// ### What it does
108     /// Nothing. This lint has been deprecated.
109     ///
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"
117 }
118
119 declare_deprecated_lint! {
120     /// ### What it does
121     /// Nothing. This lint has been deprecated.
122     ///
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
127     /// deprecated.
128     #[clippy::version = "pre 1.29.0"]
129     pub UNSAFE_VECTOR_INITIALIZATION,
130     "the replacement suggested by this lint had substantially different behavior"
131 }
132
133 declare_deprecated_lint! {
134     /// ### What it does
135     /// Nothing. This lint has been deprecated.
136     ///
137     /// ### Deprecation reason
138     /// This lint has been superseded by #[must_use] in rustc.
139     #[clippy::version = "1.39.0"]
140     pub UNUSED_COLLECT,
141     "`collect` has been marked as #[must_use] in rustc and that covers all cases of this lint"
142 }
143
144 declare_deprecated_lint! {
145     /// ### What it does
146     /// Nothing. This lint has been deprecated.
147     ///
148     /// ### Deprecation reason
149     /// Associated-constants are now preferred.
150     #[clippy::version = "1.44.0"]
151     pub REPLACE_CONSTS,
152     "associated-constants `MIN`/`MAX` of integers are preferred to `{min,max}_value()` and module constants"
153 }
154
155 declare_deprecated_lint! {
156     /// ### What it does
157     /// Nothing. This lint has been deprecated.
158     ///
159     /// ### Deprecation reason
160     /// The regex! macro does not exist anymore.
161     #[clippy::version = "1.47.0"]
162     pub REGEX_MACRO,
163     "the regex! macro has been removed from the regex crate in 2018"
164 }
165
166 declare_deprecated_lint! {
167     /// ### What it does
168     /// Nothing. This lint has been deprecated.
169     ///
170     /// ### Deprecation reason
171     /// This lint has been replaced by `manual_find_map`, a
172     /// more specific lint.
173     #[clippy::version = "1.51.0"]
174     pub FIND_MAP,
175     "this lint has been replaced by `manual_find_map`, a more specific lint"
176 }
177
178 declare_deprecated_lint! {
179     /// ### What it does
180     /// Nothing. This lint has been deprecated.
181     ///
182     /// ### Deprecation reason
183     /// This lint has been replaced by `manual_filter_map`, a
184     /// more specific lint.
185     #[clippy::version = "1.53.0"]
186     pub FILTER_MAP,
187     "this lint has been replaced by `manual_filter_map`, a more specific lint"
188 }
189
190 declare_deprecated_lint! {
191     /// ### What it does
192     /// Nothing. This lint has been deprecated.
193     ///
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     /// ```
198     #[clippy::version = "1.54.0"]
199     pub PUB_ENUM_VARIANT_NAMES,
200     "set the `avoid-breaking-exported-api` config option to `false` to enable the `enum_variant_names` lint for public items"
201 }
202
203 declare_deprecated_lint! {
204     /// ### What it does
205     /// Nothing. This lint has been deprecated.
206     ///
207     /// ### Deprecation reason
208     /// The `avoid_breaking_exported_api` config option was added, which
209     /// enables the `wrong_self_conversion` lint for public items.
210     #[clippy::version = "1.54.0"]
211     pub WRONG_PUB_SELF_CONVENTION,
212     "set the `avoid-breaking-exported-api` config option to `false` to enable the `wrong_self_convention` lint for public items"
213 }