From 302a0098e580df542162473f46354bb21fb1d676 Mon Sep 17 00:00:00 2001 From: Maya Farber Brodsky Date: Fri, 25 Oct 2024 18:42:37 +0300 Subject: [PATCH] Fix incorrect separator for match arms --- src/matches.rs | 2 +- tests/source/issue-6373.rs | 8 ++++++++ tests/target/issue-6373.rs | 8 ++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/source/issue-6373.rs create mode 100644 tests/target/issue-6373.rs diff --git a/src/matches.rs b/src/matches.rs index 8f62648e576..ea2fb699a6c 100644 --- a/src/matches.rs +++ b/src/matches.rs @@ -224,7 +224,7 @@ fn rewrite_match_arms( .zip(beginning_verts.into_iter()) .map(|((arm, is_last), beginning_vert)| ArmWrapper::new(arm, is_last, beginning_vert)), "}", - "|", + ",", |arm| arm.span().lo(), |arm| arm.span().hi(), |arm| arm.rewrite_result(context, arm_shape), diff --git a/tests/source/issue-6373.rs b/tests/source/issue-6373.rs new file mode 100644 index 00000000000..3291f4d3cfd --- /dev/null +++ b/tests/source/issue-6373.rs @@ -0,0 +1,8 @@ +fn main() { + let x: Option = Some(10); + let value = match x { + Some(i) => i /* comment */, + None => 0, + }; + println!("{}", value); +} diff --git a/tests/target/issue-6373.rs b/tests/target/issue-6373.rs new file mode 100644 index 00000000000..c5a14e3936a --- /dev/null +++ b/tests/target/issue-6373.rs @@ -0,0 +1,8 @@ +fn main() { + let x: Option = Some(10); + let value = match x { + Some(i) => i, /* comment */ + None => 0, + }; + println!("{}", value); +}