Skip to content

Commit 0739a97

Browse files
committed
---
yaml --- r: 2855 b: refs/heads/master c: 1676c67 h: refs/heads/master i: 2853: a5023be 2851: 1ebf45d 2847: e06fb18 v: v3
1 parent d05b04c commit 0739a97

File tree

3 files changed

+23
-23
lines changed

3 files changed

+23
-23
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: cf57553679b59bc90caa3632762b8beda1896f9d
2+
refs/heads/master: 1676c6744643cf7169250fbba242d65eb73edd8a

trunk/src/comp/pretty/pp.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ fn eof(printer p) { p.pretty_print(EOF); }
547547
fn word(printer p, str wrd) {
548548
p.pretty_print(STRING(wrd, str::char_len(wrd) as int));
549549
}
550-
fn word_and_eol(printer p, str wrd) {
550+
fn huge_word(printer p, str wrd) {
551551
p.pretty_print(STRING(wrd, 0xffff));
552552
}
553553
fn spaces(printer p, uint n) { break_offset(p, n, 0); }

trunk/src/comp/pretty/pprust.rs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import pp::box;
1717
import pp::cbox;
1818
import pp::ibox;
1919
import pp::word;
20-
import pp::word_and_eol;
20+
import pp::huge_word;
2121
import pp::space;
2222
import pp::zerobreak;
2323
import pp::hardbreak;
@@ -152,7 +152,8 @@ fn commasep_cmnt[IN](ps s, breaks b, vec[IN] elts, fn(ps, &IN) op,
152152
i += 1u;
153153
if (i < len) {
154154
word(s.s, ",");
155-
if (!maybe_print_line_comment(s, get_span(elt))) {space(s.s);}
155+
maybe_print_trailing_comment(s, get_span(elt));
156+
space(s.s);
156157
}
157158
}
158159
end(s.s);
@@ -350,7 +351,7 @@ fn print_item(ps s, @ast::item item) {
350351
pclose(s);
351352
}
352353
word(s.s, ";");
353-
maybe_print_line_comment(s, v.span);
354+
maybe_print_trailing_comment(s, v.span);
354355
}
355356
bclose(s, item.span);
356357
}
@@ -409,13 +410,13 @@ fn print_block(ps s, ast::block blk) {
409410
}
410411
}
411412
if (front::parser::stmt_ends_with_semi(st)) {word(s.s, ";");}
412-
maybe_print_line_comment(s, st.span);
413+
maybe_print_trailing_comment(s, st.span);
413414
}
414415
alt (blk.node.expr) {
415416
case (option::some[@ast::expr](?expr)) {
416417
space(s.s);
417418
print_expr(s, expr);
418-
maybe_print_line_comment(s, expr.span);
419+
maybe_print_trailing_comment(s, expr.span);
419420
}
420421
case (_) {}
421422
}
@@ -1105,32 +1106,28 @@ fn maybe_print_comment(ps s, uint pos) {
11051106
}
11061107
}
11071108

1108-
fn maybe_print_line_comment(ps s, common::span span) -> bool {
1109+
fn maybe_print_trailing_comment(ps s, common::span span) {
11091110
auto cm;
11101111
alt (s.cm) {
11111112
case (option::some[codemap](?ccm)) {
11121113
cm = ccm;
11131114
}
1114-
case (_) {
1115-
ret false;
1116-
}
1115+
case (_) { ret; }
11171116
}
11181117
alt (next_comment(s)) {
11191118
case (option::some[lexer::cmnt](?cmnt)) {
1120-
if (cmnt.style != lexer::trailing) { ret false; }
1119+
if (cmnt.style != lexer::trailing) { ret; }
11211120

11221121
auto span_line = codemap::lookup_pos(cm, span.hi);
11231122
auto comment_line = codemap::lookup_pos(cm, cmnt.pos);
11241123
if (span_line.line == comment_line.line) {
11251124
word(s.s, " ");
11261125
print_comment(s, cmnt);
11271126
s.cur_cmnt += 1u;
1128-
ret true;
11291127
}
11301128
}
11311129
case (_) {}
11321130
}
1133-
ret false;
11341131
}
11351132

11361133
fn print_remaining_comments(ps s) {
@@ -1148,21 +1145,24 @@ fn print_remaining_comments(ps s) {
11481145
fn print_comment(ps s, lexer::cmnt cmnt) {
11491146
alt (cmnt.style) {
11501147
case (lexer::isolated) {
1151-
zerobreak(s.s);
1148+
hardbreak(s.s);
11521149
for (str line in cmnt.lines) {
1153-
word_and_eol(s.s, line);
1150+
huge_word(s.s, line);
11541151
zerobreak(s.s);
11551152
}
1156-
zerobreak(s.s);
11571153
}
11581154
case (lexer::trailing) {
1159-
cbox(s.s, 0u);
1160-
for (str line in cmnt.lines) {
1161-
word_and_eol(s.s, line);
1162-
zerobreak(s.s);
1155+
if (vec::len(cmnt.lines) == 1u) {
1156+
word(s.s, cmnt.lines.(0));
1157+
hardbreak(s.s);
1158+
} else {
1159+
cbox(s.s, 0u);
1160+
for (str line in cmnt.lines) {
1161+
huge_word(s.s, line);
1162+
zerobreak(s.s);
1163+
}
1164+
end(s.s);
11631165
}
1164-
end(s.s);
1165-
zerobreak(s.s);
11661166
}
11671167
case (lexer::mixed) {
11681168
assert vec::len(cmnt.lines) == 1u;

0 commit comments

Comments
 (0)