Skip to content

Commit 3eef999

Browse files
committed
Don't pp extra lines after block open when preserving whitespace. Closes rust-lang#759
1 parent 731797d commit 3eef999

File tree

10 files changed

+23
-8
lines changed

10 files changed

+23
-8
lines changed

src/comp/syntax/print/pprust.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,20 @@ fn bclose_(s: &ps, span: codemap::span, indented: uint) {
172172
}
173173
fn bclose(s: &ps, span: codemap::span) { bclose_(s, span, indent_unit); }
174174

175+
fn is_begin(s: &ps) -> bool {
176+
alt s.s.last_token() {
177+
pp::BEGIN(_) { true }
178+
_ { false }
179+
}
180+
}
181+
182+
fn is_end(s: &ps) -> bool {
183+
alt s.s.last_token() {
184+
pp::END. { true }
185+
_ { false }
186+
}
187+
}
188+
175189
fn is_bol(s: &ps) -> bool {
176190
ret s.s.last_token() == pp::EOF ||
177191
s.s.last_token() == pp::hardbreak_tok();
@@ -1403,7 +1417,7 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
14031417
}
14041418
lexer::blank_line. {
14051419
// We need to do at least one, possibly two hardbreaks.
1406-
pprust::hardbreak_if_not_bol(s);
1420+
if is_begin(s) || is_end(s) { hardbreak(s.s) }
14071421
hardbreak(s.s);
14081422
}
14091423
}

src/test/bench/shootout-fibo.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-pretty
21

32

43
// -*- rust -*-

src/test/bench/shootout-nbody.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-pretty
21
// based on:
32
// http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java
43

src/test/bench/task-perf-word-count.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-pretty
21
/**
32
A parallel word-frequency counting program.
43

src/test/pretty/empty-lines.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// Issue #759
2+
// Whitespace under block opening should not expand forever
3+
4+
fn a() -> uint {
5+
6+
1u
7+
}

src/test/run-pass/hashmap-memory.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-pretty
21
/**
32
A somewhat reduced test case to expose some Valgrind issues.
43

src/test/run-pass/interior-vec.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
// xfail-stage0
2+
// xfail-pretty
23

34
import rusti::ivec_len;
45

src/test/run-pass/issue-687.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// xfail-stage0
2-
// xfail-pretty
32

43
use std;
54
import std::ivec;

src/test/run-pass/pattern-bound-var-in-for-each.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// xfail-stage0
2-
// xfail-pretty
32
// Tests that trans_path checks whether a
43
// pattern-bound var is an upvar (when translating
54
// the for-each body)

src/test/run-pass/while-prelude-drop.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// xfail-pretty
21

32
tag t { a; b(str); }
43

0 commit comments

Comments
 (0)