mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-06 05:33:59 +00:00
Cargo fmt
This commit is contained in:
parent
90383d7426
commit
e3d2f2c2b1
@ -419,10 +419,12 @@ fn rewrite_chain_subexpr(
|
||||
context: &RewriteContext,
|
||||
shape: Shape,
|
||||
) -> Option<String> {
|
||||
let rewrite_element = |expr_str: String| if expr_str.len() <= shape.width {
|
||||
Some(expr_str)
|
||||
} else {
|
||||
None
|
||||
let rewrite_element = |expr_str: String| {
|
||||
if expr_str.len() <= shape.width {
|
||||
Some(expr_str)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
};
|
||||
|
||||
match expr.node {
|
||||
|
@ -2316,12 +2316,13 @@ fn rewrite_paren(context: &RewriteContext, subexpr: &ast::Expr, shape: Shape) ->
|
||||
.offset_left(paren_overhead)
|
||||
.and_then(|s| s.sub_width(paren_overhead))?;
|
||||
|
||||
let paren_wrapper =
|
||||
|s: &str| if context.config.spaces_within_parens_and_brackets() && !s.is_empty() {
|
||||
let paren_wrapper = |s: &str| {
|
||||
if context.config.spaces_within_parens_and_brackets() && !s.is_empty() {
|
||||
format!("( {} )", s)
|
||||
} else {
|
||||
format!("({})", s)
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
let subexpr_str = subexpr.rewrite(context, sub_shape)?;
|
||||
debug!("rewrite_paren, subexpr_str: `{:?}`", subexpr_str);
|
||||
|
20
src/items.rs
20
src/items.rs
@ -482,10 +482,12 @@ impl<'a> FmtVisitor<'a> {
|
||||
enum_def.variants.iter(),
|
||||
"}",
|
||||
",",
|
||||
|f| if !f.node.attrs.is_empty() {
|
||||
f.node.attrs[0].span.lo()
|
||||
} else {
|
||||
f.span.lo()
|
||||
|f| {
|
||||
if !f.node.attrs.is_empty() {
|
||||
f.node.attrs[0].span.lo()
|
||||
} else {
|
||||
f.span.lo()
|
||||
}
|
||||
},
|
||||
|f| f.span.hi(),
|
||||
|f| self.format_variant(f, one_line_width),
|
||||
@ -2549,10 +2551,12 @@ fn rewrite_where_clause_rfc_style(
|
||||
};
|
||||
let preds_str = write_list(&items.collect::<Vec<_>>(), &fmt)?;
|
||||
|
||||
let comment_separator = |comment: &str, shape: Shape| if comment.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("\n{}", shape.indent.to_string(context.config))
|
||||
let comment_separator = |comment: &str, shape: Shape| {
|
||||
if comment.is_empty() {
|
||||
String::new()
|
||||
} else {
|
||||
format!("\n{}", shape.indent.to_string(context.config))
|
||||
}
|
||||
};
|
||||
let newline_before_where = comment_separator(&comment_before, shape);
|
||||
let newline_after_where = comment_separator(&comment_after, clause_shape);
|
||||
|
Loading…
Reference in New Issue
Block a user