2 #![allow(unused_variables)]
3 #![allow(unused_imports)]
4 // ignore-cross-compile
5 #![feature(quote, rustc_private)]
9 use syntax::ext::base::ExtCtxt;
11 use syntax::parse::PResult;
13 fn syntax_extension(cx: &ExtCtxt) {
14 let e_toks : Vec<syntax::tokenstream::TokenTree> = quote_tokens!(cx, 1 + 2);
15 let p_toks : Vec<syntax::tokenstream::TokenTree> = quote_tokens!(cx, (x, 1 .. 4, *));
17 let a: P<syntax::ast::Expr> = quote_expr!(cx, 1 + 2);
18 let _b: Option<P<syntax::ast::Item>> = quote_item!(cx, static foo : isize = $e_toks; );
19 let _c: P<syntax::ast::Pat> = quote_pat!(cx, (x, 1 .. 4, *) );
20 let _d: Option<syntax::ast::Stmt> = quote_stmt!(cx, let x = $a; );
21 let _d: syntax::ast::Arm = quote_arm!(cx, (ref x, ref y) = (x, y) );
22 let _e: P<syntax::ast::Expr> = quote_expr!(cx, match foo { $p_toks => 10 } );
24 let _f: P<syntax::ast::Expr> = quote_expr!(cx, ());
25 let _g: P<syntax::ast::Expr> = quote_expr!(cx, true);
26 let _h: P<syntax::ast::Expr> = quote_expr!(cx, 'a');
28 let i: Option<P<syntax::ast::Item>> = quote_item!(cx, #[derive(Eq)] struct Foo; );
31 let _l: P<syntax::ast::Ty> = quote_ty!(cx, &isize);
33 let _n: syntax::ast::Attribute = quote_attr!(cx, #![cfg(foo, bar = "baz")]);
35 let _o: Option<P<syntax::ast::Item>> = quote_item!(cx, fn foo<T: ?Sized>() {});
38 quote_stmt!(cx, let x = 1;).unwrap(),
39 quote_stmt!(cx, let y = 2;).unwrap(),
41 let expr: P<syntax::ast::Expr> = quote_expr!(cx, x + y);