Don't pretty-print trailing whitespace for blank lines inside block comments

This commit is contained in:
Brian Anderson 2011-08-18 19:19:38 -07:00
parent 84fb821e40
commit b02f1f46e5
3 changed files with 25 additions and 2 deletions

View File

@ -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);
}
}

View File

@ -0,0 +1,8 @@
// pp-exact
fn f() {
/*
The next line should not be indented.
That one. It shouldn't have been indented.
*/
}

View File

@ -0,0 +1,7 @@
// pp-exact
fn f() {
} /*
The next line should not be indented.
That one. It shouldn't have been indented.
*/