]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_match.stderr
Auto merge of #8596 - Jaic1:unnecessary_cast, r=flip1995
[rust.git] / tests / ui / needless_match.stderr
1 error: this match expression is unnecessary
2   --> $DIR/needless_match.rs:17: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:18
17    |
18 LL |       let _: i32 = match i {
19    |  __________________^
20 LL | |         0 => 0,
21 LL | |         1 => 1,
22 LL | |         ref i => *i,
23 LL | |     };
24    | |_____^ help: replace it with: `i`
25
26 error: this match expression is unnecessary
27   --> $DIR/needless_match.rs:28:22
28    |
29 LL |       let mut _i_mut = match i {
30    |  ______________________^
31 LL | |         0 => 0,
32 LL | |         1 => 1,
33 LL | |         ref mut i => *i,
34 LL | |     };
35    | |_____^ help: replace it with: `i`
36
37 error: this match expression is unnecessary
38   --> $DIR/needless_match.rs:35:19
39    |
40 LL |       let _: &str = match s {
41    |  ___________________^
42 LL | |         "a" => "a",
43 LL | |         "b" => "b",
44 LL | |         s => s,
45 LL | |     };
46    | |_____^ help: replace it with: `s`
47
48 error: this match expression is unnecessary
49   --> $DIR/needless_match.rs:43:21
50    |
51 LL |       let _: Choice = match se {
52    |  _____________________^
53 LL | |         Choice::A => Choice::A,
54 LL | |         Choice::B => Choice::B,
55 LL | |         Choice::C => Choice::C,
56 LL | |         Choice::D => Choice::D,
57 LL | |     };
58    | |_____^ help: replace it with: `se`
59
60 error: this match expression is unnecessary
61   --> $DIR/needless_match.rs:65:26
62    |
63 LL |       let _: Option<i32> = match x {
64    |  __________________________^
65 LL | |         Some(a) => Some(a),
66 LL | |         None => None,
67 LL | |     };
68    | |_____^ help: replace it with: `x`
69
70 error: this match expression is unnecessary
71   --> $DIR/needless_match.rs:81:31
72    |
73 LL |       let _: Result<i32, i32> = match Ok(1) {
74    |  _______________________________^
75 LL | |         Ok(a) => Ok(a),
76 LL | |         Err(err) => Err(err),
77 LL | |     };
78    | |_____^ help: replace it with: `Ok(1)`
79
80 error: this match expression is unnecessary
81   --> $DIR/needless_match.rs:85:31
82    |
83 LL |       let _: Result<i32, i32> = match func_ret_err(0_i32) {
84    |  _______________________________^
85 LL | |         Err(err) => Err(err),
86 LL | |         Ok(a) => Ok(a),
87 LL | |     };
88    | |_____^ help: replace it with: `func_ret_err(0_i32)`
89
90 error: this if-let expression is unnecessary
91   --> $DIR/needless_match.rs:92:5
92    |
93 LL |     if let Some(a) = Some(1) { Some(a) } else { None }
94    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `Some(1)`
95
96 error: this if-let expression is unnecessary
97   --> $DIR/needless_match.rs:96:30
98    |
99 LL |     let _: Result<(), i32> = if let Err(e) = x { Err(e) } else { x };
100    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
101
102 error: this if-let expression is unnecessary
103   --> $DIR/needless_match.rs:97:30
104    |
105 LL |     let _: Result<(), i32> = if let Ok(val) = x { Ok(val) } else { x };
106    |                              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: replace it with: `x`
107
108 error: this if-let expression is unnecessary
109   --> $DIR/needless_match.rs:103:21
110    |
111 LL |       let _: Choice = if let Choice::A = x {
112    |  _____________________^
113 LL | |         Choice::A
114 LL | |     } else if let Choice::B = x {
115 LL | |         Choice::B
116 ...  |
117 LL | |         x
118 LL | |     };
119    | |_____^ help: replace it with: `x`
120
121 error: aborting due to 12 previous errors
122