fix 'extra comma inserted due to comment' (#3677)
This commit is contained in:
parent
e55fc6be3b
commit
71289e1d23
@ -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
|
||||
|
5
tests/source/issue-3675.rs
Normal file
5
tests/source/issue-3675.rs
Normal file
@ -0,0 +1,5 @@
|
||||
fn main() {
|
||||
println!("{}"
|
||||
// comment
|
||||
, 111);
|
||||
}
|
6
tests/target/issue-3675.rs
Normal file
6
tests/target/issue-3675.rs
Normal file
@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
println!(
|
||||
"{}", // comment
|
||||
111
|
||||
);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user