diff --git a/src/lists.rs b/src/lists.rs index ffb92d3a83cbf..97592f893a520 100644 --- a/src/lists.rs +++ b/src/lists.rs @@ -612,7 +612,7 @@ pub fn extract_post_comment( post_snippet[1..].trim_matches(white_space) } else if post_snippet.starts_with(separator) { post_snippet[separator.len()..].trim_matches(white_space) - } else if post_snippet.ends_with(',') { + } else if post_snippet.ends_with(',') && !post_snippet.trim().starts_with("//") { post_snippet[..(post_snippet.len() - 1)].trim_matches(white_space) } else { post_snippet diff --git a/tests/source/issue-3532.rs b/tests/source/issue-3532.rs new file mode 100644 index 0000000000000..ec0c01610cd4f --- /dev/null +++ b/tests/source/issue-3532.rs @@ -0,0 +1,7 @@ +fn foo(a: T) { + match a { +1 => {} + 0 => {} + // _ => panic!("doesn't format!"), + } +} diff --git a/tests/target/issue-3532.rs b/tests/target/issue-3532.rs new file mode 100644 index 0000000000000..f41902620cd19 --- /dev/null +++ b/tests/target/issue-3532.rs @@ -0,0 +1,6 @@ +fn foo(a: T) { + match a { + 1 => {} + 0 => {} // _ => panic!("doesn't format!"), + } +}