Skip to content

Commit 8b53d78

Browse files
committed
Cargo fmt
1 parent af663d8 commit 8b53d78

File tree

6 files changed

+17
-36
lines changed

6 files changed

+17
-36
lines changed

src/bin/rustfmt.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ impl CliOptions {
8787
if let Ok(write_mode) = WriteMode::from_str(write_mode) {
8888
options.write_mode = Some(write_mode);
8989
} else {
90-
return Err(FmtError::from(
91-
format!("Invalid write-mode: {}", write_mode),
92-
));
90+
return Err(FmtError::from(format!(
91+
"Invalid write-mode: {}",
92+
write_mode
93+
)));
9394
}
9495
}
9596

src/chains.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,9 +147,8 @@ pub fn rewrite_chain(expr: &ast::Expr, context: &RewriteContext, shape: Shape) -
147147
let last_subexpr = &subexpr_list[suffix_try_num];
148148
let subexpr_list = &subexpr_list[suffix_try_num..subexpr_num - prefix_try_num];
149149
let iter = subexpr_list.iter().skip(1).rev().zip(child_shape_iter);
150-
let mut rewrites = iter.map(|(e, shape)| {
151-
rewrite_chain_subexpr(e, total_span, context, shape)
152-
}).collect::<Option<Vec<_>>>()?;
150+
let mut rewrites = iter.map(|(e, shape)| rewrite_chain_subexpr(e, total_span, context, shape))
151+
.collect::<Option<Vec<_>>>()?;
153152

154153
// Total of all items excluding the last.
155154
let extend_last_subexpr = last_line_extendable(&parent_rewrite) && rewrites.is_empty();

src/comment.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -224,9 +224,7 @@ pub fn rewrite_comment(
224224
// we should stop now.
225225
let num_bare_lines = orig.lines()
226226
.map(|line| line.trim())
227-
.filter(|l| {
228-
!(l.starts_with('*') || l.starts_with("//") || l.starts_with("/*"))
229-
})
227+
.filter(|l| !(l.starts_with('*') || l.starts_with("//") || l.starts_with("/*")))
230228
.count();
231229
if num_bare_lines > 0 && !config.normalize_comments() {
232230
return Some(orig.to_owned());

src/expr.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,7 @@ pub fn format_expr(
292292
};
293293

294294
expr_rw
295-
.and_then(|expr_str| {
296-
recover_comment_removed(expr_str, expr.span, context)
297-
})
295+
.and_then(|expr_str| recover_comment_removed(expr_str, expr.span, context))
298296
.and_then(|expr_str| {
299297
let attrs = outer_attributes(&expr.attrs);
300298
let attrs_str = attrs.rewrite(context, shape)?;
@@ -1925,9 +1923,7 @@ where
19251923
config: context.config,
19261924
};
19271925

1928-
write_list(&item_vec, &fmt).map(|args_str| {
1929-
(tactic != DefinitiveListTactic::Vertical, args_str)
1930-
})
1926+
write_list(&item_vec, &fmt).map(|args_str| (tactic != DefinitiveListTactic::Vertical, args_str))
19311927
}
19321928

19331929
fn try_overflow_last_arg<'a, T>(

src/items.rs

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -817,8 +817,7 @@ fn format_impl_ref_and_type(
817817
IndentStyle::Visual => new_line_offset + trait_ref_overhead,
818818
IndentStyle::Block => new_line_offset,
819819
};
820-
result.push_str(&*self_ty
821-
.rewrite(context, Shape::legacy(budget, type_offset))?);
820+
result.push_str(&*self_ty.rewrite(context, Shape::legacy(budget, type_offset))?);
822821
Some(result)
823822
} else {
824823
unreachable!();
@@ -1578,9 +1577,7 @@ fn rewrite_static(
15781577
lhs,
15791578
&**expr,
15801579
Shape::legacy(remaining_width, offset.block_only()),
1581-
).and_then(|res| {
1582-
recover_comment_removed(res, static_parts.span, context)
1583-
})
1580+
).and_then(|res| recover_comment_removed(res, static_parts.span, context))
15841581
.map(|s| if s.ends_with(';') { s } else { s + ";" })
15851582
} else {
15861583
Some(format!("{}{};", prefix, ty_str))
@@ -2096,18 +2093,14 @@ fn rewrite_args(
20962093
generics_str_contains_newline: bool,
20972094
) -> Option<String> {
20982095
let mut arg_item_strs = args.iter()
2099-
.map(|arg| {
2100-
arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent))
2101-
})
2096+
.map(|arg| arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent)))
21022097
.collect::<Option<Vec<_>>>()?;
21032098

21042099
// Account for sugary self.
21052100
// FIXME: the comment for the self argument is dropped. This is blocked
21062101
// on rust issue #27522.
21072102
let min_args = explicit_self
2108-
.and_then(|explicit_self| {
2109-
rewrite_explicit_self(explicit_self, args, context)
2110-
})
2103+
.and_then(|explicit_self| rewrite_explicit_self(explicit_self, args, context))
21112104
.map_or(1, |self_str| {
21122105
arg_item_strs[0] = self_str;
21132106
2
@@ -2326,9 +2319,8 @@ fn rewrite_generics(
23262319
) -> Option<String> {
23272320
let g_shape = generics_shape_from_config(context.config, shape, 0)?;
23282321
let one_line_width = shape.width.checked_sub(2).unwrap_or(0);
2329-
rewrite_generics_inner(context, generics, g_shape, one_line_width, span).or_else(|| {
2330-
rewrite_generics_inner(context, generics, g_shape, 0, span)
2331-
})
2322+
rewrite_generics_inner(context, generics, g_shape, one_line_width, span)
2323+
.or_else(|| rewrite_generics_inner(context, generics, g_shape, 0, span))
23322324
}
23332325

23342326
fn rewrite_generics_inner(

src/visitor.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,7 @@ impl<'a> FmtVisitor<'a> {
109109
if self.config.remove_blank_lines_at_start_or_end_of_block() {
110110
if let Some(first_stmt) = b.stmts.first() {
111111
let attr_lo = inner_attrs
112-
.and_then(|attrs| {
113-
inner_attributes(attrs).first().map(|attr| attr.span.lo())
114-
})
112+
.and_then(|attrs| inner_attributes(attrs).first().map(|attr| attr.span.lo()))
115113
.or_else(|| {
116114
// Attributes for an item in a statement position
117115
// do not belong to the statement. (rust-lang/rust#34459)
@@ -872,10 +870,7 @@ fn rewrite_first_group_attrs(
872870
for derive in derives {
873871
derive_args.append(&mut get_derive_args(context, derive)?);
874872
}
875-
return Some((
876-
derives.len(),
877-
format_derive(context, &derive_args, shape)?,
878-
));
873+
return Some((derives.len(), format_derive(context, &derive_args, shape)?));
879874
}
880875
}
881876
// Rewrite the first attribute.

0 commit comments

Comments
 (0)