Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 8c94e2b

Browse files
authored
Merge pull request rust-lang#3533 from rchaser53/issue-3532
fix Comma in comment causes no formatting
2 parents d3ec460 + 2c58b20 commit 8c94e2b

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

src/lists.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ pub fn extract_post_comment(
612612
post_snippet[1..].trim_matches(white_space)
613613
} else if post_snippet.starts_with(separator) {
614614
post_snippet[separator.len()..].trim_matches(white_space)
615-
} else if post_snippet.ends_with(',') {
615+
} else if post_snippet.ends_with(',') && !post_snippet.trim().starts_with("//") {
616616
post_snippet[..(post_snippet.len() - 1)].trim_matches(white_space)
617617
} else {
618618
post_snippet

tests/source/issue-3532.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
fn foo(a: T) {
2+
match a {
3+
1 => {}
4+
0 => {}
5+
// _ => panic!("doesn't format!"),
6+
}
7+
}

tests/target/issue-3532.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
fn foo(a: T) {
2+
match a {
3+
1 => {}
4+
0 => {} // _ => panic!("doesn't format!"),
5+
}
6+
}

0 commit comments

Comments
 (0)