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