rust/src/test/run-pass-fulldeps/issue-1926.rs

53 lines
1.3 KiB
Rust
Raw Normal View History

// xfail-test
// fails pretty printing for some reason
use syntax;
2012-09-05 14:32:05 -05:00
use syntax::diagnostic;
use syntax::ast;
use syntax::codemap;
use syntax::print::pprust;
use syntax::parse::parser;
fn new_parse_sess() -> parser::parse_sess {
let cm = codemap::new_codemap();
let handler = diagnostic::mk_handler(option::none);
let sess = @{
cm: cm,
mut next_id: 1,
span_diagnostic: diagnostic::mk_span_handler(handler, cm),
mut chpos: 0u,
mut byte_pos: 0u
};
2012-08-01 19:30:05 -05:00
return sess;
}
trait fake_ext_ctxt {
fn session() -> fake_session;
fn cfg() -> ast::crate_cfg;
fn parse_sess() -> parser::parse_sess;
}
type fake_options = {cfg: ast::crate_cfg};
type fake_session = {opts: @fake_options,
parse_sess: parser::parse_sess};
impl of fake_ext_ctxt for fake_session {
fn session() -> fake_session {self}
fn cfg() -> ast::crate_cfg { self.opts.cfg }
fn parse_sess() -> parser::parse_sess { self.parse_sess }
}
fn mk_ctxt() -> fake_ext_ctxt {
let opts : fake_options = {cfg: ~[]};
{opts: @opts, parse_sess: new_parse_sess()} as fake_ext_ctxt
}
fn main() {
let ext_cx = mk_ctxt();
let s = #ast[expr]{__s};
let e = #ast[expr]{__e};
let f = #ast[expr]{$(s).foo {|__e| $(e)}};
log(error, pprust::expr_to_str(f));
}