From 1e1d9d4afe59fc6ec8d39148acb2f99b715c0285 Mon Sep 17 00:00:00 2001 From: Seiichi Uchida Date: Fri, 23 Mar 2018 19:59:38 +0900 Subject: [PATCH] Do not add the beginning vert to the match arm Pass the span after the match's condition expression. Closes #2554. --- src/matches.rs | 3 ++- tests/target/issue-2554.rs | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 tests/target/issue-2554.rs diff --git a/src/matches.rs b/src/matches.rs index 42f46608b52..65bf7f579d4 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -133,13 +133,14 @@ pub fn rewrite_match( Some(context.snippet(span).to_owned()) } } else { + let span_after_cond = mk_sp(cond.span.hi(), span.hi()); Some(format!( "match {}{}{{\n{}{}{}\n{}}}", cond_str, block_sep, inner_attrs_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), )) } diff --git a/tests/target/issue-2554.rs b/tests/target/issue-2554.rs new file mode 100644 index 00000000000..d5f0563a6f1 --- /dev/null +++ b/tests/target/issue-2554.rs @@ -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(_) => (), + } +}