mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-08 04:56:58 +00:00
Do not add the beginning vert to the match arm
Pass the span after the match's condition expression. Closes #2554.
This commit is contained in:
parent
2fbdedbf2f
commit
1e1d9d4afe
@ -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),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
13
tests/target/issue-2554.rs
Normal file
13
tests/target/issue-2554.rs
Normal 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(_) => (),
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user