Skip to content

Commit 068ec24

Browse files
committed
Cargo fmt
1 parent cf2f7b4 commit 068ec24

File tree

6 files changed

+26
-70
lines changed

6 files changed

+26
-70
lines changed

src/items.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -860,8 +860,7 @@ fn format_impl_ref_and_type(
860860
result.push_str(format_defaultness(defaultness));
861861
result.push_str(format_unsafety(unsafety));
862862

863-
let shape =
864-
Shape::indented(offset + last_line_width(&result), context.config);
863+
let shape = Shape::indented(offset + last_line_width(&result), context.config);
865864
let generics_str = rewrite_generics(context, "impl", generics, shape)?;
866865
result.push_str(&generics_str);
867866

@@ -1933,8 +1932,7 @@ impl Rewrite for ast::FunctionRetTy {
19331932
match *self {
19341933
ast::FunctionRetTy::Default(_) => Some(String::new()),
19351934
ast::FunctionRetTy::Ty(ref ty) => {
1936-
if context.config.indent_style() == IndentStyle::Visual
1937-
{
1935+
if context.config.indent_style() == IndentStyle::Visual {
19381936
let inner_width = shape.width.checked_sub(3)?;
19391937
return ty
19401938
.rewrite(context, Shape::legacy(inner_width, shape.indent + 3))
@@ -2288,17 +2286,17 @@ fn rewrite_fn_base(
22882286
.last()
22892287
.map_or(false, |last_line| last_line.contains("//"));
22902288

2291-
if closing_paren_overflow_max_width {
2292-
result.push(')');
2293-
result.push_str(&indent.to_string_with_newline(context.config));
2294-
no_params_and_over_max_width = true;
2295-
} else if params_last_line_contains_comment {
2296-
result.push_str(&indent.to_string_with_newline(context.config));
2297-
result.push(')');
2298-
no_params_and_over_max_width = true;
2299-
} else {
2300-
result.push(')');
2301-
}
2289+
if closing_paren_overflow_max_width {
2290+
result.push(')');
2291+
result.push_str(&indent.to_string_with_newline(context.config));
2292+
no_params_and_over_max_width = true;
2293+
} else if params_last_line_contains_comment {
2294+
result.push_str(&indent.to_string_with_newline(context.config));
2295+
result.push(')');
2296+
no_params_and_over_max_width = true;
2297+
} else {
2298+
result.push(')');
2299+
}
23022300
}
23032301

23042302
// Return type.
@@ -2324,8 +2322,7 @@ fn rewrite_fn_base(
23242322
}
23252323
};
23262324
let ret_shape = if ret_should_indent {
2327-
if context.config.indent_style() == IndentStyle::Visual
2328-
{
2325+
if context.config.indent_style() == IndentStyle::Visual {
23292326
let indent = if param_str.is_empty() {
23302327
// Aligning with non-existent params looks silly.
23312328
force_new_line_for_brace = true;
@@ -2356,9 +2353,9 @@ fn rewrite_fn_base(
23562353
ret_shape
23572354
}
23582355
} else {
2359-
if !param_str.is_empty() || !no_params_and_over_max_width {
2360-
result.push(' ');
2361-
}
2356+
if !param_str.is_empty() || !no_params_and_over_max_width {
2357+
result.push(' ');
2358+
}
23622359

23632360
let ret_shape = Shape::indented(indent, context.config);
23642361
ret_shape

src/matches.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -405,12 +405,11 @@ fn rewrite_match_body(
405405
} else {
406406
""
407407
};
408-
let semicolon =
409-
if semicolon_for_expr(context, body) {
410-
";"
411-
} else {
412-
""
413-
};
408+
let semicolon = if semicolon_for_expr(context, body) {
409+
";"
410+
} else {
411+
""
412+
};
414413
("{", format!("{}{}}}{}", semicolon, indent_str, comma))
415414
} else {
416415
("", String::from(","))

src/overflow.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,9 +472,7 @@ impl<'a> Context<'a> {
472472
self.context.force_one_line_chain.replace(true);
473473
}
474474
Some(OverflowableItem::MacroArg(MacroArg::Expr(expr)))
475-
if !combine_arg_with_callee
476-
&& is_method_call(expr)
477-
=>
475+
if !combine_arg_with_callee && is_method_call(expr) =>
478476
{
479477
self.context.force_one_line_chain.replace(true);
480478
}

src/types.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -678,8 +678,7 @@ impl Rewrite for ast::Ty {
678678
// FIXME: we drop any comments here, even though it's a silly place to put
679679
// comments.
680680
ast::TyKind::Paren(ref ty) => {
681-
if context.config.indent_style() == IndentStyle::Visual
682-
{
681+
if context.config.indent_style() == IndentStyle::Visual {
683682
let budget = shape.width.checked_sub(2)?;
684683
return ty
685684
.rewrite(context, Shape::legacy(budget, shape.indent + 1))
@@ -744,8 +743,7 @@ impl Rewrite for ast::Ty {
744743
if it.is_empty() {
745744
return Some("impl".to_owned());
746745
}
747-
let rw =
748-
join_bounds(context, shape, it, false);
746+
let rw = join_bounds(context, shape, it, false);
749747
rw.map(|it_str| {
750748
let space = if it_str.is_empty() { "" } else { " " };
751749
format!("impl{}{}", space, it_str)

src/utils.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -582,11 +582,7 @@ pub(crate) fn trim_left_preserve_layout(
582582
// Because there is a veto against trimming and indenting lines within a string,
583583
// such lines should not be taken into account when computing the minimum.
584584
match kind {
585-
FullCodeCharKind::InStringCommented | FullCodeCharKind::EndStringCommented
586-
=>
587-
{
588-
None
589-
}
585+
FullCodeCharKind::InStringCommented | FullCodeCharKind::EndStringCommented => None,
590586
FullCodeCharKind::InString | FullCodeCharKind::EndString => None,
591587
_ => prefix_space_width,
592588
}

src/visitor.rs

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -270,38 +270,6 @@ impl<'b, 'a: 'b> FmtVisitor<'a> {
270270

271271
let comment_shape =
272272
Shape::indented(self.block_indent, config).comment(config);
273-
if self.config.version() == Version::Two && comment_on_same_line {
274-
self.push_str(" ");
275-
// put the first line of the comment on the same line as the
276-
// block's last line
277-
match sub_slice.find("\n") {
278-
None => {
279-
self.push_str(&sub_slice);
280-
}
281-
Some(offset) if offset + 1 == sub_slice.len() => {
282-
self.push_str(&sub_slice[..offset]);
283-
}
284-
Some(offset) => {
285-
let first_line = &sub_slice[..offset];
286-
self.push_str(first_line);
287-
288-
// put the other lines below it, shaping it as needed
289-
let other_lines = &sub_slice[offset + 1..];
290-
if !other_lines.trim().is_empty() {
291-
self.push_str(
292-
&self.block_indent.to_string_with_newline(config),
293-
);
294-
let comment_str =
295-
rewrite_comment(other_lines, false, comment_shape, config);
296-
match comment_str {
297-
Some(ref s) => self.push_str(s),
298-
None => self.push_str(other_lines),
299-
}
300-
}
301-
}
302-
}
303-
self.push_str(&self.block_indent.to_string_with_newline(config));
304-
}
305273

306274
let comment_str = rewrite_comment(&sub_slice, false, comment_shape, config);
307275
match comment_str {

0 commit comments

Comments
 (0)