Skip to content

Commit 53ecaba

Browse files
authored
Merge pull request #2556 from topecongiro/issue-2554
Do not add the beginning vert to the match arm
2 parents 903de92 + 1e1d9d4 commit 53ecaba

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

src/matches.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,13 +133,14 @@ pub fn rewrite_match(
133133
Some(context.snippet(span).to_owned())
134134
}
135135
} else {
136+
let span_after_cond = mk_sp(cond.span.hi(), span.hi());
136137
Some(format!(
137138
"match {}{}{{\n{}{}{}\n{}}}",
138139
cond_str,
139140
block_sep,
140141
inner_attrs_str,
141142
nested_indent_str,
142-
rewrite_match_arms(context, arms, shape, span, open_brace_pos)?,
143+
rewrite_match_arms(context, arms, shape, span_after_cond, open_brace_pos)?,
143144
shape.indent.to_string(context.config),
144145
))
145146
}

tests/target/issue-2554.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// #2554
2+
// Do not add the beginning vert to the first match arm's pattern.
3+
4+
fn main() {
5+
match foo(|_| {
6+
bar(|_| {
7+
//
8+
})
9+
}) {
10+
Ok(()) => (),
11+
Err(_) => (),
12+
}
13+
}

0 commit comments

Comments
 (0)