Don't pp extra lines after block open when preserving whitespace. Closes #759

This commit is contained in:
Brian Anderson 2011-08-02 15:25:06 -07:00
parent 731797d075
commit 3eef9993af
10 changed files with 23 additions and 8 deletions

View File

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

View File

@ -1,4 +1,3 @@
// xfail-pretty
// -*- rust -*-

View File

@ -1,4 +1,3 @@
// xfail-pretty
// based on:
// http://shootout.alioth.debian.org/u32/benchmark.php?test=nbody&lang=java

View File

@ -1,4 +1,3 @@
// xfail-pretty
/**
A parallel word-frequency counting program.

View File

@ -0,0 +1,7 @@
// Issue #759
// Whitespace under block opening should not expand forever
fn a() -> uint {
1u
}

View File

@ -1,4 +1,3 @@
// xfail-pretty
/**
A somewhat reduced test case to expose some Valgrind issues.

View File

@ -1,4 +1,5 @@
// xfail-stage0
// xfail-pretty
import rusti::ivec_len;

View File

@ -1,5 +1,4 @@
// xfail-stage0
// xfail-pretty
use std;
import std::ivec;

View File

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

View File

@ -1,4 +1,3 @@
// xfail-pretty
tag t { a; b(str); }