Skip to content

Commit

Permalink
Don't pp extra lines after block open when preserving whitespace. Closes
Browse files Browse the repository at this point in the history
  • Loading branch information
brson committed Aug 3, 2011
1 parent 731797d commit 3eef999
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 8 deletions.
16 changes: 15 additions & 1 deletion src/comp/syntax/print/pprust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,20 @@ fn bclose_(s: &ps, span: codemap::span, indented: uint) {
}
fn bclose(s: &ps, span: codemap::span) { bclose_(s, span, indent_unit); }

fn is_begin(s: &ps) -> bool {
alt s.s.last_token() {
pp::BEGIN(_) { true }
_ { false }
}
}

fn is_end(s: &ps) -> bool {
alt s.s.last_token() {
pp::END. { true }
_ { false }
}
}

fn is_bol(s: &ps) -> bool {
ret s.s.last_token() == pp::EOF ||
s.s.last_token() == pp::hardbreak_tok();
Expand Down Expand Up @@ -1403,7 +1417,7 @@ fn print_comment(s: &ps, cmnt: lexer::cmnt) {
}
lexer::blank_line. {
// We need to do at least one, possibly two hardbreaks.
pprust::hardbreak_if_not_bol(s);
if is_begin(s) || is_end(s) { hardbreak(s.s) }
hardbreak(s.s);
}
}
Expand Down
1 change: 0 additions & 1 deletion src/test/bench/shootout-fibo.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-pretty


// -*- rust -*-
Expand Down
1 change: 0 additions & 1 deletion src/test/bench/shootout-nbody.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-pretty
// based on:
// http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java

Expand Down
1 change: 0 additions & 1 deletion src/test/bench/task-perf-word-count.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-pretty
/**
A parallel word-frequency counting program.
Expand Down
7 changes: 7 additions & 0 deletions src/test/pretty/empty-lines.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Issue #759
// Whitespace under block opening should not expand forever

fn a() -> uint {

1u
}
1 change: 0 additions & 1 deletion src/test/run-pass/hashmap-memory.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-pretty
/**
A somewhat reduced test case to expose some Valgrind issues.
Expand Down
1 change: 1 addition & 0 deletions src/test/run-pass/interior-vec.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// xfail-stage0
// xfail-pretty

import rusti::ivec_len;

Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/issue-687.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// xfail-stage0
// xfail-pretty

use std;
import std::ivec;
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/pattern-bound-var-in-for-each.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// xfail-stage0
// xfail-pretty
// Tests that trans_path checks whether a
// pattern-bound var is an upvar (when translating
// the for-each body)
Expand Down
1 change: 0 additions & 1 deletion src/test/run-pass/while-prelude-drop.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// xfail-pretty

tag t { a; b(str); }

Expand Down

0 comments on commit 3eef999

Please sign in to comment.