]> git.lizzy.rs Git - rust.git/blob - tests/ui/match_same_arms2.stderr
Improve lint message for match-same-arms lint
[rust.git] / tests / ui / match_same_arms2.stderr
1 error: this `match` has identical arm bodies
2   --> $DIR/match_same_arms2.rs:20:14
3    |
4 LL |           _ => {
5    |  ______________^
6 LL | |             //~ ERROR match arms have same body
7 LL | |             foo();
8 LL | |             let mut a = 42 + [23].len() as i32;
9 ...  |
10 LL | |             a
11 LL | |         },
12    | |_________^
13    |
14    = note: `-D clippy::match-same-arms` implied by `-D warnings`
15 note: same as this
16   --> $DIR/match_same_arms2.rs:11:15
17    |
18 LL |           42 => {
19    |  _______________^
20 LL | |             foo();
21 LL | |             let mut a = 42 + [23].len() as i32;
22 LL | |             if true {
23 ...  |
24 LL | |             a
25 LL | |         },
26    | |_________^
27 note: `42` has the same arm body as the `_` wildcard, consider removing it
28   --> $DIR/match_same_arms2.rs:11:15
29    |
30 LL |           42 => {
31    |  _______________^
32 LL | |             foo();
33 LL | |             let mut a = 42 + [23].len() as i32;
34 LL | |             if true {
35 ...  |
36 LL | |             a
37 LL | |         },
38    | |_________^
39
40 error: this `match` has identical arm bodies
41   --> $DIR/match_same_arms2.rs:34:15
42    |
43 LL |         51 => foo(), //~ ERROR match arms have same body
44    |               ^^^^^
45    |
46 note: same as this
47   --> $DIR/match_same_arms2.rs:33:15
48    |
49 LL |         42 => foo(),
50    |               ^^^^^
51 help: consider refactoring into `42 | 51`
52   --> $DIR/match_same_arms2.rs:33:9
53    |
54 LL |         42 => foo(),
55    |         ^^
56    = help: ...or consider changing the match arm bodies
57
58 error: this `match` has identical arm bodies
59   --> $DIR/match_same_arms2.rs:40:17
60    |
61 LL |         None => 24, //~ ERROR match arms have same body
62    |                 ^^
63    |
64 note: same as this
65   --> $DIR/match_same_arms2.rs:39:20
66    |
67 LL |         Some(_) => 24,
68    |                    ^^
69 help: consider refactoring into `Some(_) | None`
70   --> $DIR/match_same_arms2.rs:39:9
71    |
72 LL |         Some(_) => 24,
73    |         ^^^^^^^
74    = help: ...or consider changing the match arm bodies
75
76 error: this `match` has identical arm bodies
77   --> $DIR/match_same_arms2.rs:62:28
78    |
79 LL |         (None, Some(a)) => bar(a), //~ ERROR match arms have same body
80    |                            ^^^^^^
81    |
82 note: same as this
83   --> $DIR/match_same_arms2.rs:61:28
84    |
85 LL |         (Some(a), None) => bar(a),
86    |                            ^^^^^^
87 help: consider refactoring into `(Some(a), None) | (None, Some(a))`
88   --> $DIR/match_same_arms2.rs:61:9
89    |
90 LL |         (Some(a), None) => bar(a),
91    |         ^^^^^^^^^^^^^^^
92    = help: ...or consider changing the match arm bodies
93
94 error: this `match` has identical arm bodies
95   --> $DIR/match_same_arms2.rs:68:26
96    |
97 LL |         (.., Some(a)) => bar(a), //~ ERROR match arms have same body
98    |                          ^^^^^^
99    |
100 note: same as this
101   --> $DIR/match_same_arms2.rs:67:26
102    |
103 LL |         (Some(a), ..) => bar(a),
104    |                          ^^^^^^
105 help: consider refactoring into `(Some(a), ..) | (.., Some(a))`
106   --> $DIR/match_same_arms2.rs:67:9
107    |
108 LL |         (Some(a), ..) => bar(a),
109    |         ^^^^^^^^^^^^^
110    = help: ...or consider changing the match arm bodies
111
112 error: this `match` has identical arm bodies
113   --> $DIR/match_same_arms2.rs:102:29
114    |
115 LL |         (Ok(_), Some(x)) => println!("ok {}", x),
116    |                             ^^^^^^^^^^^^^^^^^^^^
117    |
118 note: same as this
119   --> $DIR/match_same_arms2.rs:101:29
120    |
121 LL |         (Ok(x), Some(_)) => println!("ok {}", x),
122    |                             ^^^^^^^^^^^^^^^^^^^^
123 help: consider refactoring into `(Ok(x), Some(_)) | (Ok(_), Some(x))`
124   --> $DIR/match_same_arms2.rs:101:9
125    |
126 LL |         (Ok(x), Some(_)) => println!("ok {}", x),
127    |         ^^^^^^^^^^^^^^^^
128    = help: ...or consider changing the match arm bodies
129    = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
130
131 error: this `match` has identical arm bodies
132   --> $DIR/match_same_arms2.rs:117:18
133    |
134 LL |         Ok(_) => println!("ok"),
135    |                  ^^^^^^^^^^^^^^
136    |
137 note: same as this
138   --> $DIR/match_same_arms2.rs:116:18
139    |
140 LL |         Ok(3) => println!("ok"),
141    |                  ^^^^^^^^^^^^^^
142 help: consider refactoring into `Ok(3) | Ok(_)`
143   --> $DIR/match_same_arms2.rs:116:9
144    |
145 LL |         Ok(3) => println!("ok"),
146    |         ^^^^^
147    = help: ...or consider changing the match arm bodies
148    = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
149
150 error: this `match` has identical arm bodies
151   --> $DIR/match_same_arms2.rs:144:14
152    |
153 LL |           1 => {
154    |  ______________^
155 LL | |             empty!(0);
156 LL | |         },
157    | |_________^
158    |
159 note: same as this
160   --> $DIR/match_same_arms2.rs:141:14
161    |
162 LL |           0 => {
163    |  ______________^
164 LL | |             empty!(0);
165 LL | |         },
166    | |_________^
167 help: consider refactoring into `0 | 1`
168   --> $DIR/match_same_arms2.rs:141:9
169    |
170 LL |         0 => {
171    |         ^
172    = help: ...or consider changing the match arm bodies
173
174 error: match expression looks like `matches!` macro
175   --> $DIR/match_same_arms2.rs:162:16
176    |
177 LL |       let _ans = match x {
178    |  ________________^
179 LL | |         E::A => false,
180 LL | |         E::B => false,
181 LL | |         _ => true,
182 LL | |     };
183    | |_____^ help: try this: `!matches!(x, E::A | E::B)`
184    |
185    = note: `-D clippy::match-like-matches-macro` implied by `-D warnings`
186
187 error: aborting due to 9 previous errors
188