diff --git a/src/fuzzer/fuzzer.rs b/src/fuzzer/fuzzer.rs index d99a40018f1..72f7ac493b8 100644 --- a/src/fuzzer/fuzzer.rs +++ b/src/fuzzer/fuzzer.rs @@ -274,7 +274,8 @@ fn check_variants_T( crate2, filename, io::str_reader(""), a, - pprust::no_ann())}); + pprust::no_ann(), + false)}); alt cx.mode { tm_converge { check_roundtrip_convergence(str3, 1u); @@ -422,11 +423,12 @@ fn parse_and_print(code: @str) -> str { filename, code, []/~, sess); io::with_str_reader(*code) { |rdr| as_str({|a|pprust::print_crate(sess.cm, - sess.span_diagnostic, - crate, - filename, - rdr, a, - pprust::no_ann())}) + sess.span_diagnostic, + crate, + filename, + rdr, a, + pprust::no_ann(), + false)}) } } @@ -566,11 +568,12 @@ fn check_variants(files: [str]/~, cx: context) { io::with_str_reader(*s) { |rdr| #error("%s", as_str({|a|pprust::print_crate(sess.cm, - sess.span_diagnostic, - crate, - file, - rdr, a, - pprust::no_ann())})); + sess.span_diagnostic, + crate, + file, + rdr, a, + pprust::no_ann(), + false)})); } check_variants_of_ast(*crate, sess.cm, file, cx); } diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index bce360c52f9..833da64af79 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -64,14 +64,17 @@ const default_columns: uint = 78u; // copy forward. fn print_crate(cm: codemap, span_diagnostic: diagnostic::span_handler, crate: @ast::crate, filename: str, in: io::reader, - out: io::writer, ann: pp_ann) { + out: io::writer, ann: pp_ann, is_expanded: bool) { let r = comments::gather_comments_and_literals(span_diagnostic, filename, in); let s = @{s: pp::mk_printer(out, default_columns), cm: some(cm), comments: some(r.cmnts), - literals: some(r.lits), + // If the code is post expansion, don't use the table of + // literals, since it doesn't correspond with the literals + // in the AST anymore. + literals: if is_expanded { none } else { some(r.lits) }, mut cur_cmnt: 0u, mut cur_lit: 0u, boxes: dvec(), diff --git a/src/rustc/driver/driver.rs b/src/rustc/driver/driver.rs index 13c0035011c..0b9490c9baa 100644 --- a/src/rustc/driver/driver.rs +++ b/src/rustc/driver/driver.rs @@ -310,22 +310,22 @@ fn pretty_print_input(sess: session, cfg: ast::crate_cfg, input: input, }; let {crate, tcx} = compile_upto(sess, cfg, input, upto, none); - let mut ann: pprust::pp_ann = pprust::no_ann(); - alt ppm { + let ann = alt ppm { ppm_typed { - ann = {pre: ann_paren_for_expr, - post: {|a|ann_typed_post(option::get(tcx), a)}}; + {pre: ann_paren_for_expr, + post: {|a|ann_typed_post(option::get(tcx), a)}} } ppm_identified | ppm_expanded_identified { - ann = {pre: ann_paren_for_expr, post: ann_identified_post}; + {pre: ann_paren_for_expr, post: ann_identified_post} } - ppm_expanded | ppm_normal {} - } + ppm_expanded | ppm_normal { pprust::no_ann() } + }; + let is_expanded = upto != cu_parse; let src = codemap::get_filemap(sess.codemap, source_name(input)).src; io::with_str_reader(*src) { |rdr| pprust::print_crate(sess.codemap, sess.span_diagnostic, crate, source_name(input), - rdr, io::stdout(), ann); + rdr, io::stdout(), ann, is_expanded); } }