mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-07 09:13:07 +03:00
Cargo fmt
This commit is contained in:
+3
-1
@@ -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
@@ -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
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user