Merge pull request #2556 from topecongiro/issue-2554

Do not add the beginning vert to the match arm
This commit is contained in:
Nick Cameron 2018-03-26 18:01:24 +13:00 committed by GitHub
commit 53ecabad04
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View file

@ -133,13 +133,14 @@ pub fn rewrite_match(
Some(context.snippet(span).to_owned()) Some(context.snippet(span).to_owned())
} }
} else { } else {
let span_after_cond = mk_sp(cond.span.hi(), span.hi());
Some(format!( Some(format!(
"match {}{}{{\n{}{}{}\n{}}}", "match {}{}{{\n{}{}{}\n{}}}",
cond_str, cond_str,
block_sep, block_sep,
inner_attrs_str, inner_attrs_str,
nested_indent_str, nested_indent_str,
rewrite_match_arms(context, arms, shape, span, open_brace_pos)?, rewrite_match_arms(context, arms, shape, span_after_cond, open_brace_pos)?,
shape.indent.to_string(context.config), shape.indent.to_string(context.config),
)) ))
} }

View file

@ -0,0 +1,13 @@
// #2554
// Do not add the beginning vert to the first match arm's pattern.
fn main() {
match foo(|_| {
bar(|_| {
//
})
}) {
Ok(()) => (),
Err(_) => (),
}
}