]> git.lizzy.rs Git - rust.git/blob - clippy_lints/src/deprecated_lints.rs
Merge pull request #3490 from phansch/extract_single_match_else_ui_test
[rust.git] / clippy_lints / src / deprecated_lints.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
9
10
11 macro_rules! declare_deprecated_lint {
12     (pub $name: ident, $_reason: expr) => {
13         declare_lint!(pub $name, Allow, "deprecated lint")
14     }
15 }
16
17 /// **What it does:** Nothing. This lint has been deprecated.
18 ///
19 /// **Deprecation reason:** 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 declare_deprecated_lint! {
22     pub SHOULD_ASSERT_EQ,
23     "`assert!()` will be more flexible with RFC 2011"
24 }
25
26 /// **What it does:** Nothing. This lint has been deprecated.
27 ///
28 /// **Deprecation reason:** This used to check for `Vec::extend`, which was slower than
29 /// `Vec::extend_from_slice`. Thanks to specialization, this is no longer true.
30 declare_deprecated_lint! {
31     pub EXTEND_FROM_SLICE,
32     "`.extend_from_slice(_)` is a faster way to extend a Vec by a slice"
33 }
34
35 /// **What it does:** Nothing. This lint has been deprecated.
36 ///
37 /// **Deprecation reason:** `Range::step_by(0)` used to be linted since it's
38 /// an infinite iterator, which is better expressed by `iter::repeat`,
39 /// but the method has been removed for `Iterator::step_by` which panics
40 /// if given a zero
41 declare_deprecated_lint! {
42     pub RANGE_STEP_BY_ZERO,
43     "`iterator.step_by(0)` panics nowadays"
44 }
45
46 /// **What it does:** Nothing. This lint has been deprecated.
47 ///
48 /// **Deprecation reason:** This used to check for `Vec::as_slice`, which was unstable with good
49 /// stable alternatives. `Vec::as_slice` has now been stabilized.
50 declare_deprecated_lint! {
51     pub UNSTABLE_AS_SLICE,
52     "`Vec::as_slice` has been stabilized in 1.7"
53 }
54
55
56 /// **What it does:** Nothing. This lint has been deprecated.
57 ///
58 /// **Deprecation reason:** This used to check for `Vec::as_mut_slice`, which was unstable with good
59 /// stable alternatives. `Vec::as_mut_slice` has now been stabilized.
60 declare_deprecated_lint! {
61     pub UNSTABLE_AS_MUT_SLICE,
62     "`Vec::as_mut_slice` has been stabilized in 1.7"
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 `&str`. This is not unidiomatic and with specialization coming, `to_string` could be
69 /// specialized to be as efficient as `to_owned`.
70 declare_deprecated_lint! {
71     pub STR_TO_STRING,
72     "using `str::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 used to check for `.to_string()` method calls on values
78 /// of type `String`. This is not unidiomatic and with specialization coming, `to_string` could be
79 /// specialized to be as efficient as `clone`.
80 declare_deprecated_lint! {
81     pub STRING_TO_STRING,
82     "using `string::to_string` is common even today and specialization will likely happen soon"
83 }
84
85 /// **What it does:** Nothing. This lint has been deprecated.
86 ///
87 /// **Deprecation reason:** This lint should never have applied to non-pointer types, as transmuting
88 /// between non-pointer types of differing alignment is well-defined behavior (it's semantically
89 /// equivalent to a memcpy). This lint has thus been refactored into two separate lints:
90 /// cast_ptr_alignment and transmute_ptr_to_ptr.
91 declare_deprecated_lint! {
92     pub MISALIGNED_TRANSMUTE,
93     "this lint has been split into cast_ptr_alignment and transmute_ptr_to_ptr"
94 }
95
96 /// **What it does:** Nothing. This lint has been deprecated.
97 ///
98 /// **Deprecation reason:** This lint is too subjective, not having a good reason for being in clippy.
99 /// Additionally, compound assignment operators may be overloaded separately from their non-assigning
100 /// counterparts, so this lint may suggest a change in behavior or the code may not compile.
101 declare_deprecated_lint! {
102     pub ASSIGN_OPS,
103     "using compound assignment operators (e.g. `+=`) is harmless"
104 }
105
106 /// **What it does:** Nothing. This lint has been deprecated.
107 ///
108 /// **Deprecation reason:** The original rule will only lint for `if let`. After
109 /// making it support to lint `match`, naming as `if let` is not suitable for it.
110 /// So, this lint is deprecated.
111 declare_deprecated_lint! {
112     pub IF_LET_REDUNDANT_PATTERN_MATCHING,
113     "this lint has been changed to redundant_pattern_matching"
114 }
115
116 /// **What it does:** Nothing. This lint has been deprecated.
117 ///
118 /// **Deprecation reason:** This lint used to suggest replacing `let mut vec =
119 /// Vec::with_capacity(n); vec.set_len(n);` with `let vec = vec![0; n];`. The
120 /// replacement has very different performance characteristics so the lint is
121 /// deprecated.
122 declare_deprecated_lint! {
123     pub UNSAFE_VECTOR_INITIALIZATION,
124     "the replacement suggested by this lint had substantially different behavior"
125 }