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