Skip to content

Commit 625ca77

Browse files
committed
tests: fix more cases where rustfmt would have hurt the tests
1 parent f1d5194 commit 625ca77

6 files changed

+262
-435
lines changed

tests/ui/formatting.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,6 @@
77
// option. This file may not be copied, modified, or distributed
88
// except according to those terms.
99

10-
11-
12-
13-
1410
#![warn(clippy::all)]
1511
#![allow(unused_variables)]
1612
#![allow(unused_assignments)]

tests/ui/formatting.stderr

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,87 +1,87 @@
11
error: this looks like an `else if` but the `else` is missing
2-
--> $DIR/formatting.rs:25:6
2+
--> $DIR/formatting.rs:21:6
33
|
4-
25 | } if foo() {
4+
21 | } if foo() {
55
| ^
66
|
77
= note: `-D clippy::suspicious-else-formatting` implied by `-D warnings`
88
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
99

1010
error: this looks like an `else if` but the `else` is missing
11-
--> $DIR/formatting.rs:32:10
11+
--> $DIR/formatting.rs:28:10
1212
|
13-
32 | } if foo() {
13+
28 | } if foo() {
1414
| ^
1515
|
1616
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
1717

1818
error: this looks like an `else if` but the `else` is missing
19-
--> $DIR/formatting.rs:40:10
19+
--> $DIR/formatting.rs:36:10
2020
|
21-
40 | } if foo() {
21+
36 | } if foo() {
2222
| ^
2323
|
2424
= note: to remove this lint, add the missing `else` or add a new line before the second `if`
2525

2626
error: this is an `else if` but the formatting might hide it
27-
--> $DIR/formatting.rs:49:6
27+
--> $DIR/formatting.rs:45:6
2828
|
29-
49 | } else
29+
45 | } else
3030
| ______^
31-
50 | | if foo() { // the span of the above error should continue here
31+
46 | | if foo() { // the span of the above error should continue here
3232
| |____^
3333
|
3434
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
3535

3636
error: this is an `else if` but the formatting might hide it
37-
--> $DIR/formatting.rs:54:6
37+
--> $DIR/formatting.rs:50:6
3838
|
39-
54 | }
39+
50 | }
4040
| ______^
41-
55 | | else
42-
56 | | if foo() { // the span of the above error should continue here
41+
51 | | else
42+
52 | | if foo() { // the span of the above error should continue here
4343
| |____^
4444
|
4545
= note: to remove this lint, remove the `else` or remove the new line between `else` and `if`
4646

4747
error: this looks like you are trying to use `.. -= ..`, but you really are doing `.. = (- ..)`
48-
--> $DIR/formatting.rs:81:6
48+
--> $DIR/formatting.rs:77:6
4949
|
50-
81 | a =- 35;
50+
77 | a =- 35;
5151
| ^^^^
5252
|
5353
= note: `-D clippy::suspicious-assignment-formatting` implied by `-D warnings`
5454
= note: to remove this lint, use either `-=` or `= -`
5555

5656
error: this looks like you are trying to use `.. *= ..`, but you really are doing `.. = (* ..)`
57-
--> $DIR/formatting.rs:82:6
57+
--> $DIR/formatting.rs:78:6
5858
|
59-
82 | a =* &191;
59+
78 | a =* &191;
6060
| ^^^^
6161
|
6262
= note: to remove this lint, use either `*=` or `= *`
6363

6464
error: this looks like you are trying to use `.. != ..`, but you really are doing `.. = (! ..)`
65-
--> $DIR/formatting.rs:85:6
65+
--> $DIR/formatting.rs:81:6
6666
|
67-
85 | b =! false;
67+
81 | b =! false;
6868
| ^^^^
6969
|
7070
= note: to remove this lint, use either `!=` or `= !`
7171

7272
error: possibly missing a comma here
73-
--> $DIR/formatting.rs:94:19
73+
--> $DIR/formatting.rs:90:19
7474
|
75-
94 | -1, -2, -3 // <= no comma here
75+
90 | -1, -2, -3 // <= no comma here
7676
| ^
7777
|
7878
= note: `-D clippy::possible-missing-comma` implied by `-D warnings`
7979
= note: to remove this lint, add a comma or write the expr in a single line
8080

8181
error: possibly missing a comma here
82-
--> $DIR/formatting.rs:98:19
82+
--> $DIR/formatting.rs:94:19
8383
|
84-
98 | -1, -2, -3 // <= no comma here
84+
94 | -1, -2, -3 // <= no comma here
8585
| ^
8686
|
8787
= note: to remove this lint, add a comma or write the expr in a single line

tests/ui/option_map_unit_fn.rs

Lines changed: 25 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ impl HasOption {
3131
value + 1
3232
}
3333
}
34-
34+
#[rustfmt::skip]
3535
fn option_map_unit_fn() {
3636
let x = HasOption { field: Some(10) };
3737

3838
x.field.map(plus_one);
39-
let _: Option<()> = x.field.map(do_nothing);
39+
let _ : Option<()> = x.field.map(do_nothing);
4040

4141
x.field.map(do_nothing);
4242

@@ -45,82 +45,57 @@ fn option_map_unit_fn() {
4545
x.field.map(diverge);
4646

4747
let captured = 10;
48-
if let Some(value) = x.field {
49-
do_nothing(value + captured)
50-
};
51-
let _: Option<()> = x.field.map(|value| do_nothing(value + captured));
48+
if let Some(value) = x.field { do_nothing(value + captured) };
49+
let _ : Option<()> = x.field.map(|value| do_nothing(value + captured));
5250

5351
x.field.map(|value| x.do_option_nothing(value + captured));
5452

55-
x.field.map(|value| {
56-
x.do_option_plus_one(value + captured);
57-
});
53+
x.field.map(|value| { x.do_option_plus_one(value + captured); });
5854

59-
x.field.map(|value| do_nothing(value + captured));
6055

6156
x.field.map(|value| do_nothing(value + captured));
6257

63-
x.field.map(|value| {
64-
do_nothing(value + captured);
65-
});
58+
x.field.map(|value| { do_nothing(value + captured) });
6659

67-
x.field.map(|value| {
68-
do_nothing(value + captured);
69-
});
60+
x.field.map(|value| { do_nothing(value + captured); });
61+
62+
x.field.map(|value| { { do_nothing(value + captured); } });
7063

71-
x.field.map(|value| diverge(value + captured));
7264

7365
x.field.map(|value| diverge(value + captured));
7466

75-
x.field.map(|value| {
76-
diverge(value + captured);
77-
});
67+
x.field.map(|value| { diverge(value + captured) });
68+
69+
x.field.map(|value| { diverge(value + captured); });
70+
71+
x.field.map(|value| { { diverge(value + captured); } });
7872

79-
x.field.map(|value| {
80-
diverge(value + captured);
81-
});
8273

8374
x.field.map(|value| plus_one(value + captured));
84-
x.field.map(|value| plus_one(value + captured));
85-
x.field.map(|value| {
86-
let y = plus_one(value + captured);
87-
});
75+
x.field.map(|value| { plus_one(value + captured) });
76+
x.field.map(|value| { let y = plus_one(value + captured); });
8877

89-
x.field.map(|value| {
90-
plus_one(value + captured);
91-
});
78+
x.field.map(|value| { plus_one(value + captured); });
9279

93-
x.field.map(|value| {
94-
plus_one(value + captured);
95-
});
80+
x.field.map(|value| { { plus_one(value + captured); } });
9681

97-
x.field.map(|ref value| do_nothing(value + captured));
9882

99-
x.field.map(|value| {
100-
do_nothing(value);
101-
do_nothing(value)
102-
});
83+
x.field.map(|ref value| { do_nothing(value + captured) });
10384

104-
x.field.map(|value| {
105-
if value > 0 {
106-
do_nothing(value);
107-
do_nothing(value)
108-
}
109-
});
85+
86+
x.field.map(|value| { do_nothing(value); do_nothing(value) });
87+
88+
x.field.map(|value| if value > 0 { do_nothing(value); do_nothing(value) });
11089

11190
// Suggestion for the let block should be `{ ... }` as it's too difficult to build a
11291
// proper suggestion for these cases
11392
x.field.map(|value| {
11493
do_nothing(value);
11594
do_nothing(value)
11695
});
117-
x.field.map(|value| {
118-
do_nothing(value);
119-
do_nothing(value);
120-
});
96+
x.field.map(|value| { do_nothing(value); do_nothing(value); });
12197

122-
// The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let
123-
// variable name for them
98+
// The following should suggest `if let Some(_X) ...` as it's difficult to generate a proper let variable name for them
12499
Some(42).map(diverge);
125100
"12".parse::<i32>().ok().map(diverge);
126101
Some(plus_one(1)).map(do_nothing);

0 commit comments

Comments
 (0)