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