Don't pretty-print trailing whitespace for blank lines inside block comments
This commit is contained in:
parent
84fb821e40
commit
b02f1f46e5
@ -1537,7 +1537,12 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
|
||||
}
|
||||
lexer::isolated. {
|
||||
pprust::hardbreak_if_not_bol(s);
|
||||
for line: str in cmnt.lines { word(s.s, line); hardbreak(s.s); }
|
||||
for line: str in cmnt.lines {
|
||||
// Don't print empty lines because they will end up as trailing
|
||||
// whitespace
|
||||
if str::is_not_empty(line) { word(s.s, line); }
|
||||
hardbreak(s.s);
|
||||
}
|
||||
}
|
||||
lexer::trailing. {
|
||||
word(s.s, " ");
|
||||
@ -1546,7 +1551,10 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
|
||||
hardbreak(s.s);
|
||||
} else {
|
||||
ibox(s, 0u);
|
||||
for line: str in cmnt.lines { word(s.s, line); hardbreak(s.s); }
|
||||
for line: str in cmnt.lines {
|
||||
if str::is_not_empty(line) { word(s.s, line); }
|
||||
hardbreak(s.s);
|
||||
}
|
||||
end(s);
|
||||
}
|
||||
}
|
||||
|
8
src/test/pretty/block-comment-trailing-whitespace.rs
Normal file
8
src/test/pretty/block-comment-trailing-whitespace.rs
Normal file
@ -0,0 +1,8 @@
|
||||
// pp-exact
|
||||
fn f() {
|
||||
/*
|
||||
The next line should not be indented.
|
||||
|
||||
That one. It shouldn't have been indented.
|
||||
*/
|
||||
}
|
7
src/test/pretty/block-comment-trailing-whitespace2.rs
Normal file
7
src/test/pretty/block-comment-trailing-whitespace2.rs
Normal file
@ -0,0 +1,7 @@
|
||||
// pp-exact
|
||||
fn f() {
|
||||
} /*
|
||||
The next line should not be indented.
|
||||
|
||||
That one. It shouldn't have been indented.
|
||||
*/
|
Loading…
Reference in New Issue
Block a user