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