mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-10 06:47:34 +00:00
Update block checking code
This commit is contained in:
parent
7ce887abcf
commit
74d40c042f
@ -960,14 +960,15 @@ impl Rewrite for ast::Arm {
|
|||||||
let budget = context.config.max_width - line_start - comma.len() - 4;
|
let budget = context.config.max_width - line_start - comma.len() - 4;
|
||||||
let offset = Indent::new(offset.block_indent, line_start + 4 - offset.block_indent);
|
let offset = Indent::new(offset.block_indent, line_start + 4 - offset.block_indent);
|
||||||
let rewrite = nop_block_collapse(body.rewrite(context, budget, offset), budget);
|
let rewrite = nop_block_collapse(body.rewrite(context, budget, offset), budget);
|
||||||
let is_body_str_block = match rewrite {
|
let is_block = if let ast::ExprBlock(ref block) = body.node {
|
||||||
Some(ref s) => s.trim().starts_with("{") && s.trim().ends_with("}"),
|
true
|
||||||
None => false,
|
} else {
|
||||||
|
false
|
||||||
};
|
};
|
||||||
|
|
||||||
match rewrite {
|
match rewrite {
|
||||||
Some(ref body_str) if !body_str.contains('\n') || !context.config.wrap_match_arms ||
|
Some(ref body_str) if !body_str.contains('\n') || !context.config.wrap_match_arms ||
|
||||||
is_body_str_block => {
|
is_block => {
|
||||||
return Some(format!("{}{} => {}{}",
|
return Some(format!("{}{} => {}{}",
|
||||||
attr_str.trim_left(),
|
attr_str.trim_left(),
|
||||||
pats_str,
|
pats_str,
|
||||||
|
Loading…
Reference in New Issue
Block a user