Skip to content

Commit 6a7f866

Browse files
committed
Format source codes
1 parent f8586ba commit 6a7f866

File tree

10 files changed

+69
-32
lines changed

10 files changed

+69
-32
lines changed

src/expr.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3035,8 +3035,7 @@ impl<'a> ToExpr for ast::StructField {
30353035
None
30363036
}
30373037

3038-
#[allow(unused_variables)]
3039-
fn can_be_overflowed(&self, context: &RewriteContext, len: usize) -> bool {
3038+
fn can_be_overflowed(&self, _: &RewriteContext, _: usize) -> bool {
30403039
false
30413040
}
30423041
}

src/file_lines.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,9 @@ impl FileLines {
167167
}
168168

169169
/// FileLines files iterator.
170-
pub struct Files<'a>(Option<::std::collections::hash_map::Keys<'a, String, Vec<Range>>>);
170+
pub struct Files<'a>(
171+
Option<::std::collections::hash_map::Keys<'a, String, Vec<Range>>>,
172+
);
171173

172174
impl<'a> iter::Iterator for Files<'a> {
173175
type Item = &'a String;

src/items.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,11 @@ fn rewrite_struct_field_type(
14191419
.map(|ty| format!("{}{}", spacing, ty))
14201420
}
14211421

1422+
impl Rewrite for ast::StructField {
1423+
fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
1424+
rewrite_struct_field(context, self, shape, 0)
1425+
}
1426+
}
14221427

14231428
pub fn rewrite_struct_field(
14241429
context: &RewriteContext,

tests/target/configs-struct_field_align_threshold-20.rs

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,14 +73,19 @@ struct Bar;
7373

7474
struct NewType(Type, OtherType);
7575

76-
struct NewInt<T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */);
77-
78-
struct Qux<'a,
79-
N: Clone + 'a,
80-
E: Clone + 'a,
81-
G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
82-
W: Write + Copy>
83-
(
76+
struct NewInt<T: Copy>(
77+
pub i32,
78+
SomeType, // inline comment
79+
T, // sup
80+
);
81+
82+
struct Qux<
83+
'a,
84+
N: Clone + 'a,
85+
E: Clone + 'a,
86+
G: Labeller<'a, N, E> + GraphWalk<'a, N, E>,
87+
W: Write + Copy,
88+
>(
8489
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, // Comment
8590
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
8691
#[AnAttr]
@@ -94,7 +99,7 @@ struct Tuple(
9499
// Comment 1
95100
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA,
96101
// Comment 2
97-
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
102+
BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB,
98103
);
99104

100105
// With a where clause and generics.
@@ -139,7 +144,10 @@ struct Baz {
139144
}
140145

141146
// Will this be a one-liner?
142-
struct Tuple(A /* Comment */, B);
147+
struct Tuple(
148+
A, // Comment
149+
B,
150+
);
143151

144152
pub struct State<F: FnMut() -> time::Timespec> {
145153
now: F,
@@ -186,19 +194,27 @@ struct Foo<T>(
186194
TTTTTTTTTTTTTTTTT,
187195
UUUUUUUUUUUUUUUUUUUUUUUU,
188196
TTTTTTTTTTTTTTTTTTT,
189-
UUUUUUUUUUUUUUUUUUU
197+
UUUUUUUUUUUUUUUUUUU,
190198
);
191-
struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT)
199+
struct Foo<T>(
200+
TTTTTTTTTTTTTTTTTT,
201+
UUUUUUUUUUUUUUUUUUUUUUUU,
202+
TTTTTTTTTTTTTTTTTTT,
203+
)
192204
where
193205
T: PartialEq;
194-
struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT)
206+
struct Foo<T>(
207+
TTTTTTTTTTTTTTTTT,
208+
UUUUUUUUUUUUUUUUUUUUUUUU,
209+
TTTTTTTTTTTTTTTTTTTTT,
210+
)
195211
where
196212
T: PartialEq;
197213
struct Foo<T>(
198214
TTTTTTTTTTTTTTTTT,
199215
UUUUUUUUUUUUUUUUUUUUUUUU,
200216
TTTTTTTTTTTTTTTTTTT,
201-
UUUUUUUUUUUUUUUUUUU
217+
UUUUUUUUUUUUUUUUUUU,
202218
)
203219
where
204220
T: PartialEq;
@@ -208,7 +224,7 @@ struct Foo<T>(
208224
// Baz
209225
TTTTTTTTTTTTTTTTTTT,
210226
// Qux (FIXME #572 - doc comment)
211-
UUUUUUUUUUUUUUUUUUU
227+
UUUUUUUUUUUUUUUUUUU,
212228
);
213229

214230
mod m {
@@ -223,7 +239,7 @@ mod m {
223239
struct Foo<T>(
224240
TTTTTTTTTTTTTTTTTTT,
225241
/// Qux
226-
UUUUUUUUUUUUUUUUUUU
242+
UUUUUUUUUUUUUUUUUUU,
227243
);
228244

229245
struct Issue677 {

tests/target/macros.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fn main() {
2929
kaas!(
3030
// comments
3131
a, // post macro
32-
b /* another */
32+
b // another
3333
);
3434

3535
trailingcomma!(a, b, c,);

tests/target/multiple.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ where
4040

4141
fn baz<
4242
'a: 'b, // comment on 'a
43-
T: SomsssssssssssssssssssssssssssssssssssssssssssssssssssssseType, /* comment on T */
43+
T: SomsssssssssssssssssssssssssssssssssssssssssssssssssssssseType, // comment on T
4444
>(
4545
a: A,
4646
b: B, // comment on b

tests/target/paths.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@ fn main() {
1414
supports_clipboard,
1515
);
1616

17-
Quux::<ParamOne /* Comment 1 */, ParamTwo /* Comment 2 */>::some_func();
17+
Quux::<
18+
ParamOne, // Comment 1
19+
ParamTwo, // Comment 2
20+
>::some_func();
1821

1922
<*mut JSObject>::relocate(entry);
2023

tests/target/struct_tuple_visual.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ fn foo() {
1010
// Comment
1111
foo(), // Comment
1212
// Comment
13-
bar(), /* Comment */
13+
bar(), // Comment
1414
);
1515

1616
Foo(Bar, f());
@@ -24,7 +24,7 @@ fn foo() {
2424

2525
Baz(
2626
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx,
27-
zzzzz, /* test */
27+
zzzzz, // test
2828
);
2929

3030
A(

tests/target/structs.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,11 @@ struct Bar;
4141

4242
struct NewType(Type, OtherType);
4343

44-
struct NewInt<T: Copy>(pub i32, SomeType /* inline comment */, T /* sup */);
44+
struct NewInt<T: Copy>(
45+
pub i32,
46+
SomeType, // inline comment
47+
T, // sup
48+
);
4549

4650
struct Qux<
4751
'a,
@@ -108,7 +112,10 @@ struct Baz {
108112
}
109113

110114
// Will this be a one-liner?
111-
struct Tuple(A /* Comment */, B);
115+
struct Tuple(
116+
A, // Comment
117+
B,
118+
);
112119

113120
pub struct State<F: FnMut() -> time::Timespec> {
114121
now: F,
@@ -157,10 +164,18 @@ struct Foo<T>(
157164
TTTTTTTTTTTTTTTTTTT,
158165
UUUUUUUUUUUUUUUUUUU,
159166
);
160-
struct Foo<T>(TTTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTT)
167+
struct Foo<T>(
168+
TTTTTTTTTTTTTTTTTT,
169+
UUUUUUUUUUUUUUUUUUUUUUUU,
170+
TTTTTTTTTTTTTTTTTTT,
171+
)
161172
where
162173
T: PartialEq;
163-
struct Foo<T>(TTTTTTTTTTTTTTTTT, UUUUUUUUUUUUUUUUUUUUUUUU, TTTTTTTTTTTTTTTTTTTTT)
174+
struct Foo<T>(
175+
TTTTTTTTTTTTTTTTT,
176+
UUUUUUUUUUUUUUUUUUUUUUUU,
177+
TTTTTTTTTTTTTTTTTTTTT,
178+
)
164179
where
165180
T: PartialEq;
166181
struct Foo<T>(

tests/target/trailing_commas.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,7 @@ struct Pair<
4848

4949
struct TupPair<
5050
S, T,
51-
>(
52-
S,
53-
T,
54-
)
51+
>(S, T,)
5552
where
5653
T: P,
5754
S: P + Q;

0 commit comments

Comments
 (0)