rust/src/test/compile-fail/qquote-2.rs
Kevin Atkinson d6d7134c37 When parsing a source string, fail when the entire string is not parsed.
(For now only fail when parse_from_source_str is used to avoid
possible compatibility problems; parse_expr_from_source_str still
does not check.)
2012-02-14 19:37:33 -08:00

49 lines
959 B
Rust

// xfail-pretty
use std;
use rustc;
import rustc::*;
import std::io::*;
import rustc::driver::diagnostic;
import rustc::syntax::ast;
import rustc::syntax::codemap;
import rustc::syntax::parse::parser;
import rustc::syntax::print::*;
fn new_parse_sess() -> parser::parse_sess {
fail;
}
iface fake_ext_ctxt {
fn session() -> fake_session;
}
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 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 stmt = #ast(stmt){let x int = 20;}; //! ERROR expected end-of-string
check_pp(*stmt, pprust::print_stmt, "");
}
fn check_pp<T>(expr: T, f: fn(pprust::ps, T), expect: str) {
fail;
}