Skip to content

Commit b955833

Browse files
committed
---
yaml --- r: 149675 b: refs/heads/try2 c: 0e1a860 h: refs/heads/master i: 149673: 983a74e 149671: f560c95 v: v3
1 parent b4821de commit b955833

File tree

5 files changed

+34
-6
lines changed

5 files changed

+34
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 324547140e0b67b109b43dfa79cc39cdf06151e5
8+
refs/heads/try2: 0e1a860789896fd2e6331648f1268c5b2cdb3573
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/librustdoc/core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ fn get_ast_and_resolve(cpath: &Path,
5858
};
5959

6060

61-
let diagnostic_handler = syntax::diagnostic::mk_handler();
61+
let diagnostic_handler = syntax::diagnostic::default_handler();
6262
let span_diagnostic_handler =
6363
syntax::diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm);
6464

branches/try2/src/librustdoc/html/highlight.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ use t = syntax::parse::token;
2828
/// Highlights some source code, returning the HTML output.
2929
pub fn highlight(src: &str) -> ~str {
3030
let sess = parse::new_parse_sess();
31-
let handler = diagnostic::mk_handler();
31+
let handler = diagnostic::default_handler();
3232
let span_handler = diagnostic::mk_span_handler(handler, sess.cm);
3333
let fm = parse::string_to_filemap(sess, src.to_owned(), ~"<stdin>");
3434

branches/try2/src/librustdoc/test.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ pub fn run(input: &str, matches: &getopts::Matches) -> int {
5050

5151

5252
let cm = @CodeMap::new();
53-
let diagnostic_handler = diagnostic::mk_handler();
53+
let diagnostic_handler = diagnostic::default_handler();
5454
let span_diagnostic_handler =
5555
diagnostic::mk_span_handler(diagnostic_handler, cm);
5656
let parsesess = parse::new_parse_sess_special_handler(span_diagnostic_handler,
@@ -115,7 +115,30 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool)
115115
.. (*session::basic_options()).clone()
116116
};
117117

118-
let diagnostic_handler = diagnostic::mk_handler();
118+
// Shuffle around a few input and output handles here. We're going to pass
119+
// an explicit handle into rustc to collect output messages, but we also
120+
// want to catch the error message that rustc prints when it fails.
121+
//
122+
// We take our task-local stderr (likely set by the test runner), and move
123+
// it into another task. This helper task then acts as a sink for both the
124+
// stderr of this task and stderr of rustc itself, copying all the info onto
125+
// the stderr channel we originally started with.
126+
//
127+
// The basic idea is to not use a default_handler() for rustc, and then also
128+
// not print things by default to the actual stderr.
129+
let (p, c) = Chan::new();
130+
let w1 = io::ChanWriter::new(c);
131+
let w2 = w1.clone();
132+
let old = io::stdio::set_stderr(~w1);
133+
spawn(proc() {
134+
let mut p = io::PortReader::new(p);
135+
let mut err = old.unwrap_or(~io::stderr() as ~Writer);
136+
io::util::copy(&mut p, &mut err).unwrap();
137+
});
138+
let emitter = diagnostic::EmitterWriter::new(~w2);
139+
140+
// Compile the code
141+
let diagnostic_handler = diagnostic::mk_handler(~emitter);
119142
let span_diagnostic_handler =
120143
diagnostic::mk_span_handler(diagnostic_handler, parsesess.cm);
121144

@@ -129,6 +152,7 @@ fn runtest(test: &str, cratename: &str, libs: HashSet<Path>, should_fail: bool)
129152
let cfg = driver::build_configuration(sess);
130153
driver::compile_input(sess, cfg, &input, &out, &None);
131154

155+
// Run the code!
132156
let exe = outdir.path().join("rust_out");
133157
let out = Process::output(exe.as_str().unwrap(), []);
134158
match out {

branches/try2/src/libsyntax/parse/lexer.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1004,6 +1004,7 @@ mod test {
10041004
use diagnostic;
10051005
use parse::token;
10061006
use parse::token::{str_to_ident};
1007+
use std::io::util;
10071008

10081009
// represents a testing reader (incl. both reader and interner)
10091010
struct Env {
@@ -1014,7 +1015,10 @@ mod test {
10141015
fn setup(teststr: ~str) -> Env {
10151016
let cm = CodeMap::new();
10161017
let fm = cm.new_filemap(~"zebra.rs", teststr);
1017-
let span_handler = diagnostic::mk_span_handler(diagnostic::mk_handler(), @cm);
1018+
let writer = ~util::NullWriter;
1019+
let emitter = diagnostic::EmitterWriter::new(writer);
1020+
let handler = diagnostic::mk_handler(~emitter);
1021+
let span_handler = diagnostic::mk_span_handler(handler, @cm);
10181022
Env {
10191023
string_reader: new_string_reader(span_handler,fm)
10201024
}

0 commit comments

Comments
 (0)