]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_match.stderr
Fix needless_match false positive for if-let
[rust.git] / tests / ui / needless_match.stderr
1 error: this match expression is unnecessary
2   --> $DIR/needless_match.rs:16:18
3    |
4 LL |       let _: i32 = match i {
5    |  __________________^
6 LL | |         0 => 0,
7 LL | |         1 => 1,
8 LL | |         2 => 2,
9 LL | |         _ => i,
10 LL | |     };
11    | |_____^ help: replace it with: `i`
12    |
13    = note: `-D clippy::needless-match` implied by `-D warnings`
14
15 error: this match expression is unnecessary
16   --> $DIR/needless_match.rs:23:19
17    |
18 LL |       let _: &str = match s {
19    |  ___________________^
20 LL | |         "a" => "a",
21 LL | |         "b" => "b",
22 LL | |         s => s,
23 LL | |     };
24    | |_____^ help: replace it with: `s`
25
26 error: this match expression is unnecessary
27   --> $DIR/needless_match.rs:32:21
28    |
29 LL |       let _: Simple = match se {
30    |  _____________________^
31 LL | |         Simple::A => Simple::A,
32 LL | |         Simple::B => Simple::B,
33 LL | |         Simple::C => Simple::C,
34 LL | |         Simple::D => Simple::D,
35 LL | |     };
36    | |_____^ help: replace it with: `se`
37
38 error: this match expression is unnecessary
39   --> $DIR/needless_match.rs:54:26
40    |
41 LL |       let _: Option<i32> = match x {
42    |  __________________________^
43 LL | |         Some(a) => Some(a),
44 LL | |         None => None,
45 LL | |     };
46    | |_____^ help: replace it with: `x`
47
48 error: this match expression is unnecessary
49   --> $DIR/needless_match.rs:70:31
50    |
51 LL |       let _: Result<i32, i32> = match Ok(1) {
52    |  _______________________________^
53 LL | |         Ok(a) => Ok(a),
54 LL | |         Err(err) => Err(err),
55 LL | |     };
56    | |_____^ help: replace it with: `Ok(1)`
57
58 error: this match expression is unnecessary
59   --> $DIR/needless_match.rs:74:31
60    |
61 LL |       let _: Result<i32, i32> = match func_ret_err(0_i32) {
62    |  _______________________________^
63 LL | |         Err(err) => Err(err),
64 LL | |         Ok(a) => Ok(a),
65 LL | |     };
66    | |_____^ help: replace it with: `func_ret_err(0_i32)`
67
68 error: this if-let expression is unnecessary
69   --> $DIR/needless_match.rs:87:13
70    |
71 LL |     let _ = if let Some(a) = Some(1) { Some(a) } else { None };
72    |             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)`
73
74 error: this if-let expression is unnecessary
75   --> $DIR/needless_match.rs:122:31
76    |
77 LL |     let _: Result<i32, i32> = if let Err(e) = x { Err(e) } else { x };
78    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
79
80 error: this if-let expression is unnecessary
81   --> $DIR/needless_match.rs:123:31
82    |
83 LL |     let _: Result<i32, i32> = if let Ok(val) = x { Ok(val) } else { x };
84    |                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
85
86 error: this if-let expression is unnecessary
87   --> $DIR/needless_match.rs:129:21
88    |
89 LL |       let _: Simple = if let Simple::A = x {
90    |  _____________________^
91 LL | |         Simple::A
92 LL | |     } else if let Simple::B = x {
93 LL | |         Simple::B
94 ...  |
95 LL | |         x
96 LL | |     };
97    | |_____^ help: replace it with: `x`
98
99 error: this match expression is unnecessary
100   --> $DIR/needless_match.rs:168:26
101    |
102 LL |           let _: Complex = match ce {
103    |  __________________________^
104 LL | |             Complex::A(a) => Complex::A(a),
105 LL | |             Complex::B(a, b) => Complex::B(a, b),
106 LL | |             Complex::C(a, b, c) => Complex::C(a, b, c),
107 LL | |             Complex::D(E::VariantA(ea, eb), b) => Complex::D(E::VariantA(ea, eb), b),
108 LL | |             Complex::D(E::VariantB(ea, eb), b) => Complex::D(E::VariantB(ea, eb), b),
109 LL | |         };
110    | |_________^ help: replace it with: `ce`
111
112 error: aborting due to 11 previous errors
113