]> git.lizzy.rs Git - rust.git/blob - src/test/compile-fail-fulldeps/qquote.rs
Rollup merge of #51722 - Aaronepower:master, r=Mark-Simulacrum
[rust.git] / src / test / compile-fail-fulldeps / qquote.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-cross-compile
12
13 #![feature(quote, rustc_private)]
14
15 extern crate syntax;
16 extern crate syntax_pos;
17
18 use syntax::ast;
19 use syntax::codemap::FilePathMapping;
20 use syntax::print::pprust;
21 use syntax::symbol::Symbol;
22 use syntax_pos::DUMMY_SP;
23
24 fn main() {
25     let ps = syntax::parse::ParseSess::new(FilePathMapping::empty());
26     let mut resolver = syntax::ext::base::DummyResolver;
27     let mut cx = syntax::ext::base::ExtCtxt::new(
28         &ps,
29         syntax::ext::expand::ExpansionConfig::default("qquote".to_string()),
30         &mut resolver);
31     let cx = &mut cx;
32
33     assert_eq!(pprust::expr_to_string(&*quote_expr!(&cx, 23)), "23");
34
35     let expr = quote_expr!(&cx, 2 - $abcd + 7); //~ ERROR cannot find value `abcd` in this scope
36     assert_eq!(pprust::expr_to_string(&*expr), "2 - $abcd + 7");
37 }