fix 'extra comma inserted due to comment' (#3677)

This commit is contained in:
rChaser53 2019-07-14 22:16:47 +09:00 committed by Seiichi Uchida
parent e55fc6be3b
commit 71289e1d23
3 changed files with 16 additions and 1 deletions

View file

@ -612,7 +612,11 @@ pub(crate) 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(',') && !post_snippet.trim().starts_with("//") {
}
// not comment or over two lines
else if post_snippet.ends_with(',')
&& (!post_snippet.trim().starts_with("//") || post_snippet.trim().contains('\n'))
{
post_snippet[..(post_snippet.len() - 1)].trim_matches(white_space)
} else {
post_snippet

View file

@ -0,0 +1,5 @@
fn main() {
println!("{}"
// comment
, 111);
}

View file

@ -0,0 +1,6 @@
fn main() {
println!(
"{}", // comment
111
);
}