]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail/qquote-2.rs
rollup merge of #18407 : thestinger/arena
[rust.git] / src / test / compile-fail / qquote-2.rs
1 // Copyright 2012-2014 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 // ignore-test Can't use syntax crate here
12
13 #![feature(quote)]
14
15 extern crate syntax;
16
17 use syntax::diagnostic;
18 use syntax::ast;
19 use syntax::codemap;
20 use syntax::parse::parser;
21 use syntax::print::*;
22
23 trait fake_ext_ctxt {
24     fn cfg() -> ast::CrateConfig;
25     fn parse_sess() -> parse::parse_sess;
26     fn call_site() -> span;
27     fn ident_of(st: &str) -> ast::ident;
28 }
29
30 type fake_session = parse::parse_sess;
31
32 impl fake_ext_ctxt for fake_session {
33     fn cfg() -> ast::CrateConfig { Vec::new() }
34     fn parse_sess() -> parse::parse_sess { self }
35     fn call_site() -> span {
36         codemap::span {
37             lo: codemap::BytePos(0),
38             hi: codemap::BytePos(0),
39             expn_id: codemap::NO_EXPANSION
40         }
41     }
42     fn ident_of(st: &str) -> ast::ident {
43         self.interner.intern(st)
44     }
45 }
46
47 fn mk_ctxt() -> fake_ext_ctxt {
48     parse::new_parse_sess(None) as fake_ext_ctxt
49 }
50
51
52 fn main() {
53     let cx = mk_ctxt();
54
55     let stmt = quote_stmt!(cx, let x int = 20;); //~ ERROR expected end-of-string
56     check_pp(*stmt,  pprust::print_stmt, "");
57 }
58
59 fn check_pp<T>(expr: T, f: |pprust::ps, T|, expect: str) {
60     panic!();
61 }