Skip to content

Commit ea042b9

Browse files
mujpaocalebcartwright
authored andcommitted
Add more tests for comments in lists
1 parent 243cec7 commit ea042b9

File tree

6 files changed

+199
-0
lines changed

6 files changed

+199
-0
lines changed

Diff for: tests/source/issue-4909/wrap-comments-not-normalized.rs renamed to tests/source/comments-in-lists/wrap-comments-not-normalized.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// rustfmt-wrap_comments: true
22

3+
// https://github.com/rust-lang/rustfmt/issues/4909
34
pub enum E {
45
// Expand as needed, numbers should be ascending according to the stage
56
// through the inclusion pipeline, or according to the descriptions
@@ -105,4 +106,24 @@ fn main() {
105106
2,
106107
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
107108
];
109+
110+
// https://github.com/rust-lang/rustfmt/issues/4430
111+
match a {
112+
// Expand as needed, numbers should be ascending according to the stage
113+
// through the inclusion pipeline, or according to the descriptions
114+
b => c,
115+
// Expand as needed, numbers should be ascending according to the stage
116+
// through the inclusion pipeline, or according to the descriptions
117+
d => e,
118+
// Expand as needed, numbers should be ascending according to the stage
119+
// through the inclusion pipeline, or according to the descriptions
120+
}
121+
122+
match a {
123+
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
124+
b => c,
125+
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
126+
d => e,
127+
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
128+
}
108129
}

Diff for: tests/source/issue-4909/wrap-comments-true.rs renamed to tests/source/comments-in-lists/wrap-comments-true.rs

+21
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// rustfmt-normalize_comments: true
22
// rustfmt-wrap_comments: true
33

4+
// https://github.com/rust-lang/rustfmt/issues/4909
45
pub enum E {
56
// Expand as needed, numbers should be ascending according to the stage
67
// through the inclusion pipeline, or according to the descriptions
@@ -106,4 +107,24 @@ fn main() {
106107
2,
107108
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
108109
];
110+
111+
// https://github.com/rust-lang/rustfmt/issues/4430
112+
match a {
113+
// Expand as needed, numbers should be ascending according to the stage
114+
// through the inclusion pipeline, or according to the descriptions
115+
b => c,
116+
// Expand as needed, numbers should be ascending according to the stage
117+
// through the inclusion pipeline, or according to the descriptions
118+
d => e,
119+
// Expand as needed, numbers should be ascending according to the stage
120+
// through the inclusion pipeline, or according to the descriptions
121+
}
122+
123+
match a {
124+
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
125+
b => c,
126+
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
127+
d => e,
128+
// Expand as needed, numbers should be ascending according to the stage through the inclusion pipeline, or according to the descriptions
129+
}
109130
}
+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
// rustfmt-format_code_in_doc_comments: true
2+
3+
// https://github.com/rust-lang/rustfmt/issues/4420
4+
enum Minimal {
5+
Example,
6+
//[thisisremoved thatsleft
7+
// canbeanything
8+
}
9+
10+
struct Minimal2 {
11+
Example: usize,
12+
//[thisisremoved thatsleft
13+
// canbeanything
14+
}
15+
16+
pub enum E {
17+
// Expand as needed, numbers should be ascending according to the stage
18+
// through the inclusion pipeline, or according to the descriptions
19+
Variant1,
20+
// Expand as needed, numbers should be ascending according to the stage
21+
// through the inclusion pipeline, or according to the descriptions
22+
Variant2,
23+
// Expand as needed, numbers should be ascending according to the stage
24+
// through the inclusion pipeline, or according to the descriptions
25+
}
26+
27+
pub enum E2 {
28+
// This can be changed once https://github.com/rust-lang/rustfmt/issues/4854 is fixed
29+
// Expand as needed, numbers should be ascending according to the stage
30+
// through the inclusion pipeline, or according to the descriptions
31+
}
32+
33+
pub struct S {
34+
// Expand as needed, numbers should be ascending according to the stage
35+
// through the inclusion pipeline, or according to the descriptions
36+
some_field: usize,
37+
// Expand as needed, numbers should be ascending according to the stage
38+
// through the inclusion pipeline, or according to the descriptions
39+
last_field: usize,
40+
// Expand as needed, numbers should be ascending according to the stage
41+
// through the inclusion pipeline, or according to the descriptions
42+
}
43+
44+
pub struct S2 {
45+
// This can be changed once https://github.com/rust-lang/rustfmt/issues/4854 is fixed
46+
// Expand as needed, numbers should be ascending according to the stage
47+
// through the inclusion pipeline, or according to the descriptions
48+
}
49+
50+
fn foo(
51+
// Expand as needed, numbers should be ascending according to the stage
52+
// through the inclusion pipeline, or according to the descriptions
53+
a: usize,
54+
// Expand as needed, numbers should be ascending according to the stage
55+
// through the inclusion pipeline, or according to the descriptions
56+
b: usize,
57+
// Expand as needed, numbers should be ascending according to the stage
58+
// through the inclusion pipeline, or according to the descriptions
59+
) -> usize {
60+
5
61+
}
62+
63+
fn foo2(// Expand as needed, numbers should be ascending according to the stage
64+
// through the inclusion pipeline, or according to the descriptions
65+
) -> usize {
66+
5
67+
}
68+
69+
fn main() {
70+
let v = vec![
71+
// Expand as needed, numbers should be ascending according to the stage
72+
// through the inclusion pipeline, or according to the descriptions
73+
1,
74+
// Expand as needed, numbers should be ascending according to the stage
75+
// through the inclusion pipeline, or according to the descriptions
76+
2,
77+
// Expand as needed, numbers should be ascending according to the stage
78+
// through the inclusion pipeline, or according to the descriptions
79+
];
80+
81+
let v2: Vec<i32> = vec![
82+
// Expand as needed, numbers should be ascending according to the stage
83+
// through the inclusion pipeline, or according to the descriptions
84+
];
85+
86+
match a {
87+
// Expand as needed, numbers should be ascending according to the stage
88+
// through the inclusion pipeline, or according to the descriptions
89+
b => c,
90+
// Expand as needed, numbers should be ascending according to the stage
91+
// through the inclusion pipeline, or according to the descriptions
92+
d => e,
93+
// Expand as needed, numbers should be ascending according to the stage
94+
// through the inclusion pipeline, or according to the descriptions
95+
}
96+
}

Diff for: tests/target/issue-4909/wrap-comments-false.rs renamed to tests/target/comments-in-lists/wrap-comments-false.rs

+13
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// rustfmt-normalize_comments: true
22

3+
// https://github.com/rust-lang/rustfmt/issues/4909
34
pub enum E {
45
// Expand as needed, numbers should be ascending according to the stage
56
// through the inclusion pipeline, or according to the descriptions
@@ -69,4 +70,16 @@ fn main() {
6970
// Expand as needed, numbers should be ascending according to the stage
7071
// through the inclusion pipeline, or according to the descriptions
7172
];
73+
74+
// https://github.com/rust-lang/rustfmt/issues/4430
75+
match a {
76+
// Expand as needed, numbers should be ascending according to the stage
77+
// through the inclusion pipeline, or according to the descriptions
78+
b => c,
79+
// Expand as needed, numbers should be ascending according to the stage
80+
// through the inclusion pipeline, or according to the descriptions
81+
d => e,
82+
// Expand as needed, numbers should be ascending according to the stage
83+
// through the inclusion pipeline, or according to the descriptions
84+
}
7285
}

Diff for: tests/target/issue-4909/wrap-comments-not-normalized.rs renamed to tests/target/comments-in-lists/wrap-comments-not-normalized.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// rustfmt-wrap_comments: true
22

3+
// https://github.com/rust-lang/rustfmt/issues/4909
34
pub enum E {
45
// Expand as needed, numbers should be ascending according to the stage
56
// through the inclusion pipeline, or according to the descriptions
@@ -115,4 +116,27 @@ fn main() {
115116
// Expand as needed, numbers should be ascending according to the stage through the
116117
// inclusion pipeline, or according to the descriptions
117118
];
119+
120+
// https://github.com/rust-lang/rustfmt/issues/4430
121+
match a {
122+
// Expand as needed, numbers should be ascending according to the stage
123+
// through the inclusion pipeline, or according to the descriptions
124+
b => c,
125+
// Expand as needed, numbers should be ascending according to the stage
126+
// through the inclusion pipeline, or according to the descriptions
127+
d => e,
128+
// Expand as needed, numbers should be ascending according to the stage
129+
// through the inclusion pipeline, or according to the descriptions
130+
}
131+
132+
match a {
133+
// Expand as needed, numbers should be ascending according to the stage through the
134+
// inclusion pipeline, or according to the descriptions
135+
b => c,
136+
// Expand as needed, numbers should be ascending according to the stage through the
137+
// inclusion pipeline, or according to the descriptions
138+
d => e,
139+
// Expand as needed, numbers should be ascending according to the stage through the
140+
// inclusion pipeline, or according to the descriptions
141+
}
118142
}

Diff for: tests/target/issue-4909/wrap-comments-true.rs renamed to tests/target/comments-in-lists/wrap-comments-true.rs

+24
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// rustfmt-normalize_comments: true
22
// rustfmt-wrap_comments: true
33

4+
// https://github.com/rust-lang/rustfmt/issues/4909
45
pub enum E {
56
// Expand as needed, numbers should be ascending according to the stage
67
// through the inclusion pipeline, or according to the descriptions
@@ -116,4 +117,27 @@ fn main() {
116117
// Expand as needed, numbers should be ascending according to the stage through the
117118
// inclusion pipeline, or according to the descriptions
118119
];
120+
121+
// https://github.com/rust-lang/rustfmt/issues/4430
122+
match a {
123+
// Expand as needed, numbers should be ascending according to the stage
124+
// through the inclusion pipeline, or according to the descriptions
125+
b => c,
126+
// Expand as needed, numbers should be ascending according to the stage
127+
// through the inclusion pipeline, or according to the descriptions
128+
d => e,
129+
// Expand as needed, numbers should be ascending according to the stage
130+
// through the inclusion pipeline, or according to the descriptions
131+
}
132+
133+
match a {
134+
// Expand as needed, numbers should be ascending according to the stage through the
135+
// inclusion pipeline, or according to the descriptions
136+
b => c,
137+
// Expand as needed, numbers should be ascending according to the stage through the
138+
// inclusion pipeline, or according to the descriptions
139+
d => e,
140+
// Expand as needed, numbers should be ascending according to the stage through the
141+
// inclusion pipeline, or according to the descriptions
142+
}
119143
}

0 commit comments

Comments
 (0)