Cargo fmt

This commit is contained in:
topecongiro
2017-10-18 22:01:59 +09:00
parent 142fc45dbb
commit 0d359eacd7
3 changed files with 16 additions and 16 deletions
+3 -1
View File
@@ -1871,7 +1871,9 @@ fn rewrite_pat_expr(
} else {
format!("{} ", matcher)
};
let pat_shape = shape.offset_left(matcher.len())?.sub_width(connector.len())?;
let pat_shape = shape
.offset_left(matcher.len())?
.sub_width(connector.len())?;
let pat_string = pat.rewrite(context, pat_shape)?;
let result = format!("{}{}{}", matcher, pat_string, connector);
return rewrite_assign_rhs(context, result, expr, shape);
+10 -14
View File
@@ -2037,9 +2037,7 @@ fn rewrite_args(
generics_str_contains_newline: bool,
) -> Option<String> {
let mut arg_item_strs = args.iter()
.map(|arg| {
arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent))
})
.map(|arg| arg.rewrite(context, Shape::legacy(multi_line_budget, arg_indent)))
.collect::<Option<Vec<_>>>()?;
// Account for sugary self.
@@ -2713,17 +2711,15 @@ fn rewrite(&self, context: &RewriteContext, shape: Shape) -> Option<String> {
let span = mk_sp(self.span.lo(), self.span.hi() - BytePos(1));
let item_str = match self.node {
ast::ForeignItemKind::Fn(ref fn_decl, ref generics) => {
rewrite_fn_base(
context,
shape.indent,
self.ident,
&FnSig::new(fn_decl, generics, self.vis.clone()),
span,
false,
false,
).map(|(s, _)| format!("{};", s))
}
ast::ForeignItemKind::Fn(ref fn_decl, ref generics) => rewrite_fn_base(
context,
shape.indent,
self.ident,
&FnSig::new(fn_decl, generics, self.vis.clone()),
span,
false,
false,
).map(|(s, _)| format!("{};", s)),
ast::ForeignItemKind::Static(ref ty, is_mutable) => {
// FIXME(#21): we're dropping potential comments in between the
// function keywords here.
+3 -1
View File
@@ -67,7 +67,9 @@ pub fn rewrite_string<'a>(orig: &str, fmt: &StringFormat<'a>) -> Option<String>
let ender_length = fmt.line_end.len();
// If we cannot put at least a single character per line, the rewrite won't
// succeed.
let max_chars = shape.width.checked_sub(fmt.opener.len() + ender_length + 1)? + 1;
let max_chars = shape
.width
.checked_sub(fmt.opener.len() + ender_length + 1)? + 1;
// Snip a line at a time from `orig` until it is used up. Push the snippet
// onto result.