Skip to content

Commit 54d5a98

Browse files
committed
Try to fix pretty-printer failure
I can't reproduce it on my side, unfortunately.
1 parent 08c16b1 commit 54d5a98

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/comp/driver/driver.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -81,22 +81,21 @@ fn parse_input(sess: session, cfg: ast::crate_cfg, input: str) ->
8181
if !input_is_stdin(input) {
8282
parser::parse_crate_from_file(input, cfg, sess.parse_sess)
8383
} else {
84-
let srcbytes = get_input_stream(sess, input).read_whole_stream();
85-
let srcstring = str::unsafe_from_bytes(srcbytes);
86-
parser::parse_crate_from_source_str(input, srcstring, cfg,
87-
sess.parse_sess)
84+
let src = get_input_str(sess, input);
85+
parser::parse_crate_from_source_str(input, src, cfg, sess.parse_sess)
8886
}
8987
}
9088

91-
fn get_input_stream(sess: session, infile: str) -> io::reader {
92-
if !input_is_stdin(infile) {
89+
fn get_input_str(sess: session, infile: str) -> str {
90+
let stream = if !input_is_stdin(infile) {
9391
alt io::file_reader(infile) {
9492
result::ok(reader) { reader }
9593
result::err(e) {
9694
sess.fatal(e)
9795
}
9896
}
99-
} else { io::stdin() }
97+
} else { io::stdin() };
98+
str::unsafe_from_bytes(stream.read_whole_stream())
10099
}
101100

102101
fn time<T>(do_it: bool, what: str, thunk: fn@() -> T) -> T {
@@ -285,7 +284,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
285284
_ { cu_parse }
286285
};
287286
let {crate, tcx} = compile_upto(sess, cfg, input, upto, none);
288-
let src = get_input_stream(sess, input);
287+
let src = get_input_str(sess, input);
289288

290289
let ann: pprust::pp_ann = pprust::no_ann();
291290
alt ppm {
@@ -299,7 +298,7 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
299298
ppm_expanded. | ppm_normal. {}
300299
}
301300
pprust::print_crate(sess.codemap, sess.diagnostic, crate, input,
302-
src, io::stdout(), ann);
301+
io::string_reader(src), io::stdout(), ann);
303302
}
304303

305304
fn get_os(triple: str) -> option<session::os> {

0 commit comments

Comments
 (0)