Skip to content

Commit 3cb2cd1

Browse files
committed
comp/fuzzer: rewrite to use io::with_str_reader.
1 parent f630ebd commit 3cb2cd1

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

src/fuzzer/fuzzer.rs

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -412,12 +412,14 @@ fn parse_and_print(code: @str) -> str {
412412
write_file(filename, *code);
413413
let crate = parser::parse_crate_from_source_str(
414414
filename, code, [], sess);
415-
ret as_str(bind pprust::print_crate(sess.cm,
415+
io::with_str_reader(*code) { |rdr|
416+
as_str(bind pprust::print_crate(sess.cm,
416417
sess.span_diagnostic,
417418
crate,
418419
filename,
419-
io::str_reader(*code), _,
420-
pprust::no_ann()));
420+
rdr, _,
421+
pprust::no_ann()))
422+
}
421423
}
422424

423425
fn has_raw_pointers(c: ast::crate) -> bool {
@@ -557,13 +559,15 @@ fn check_variants(files: [str], cx: context) {
557559
parser::parse_crate_from_source_str(
558560
file,
559561
s, [], sess);
560-
#error("%s",
561-
as_str(bind pprust::print_crate(sess.cm,
562-
sess.span_diagnostic,
563-
crate,
564-
file,
565-
io::str_reader(*s), _,
566-
pprust::no_ann())));
562+
io::with_str_reader(*s) { |rdr|
563+
#error("%s",
564+
as_str(bind pprust::print_crate(sess.cm,
565+
sess.span_diagnostic,
566+
crate,
567+
file,
568+
rdr, _,
569+
pprust::no_ann())));
570+
}
567571
check_variants_of_ast(*crate, sess.cm, file, cx);
568572
}
569573
}

src/rustc/driver/driver.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,8 +272,10 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: str,
272272
ppm_expanded | ppm_normal {}
273273
}
274274
let src = codemap::get_filemap(sess.codemap, input).src;
275-
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input,
276-
io::str_reader(*src), io::stdout(), ann);
275+
io::with_str_reader(*src) { |rdr|
276+
pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, input,
277+
rdr, io::stdout(), ann);
278+
}
277279
}
278280

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

0 commit comments

Comments
 (0)