remove trailing whitespaces in missing spans

This commit is contained in:
Stéphane Campinas 2019-03-16 12:23:02 +01:00
parent 5f3dfe6c51
commit 2d5bc69475
No known key found for this signature in database
GPG Key ID: 6D5620D908210133
3 changed files with 16 additions and 1 deletions

View File

@ -252,7 +252,12 @@ impl<'a> FmtVisitor<'a> {
// - if there isn't one already
// - otherwise, only if the last line is a line comment
if status.line_start <= snippet.len() {
match snippet[status.line_start..].chars().next() {
match snippet[status.line_start..]
.chars()
// skip trailing whitespaces
.skip_while(|c| *c == ' ' || *c == '\t')
.next()
{
Some('\n') | Some('\r') => {
if !subslice.trim_end().ends_with("*/") {
self.push_str("\n");

View File

@ -0,0 +1,5 @@
/* a nice comment with a trailing whitespace */
fn foo() {}
/* a nice comment with a trailing tab */
fn bar() {}

View File

@ -0,0 +1,5 @@
/* a nice comment with a trailing whitespace */
fn foo() {}
/* a nice comment with a trailing tab */
fn bar() {}