提交 97cf57ad 编写于 作者: G Graydon Hoare

Fix pp blank-lines insertion at beginning of file and before 'let' decls.

上级 200dbe4c
// trans.rs: Translate the completed AST to the LLVM IR.
//
// Some functions here, such as trans_block and trans_expr, return a value --
......
......@@ -235,7 +235,7 @@ fn print_comment(&ps s, lexer::cmnt cmnt) {
zerobreak(s.s);
}
case (lexer::isolated) {
hardbreak(s.s);
pprust::hardbreak_if_not_eof(s);
for (str line in cmnt.lines) { word(s.s, line); hardbreak(s.s); }
}
case (lexer::trailing) {
......
......@@ -120,6 +120,12 @@ fn bclose(&ps s, common::span span) {
}
fn hardbreak_if_not_eof(&ps s) {
if (s.s.last_token() != pp::EOF) {
hardbreak(s.s);
}
}
fn space_if_not_hardbreak(&ps s) {
if (s.s.last_token() != pp::hardbreak_tok()) {
space(s.s);
......@@ -177,7 +183,7 @@ fn print_mod(&ps s, ast::_mod _mod) {
for (@ast::item item in _mod.items) {
// Mod-level item printing we're a little more space-y about.
hardbreak(s.s);
hardbreak_if_not_eof(s);
print_item(s, item);
}
print_remaining_comments(s);
......@@ -265,7 +271,7 @@ fn print_field(&ps s, &ast::ty_field f) {
}
fn print_item(&ps s, &@ast::item item) {
hardbreak(s.s);
hardbreak_if_not_eof(s);
maybe_print_comment(s, item.span.lo);
print_outer_attributes(s, item.attrs);
alt (item.node) {
......@@ -867,7 +873,7 @@ fn print_decl(&ps s, &@ast::decl decl) {
maybe_print_comment(s, decl.span.lo);
alt (decl.node) {
case (ast::decl_local(?loc)) {
space(s.s);
space_if_not_hardbreak(s);
ibox(s, indent_unit);
alt (loc.node.ty) {
case (some(?ty)) {
......@@ -985,7 +991,7 @@ fn print_arg(&ps s, &ast::arg x) {
pclose(s);
maybe_print_comment(s, decl.output.span.lo);
if (decl.output.node != ast::ty_nil) {
space(s.s);
space_if_not_hardbreak(s);
word_space(s, "->");
print_type(s, *decl.output);
}
......@@ -1017,7 +1023,7 @@ fn print_meta_item(&ps s, &@ast::meta_item item) {
}
fn print_view_item(&ps s, &@ast::view_item item) {
hardbreak(s.s);
hardbreak_if_not_eof(s);
maybe_print_comment(s, item.span.lo);
alt (item.node) {
case (ast::view_item_use(?id, ?mta, _, _)) {
......@@ -1122,7 +1128,7 @@ fn print_arg(&ps s, &ast::ty_arg input) {
pclose(s);
maybe_print_comment(s, output.span.lo);
if (output.node != ast::ty_nil) {
space(s.s);
space_if_not_hardbreak(s);
ibox(s, indent_unit);
word_space(s, "->");
alt (cf) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册