mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-12-23 03:23:33 +00:00
385 lines
8.9 KiB
Text
385 lines
8.9 KiB
Text
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:41:10
|
|
|
|
|
41 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
42 | | Foo { bar: 42 };
|
|
43 | | 0..10;
|
|
44 | | ..;
|
|
... |
|
|
48 | | foo();
|
|
49 | | }
|
|
| |_____^
|
|
|
|
|
= note: `-D clippy::if-same-then-else` implied by `-D warnings`
|
|
note: same as this
|
|
--> $DIR/copies.rs:32:13
|
|
|
|
|
32 | if true {
|
|
| _____________^
|
|
33 | | Foo { bar: 42 };
|
|
34 | | 0..10;
|
|
35 | | ..;
|
|
... |
|
|
39 | | foo();
|
|
40 | | }
|
|
| |_____^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:90:14
|
|
|
|
|
90 | _ => { //~ ERROR match arms have same body
|
|
| ______________^
|
|
91 | | foo();
|
|
92 | | let mut a = 42 + [23].len() as i32;
|
|
93 | | if true {
|
|
... |
|
|
97 | | a
|
|
98 | | }
|
|
| |_________^
|
|
|
|
|
= note: `-D clippy::match-same-arms` implied by `-D warnings`
|
|
note: same as this
|
|
--> $DIR/copies.rs:81:15
|
|
|
|
|
81 | 42 => {
|
|
| _______________^
|
|
82 | | foo();
|
|
83 | | let mut a = 42 + [23].len() as i32;
|
|
84 | | if true {
|
|
... |
|
|
88 | | a
|
|
89 | | }
|
|
| |_________^
|
|
note: `42` has the same arm body as the `_` wildcard, consider removing it`
|
|
--> $DIR/copies.rs:81:15
|
|
|
|
|
81 | 42 => {
|
|
| _______________^
|
|
82 | | foo();
|
|
83 | | let mut a = 42 + [23].len() as i32;
|
|
84 | | if true {
|
|
... |
|
|
88 | | a
|
|
89 | | }
|
|
| |_________^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:104:14
|
|
|
|
|
104 | _ => 0, //~ ERROR match arms have same body
|
|
| ^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:102:19
|
|
|
|
|
102 | Abc::A => 0,
|
|
| ^
|
|
note: `Abc::A` has the same arm body as the `_` wildcard, consider removing it`
|
|
--> $DIR/copies.rs:102:19
|
|
|
|
|
102 | Abc::A => 0,
|
|
| ^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:114:10
|
|
|
|
|
114 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
115 | | 42
|
|
116 | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:111:21
|
|
|
|
|
111 | let _ = if true {
|
|
| _____________________^
|
|
112 | | 42
|
|
113 | | }
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:128:10
|
|
|
|
|
128 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
129 | | for _ in &[42] {
|
|
130 | | let foo: &Option<_> = &Some::<u8>(42);
|
|
131 | | if true {
|
|
... |
|
|
136 | | }
|
|
137 | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:118:13
|
|
|
|
|
118 | if true {
|
|
| _____________^
|
|
119 | | for _ in &[42] {
|
|
120 | | let foo: &Option<_> = &Some::<u8>(42);
|
|
121 | | if true {
|
|
... |
|
|
126 | | }
|
|
127 | | }
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:150:10
|
|
|
|
|
150 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
151 | | let bar = if true {
|
|
152 | | 42
|
|
153 | | }
|
|
... |
|
|
159 | | bar + 1;
|
|
160 | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:139:13
|
|
|
|
|
139 | if true {
|
|
| _____________^
|
|
140 | | let bar = if true {
|
|
141 | | 42
|
|
142 | | }
|
|
... |
|
|
148 | | bar + 1;
|
|
149 | | }
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:185:10
|
|
|
|
|
185 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
186 | | if let Some(a) = Some(42) {}
|
|
187 | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:182:13
|
|
|
|
|
182 | if true {
|
|
| _____________^
|
|
183 | | if let Some(a) = Some(42) {}
|
|
184 | | }
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:192:10
|
|
|
|
|
192 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
193 | | if let (1, .., 3) = (1, 2, 3) {}
|
|
194 | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:189:13
|
|
|
|
|
189 | if true {
|
|
| _____________^
|
|
190 | | if let (1, .., 3) = (1, 2, 3) {}
|
|
191 | | }
|
|
| |_____^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:247:15
|
|
|
|
|
247 | 51 => foo(), //~ ERROR match arms have same body
|
|
| ^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:246:15
|
|
|
|
|
246 | 42 => foo(),
|
|
| ^^^^^
|
|
note: consider refactoring into `42 | 51`
|
|
--> $DIR/copies.rs:246:15
|
|
|
|
|
246 | 42 => foo(),
|
|
| ^^^^^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:253:17
|
|
|
|
|
253 | None => 24, //~ ERROR match arms have same body
|
|
| ^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:252:20
|
|
|
|
|
252 | Some(_) => 24,
|
|
| ^^
|
|
note: consider refactoring into `Some(_) | None`
|
|
--> $DIR/copies.rs:252:20
|
|
|
|
|
252 | Some(_) => 24,
|
|
| ^^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:275:28
|
|
|
|
|
275 | (None, Some(a)) => bar(a), //~ ERROR match arms have same body
|
|
| ^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:274:28
|
|
|
|
|
274 | (Some(a), None) => bar(a),
|
|
| ^^^^^^
|
|
note: consider refactoring into `(Some(a), None) | (None, Some(a))`
|
|
--> $DIR/copies.rs:274:28
|
|
|
|
|
274 | (Some(a), None) => bar(a),
|
|
| ^^^^^^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:281:26
|
|
|
|
|
281 | (.., Some(a)) => bar(a), //~ ERROR match arms have same body
|
|
| ^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:280:26
|
|
|
|
|
280 | (Some(a), ..) => bar(a),
|
|
| ^^^^^^
|
|
note: consider refactoring into `(Some(a), ..) | (.., Some(a))`
|
|
--> $DIR/copies.rs:280:26
|
|
|
|
|
280 | (Some(a), ..) => bar(a),
|
|
| ^^^^^^
|
|
|
|
error: this `match` has identical arm bodies
|
|
--> $DIR/copies.rs:287:20
|
|
|
|
|
287 | (.., 3) => 42, //~ ERROR match arms have same body
|
|
| ^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:286:23
|
|
|
|
|
286 | (1, .., 3) => 42,
|
|
| ^^
|
|
note: consider refactoring into `(1, .., 3) | (.., 3)`
|
|
--> $DIR/copies.rs:286:23
|
|
|
|
|
286 | (1, .., 3) => 42,
|
|
| ^^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:293:12
|
|
|
|
|
293 | } else { //~ ERROR same body as `if` block
|
|
| ____________^
|
|
294 | | 0.0
|
|
295 | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:291:21
|
|
|
|
|
291 | let _ = if true {
|
|
| _____________________^
|
|
292 | | 0.0
|
|
293 | | } else { //~ ERROR same body as `if` block
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:299:12
|
|
|
|
|
299 | } else { //~ ERROR same body as `if` block
|
|
| ____________^
|
|
300 | | -0.0
|
|
301 | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:297:21
|
|
|
|
|
297 | let _ = if true {
|
|
| _____________________^
|
|
298 | | -0.0
|
|
299 | | } else { //~ ERROR same body as `if` block
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:319:12
|
|
|
|
|
319 | } else { //~ ERROR same body as `if` block
|
|
| ____________^
|
|
320 | | std::f32::NAN
|
|
321 | | };
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:317:21
|
|
|
|
|
317 | let _ = if true {
|
|
| _____________________^
|
|
318 | | std::f32::NAN
|
|
319 | | } else { //~ ERROR same body as `if` block
|
|
| |_____^
|
|
|
|
error: this `if` has identical blocks
|
|
--> $DIR/copies.rs:337:10
|
|
|
|
|
337 | else { //~ ERROR same body as `if` block
|
|
| __________^
|
|
338 | | try!(Ok("foo"));
|
|
339 | | }
|
|
| |_____^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:334:13
|
|
|
|
|
334 | if true {
|
|
| _____________^
|
|
335 | | try!(Ok("foo"));
|
|
336 | | }
|
|
| |_____^
|
|
|
|
error: this `if` has the same condition as a previous if
|
|
--> $DIR/copies.rs:363:13
|
|
|
|
|
363 | else if b { //~ ERROR ifs same condition
|
|
| ^
|
|
|
|
|
= note: `-D clippy::ifs-same-cond` implied by `-D warnings`
|
|
note: same as this
|
|
--> $DIR/copies.rs:361:8
|
|
|
|
|
361 | if b {
|
|
| ^
|
|
|
|
error: this `if` has the same condition as a previous if
|
|
--> $DIR/copies.rs:368:13
|
|
|
|
|
368 | else if a == 1 { //~ ERROR ifs same condition
|
|
| ^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:366:8
|
|
|
|
|
366 | if a == 1 {
|
|
| ^^^^^^
|
|
|
|
error: this `if` has the same condition as a previous if
|
|
--> $DIR/copies.rs:375:13
|
|
|
|
|
375 | else if 2*a == 1 { //~ ERROR ifs same condition
|
|
| ^^^^^^^^
|
|
|
|
|
note: same as this
|
|
--> $DIR/copies.rs:371:8
|
|
|
|
|
371 | if 2*a == 1 {
|
|
| ^^^^^^^^
|
|
|
|
error: aborting due to 20 previous errors
|
|
|