]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/deprecated_lints.rs
Auto merge of #3946 - rchaser53:issue-3920, r=flip1995
[rust.git] / 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 /// **What it does:** Nothing. This lint has been deprecated.
8 ///
9 /// **Deprecation reason:** This used to check for `assert!(a == b)` and recommend
10 /// replacement with `assert_eq!(a, b)`, but this is no longer needed after RFC 2011.
11 declare_deprecated_lint! {
12     pub SHOULD_ASSERT_EQ,
13     "`assert!()` will be more flexible with RFC 2011"
14 }
15
16 /// **What it does:** Nothing. This lint has been deprecated.
17 ///
18 /// **Deprecation reason:** This used to check for `Vec::extend`, which was slower than
19 /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
20 declare_deprecated_lint! {
21     pub EXTEND_FROM_SLICE,
22     "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
23 }
24
25 /// **What it does:** Nothing. This lint has been deprecated.
26 ///
27 /// **Deprecation reason:** `Range::step_by(0)` used to be linted since it's
28 /// an infinite iterator, which is better expressed by `iter::repeat`,
29 /// but the method has been removed for `Iterator::step_by` which panics
30 /// if given a zero
31 declare_deprecated_lint! {
32     pub RANGE_STEP_BY_ZERO,
33     "`iterator.step_by(0)` panics nowadays"
34 }
35
36 /// **What it does:** Nothing. This lint has been deprecated.
37 ///
38 /// **Deprecation reason:** This used to check for `Vec::as_slice`, which was unstable with good
39 /// stable alternatives. `Vec::as_slice` has now been stabilized.
40 declare_deprecated_lint! {
41     pub UNSTABLE_AS_SLICE,
42     "`Vec::as_slice` has been stabilized in 1.7"
43 }
44
45
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 declare_deprecated_lint! {
51     pub UNSTABLE_AS_MUT_SLICE,
52     "`Vec::as_mut_slice` has been stabilized in 1.7"
53 }
54
55 /// **What it does:** Nothing. This lint has been deprecated.
56 ///
57 /// **Deprecation reason:** This used to check for `.to_string()` method calls on values
58 /// of type `&str`. This is not unidiomatic and with specialization coming, `to_string` could be
59 /// specialized to be as efficient as `to_owned`.
60 declare_deprecated_lint! {
61     pub STR_TO_STRING,
62     "using `str::to_string` is common even today and specialization will likely happen soon"
63 }
64
65 /// **What it does:** Nothing. This lint has been deprecated.
66 ///
67 /// **Deprecation reason:** This used to check for `.to_string()` method calls on values
68 /// of type `String`. This is not unidiomatic and with specialization coming, `to_string` could be
69 /// specialized to be as efficient as `clone`.
70 declare_deprecated_lint! {
71     pub STRING_TO_STRING,
72     "using `string::to_string` is common even today and specialization will likely happen soon"
73 }
74
75 /// **What it does:** Nothing. This lint has been deprecated.
76 ///
77 /// **Deprecation reason:** This lint should never have applied to non-pointer types, as transmuting
78 /// between non-pointer types of differing alignment is well-defined behavior (it's semantically
79 /// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
80 /// cast_ptr_alignment and transmute_ptr_to_ptr.
81 declare_deprecated_lint! {
82     pub MISALIGNED_TRANSMUTE,
83     "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
84 }
85
86 /// **What it does:** Nothing. This lint has been deprecated.
87 ///
88 /// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy.
89 /// Additionally, compound assignment operators may be overloaded separately from their non-assigning
90 /// counterparts, so this lint may suggest a change in behavior or the code may not compile.
91 declare_deprecated_lint! {
92     pub ASSIGN_OPS,
93     "using compound assignment operators (e.g., `+=`) is harmless"
94 }
95
96 /// **What it does:** Nothing. This lint has been deprecated.
97 ///
98 /// **Deprecation reason:** The original rule will only lint for `if let`. After
99 /// making it support to lint `match`, naming as `if let` is not suitable for it.
100 /// So, this lint is deprecated.
101 declare_deprecated_lint! {
102     pub IF_LET_REDUNDANT_PATTERN_MATCHING,
103     "this lint has been changed to redundant_pattern_matching"
104 }
105
106 /// **What it does:** Nothing. This lint has been deprecated.
107 ///
108 /// **Deprecation reason:** This lint used to suggest replacing `let mut vec =
109 /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
110 /// replacement has very different performance characteristics so the lint is
111 /// deprecated.
112 declare_deprecated_lint! {
113     pub UNSAFE_VECTOR_INITIALIZATION,
114     "the replacement suggested by this lint had substantially different behavior"
115 }