Fix fallout in macro_crate/quote tests.

This commit is contained in:
Eduard Burtescu 2014-09-12 02:33:08 +03:00
parent 5b2837b918
commit 8577343f9e
2 changed files with 15 additions and 16 deletions

View File

@ -20,10 +20,9 @@ use syntax::codemap::Span;
use syntax::ext::base::*;
use syntax::parse::token;
use syntax::parse;
use syntax::ptr::P;
use rustc::plugin::Registry;
use std::gc::{Gc, GC};
#[macro_export]
macro_rules! exported_macro (() => (2i))
@ -57,12 +56,12 @@ fn expand_identity(cx: &mut ExtCtxt, _span: Span, tts: &[TokenTree])
MacExpr::new(quote_expr!(&mut *cx, $expr))
}
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: Gc<MetaItem>, it: Gc<Item>)
-> Gc<Item> {
box(GC) Item {
fn expand_into_foo(cx: &mut ExtCtxt, sp: Span, attr: &MetaItem, it: P<Item>)
-> P<Item> {
P(Item {
attrs: it.attrs.clone(),
..(*quote_item!(cx, enum Foo { Bar, Baz }).unwrap()).clone()
}
})
}
fn expand_forged_ident(cx: &mut ExtCtxt, sp: Span, tts: &[TokenTree]) -> Box<MacResult+'static> {

View File

@ -16,24 +16,24 @@
extern crate syntax;
use syntax::ext::base::ExtCtxt;
use std::gc::Gc;
use syntax::ptr::P;
fn syntax_extension(cx: &ExtCtxt) {
let e_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, 1 + 2);
let p_toks : Vec<syntax::ast::TokenTree> = quote_tokens!(cx, (x, 1 .. 4, *));
let a: Gc<syntax::ast::Expr> = quote_expr!(cx, 1 + 2);
let _b: Option<Gc<syntax::ast::Item>> = quote_item!(cx, static foo : int = $e_toks; );
let _c: Gc<syntax::ast::Pat> = quote_pat!(cx, (x, 1 .. 4, *) );
let _d: Gc<syntax::ast::Stmt> = quote_stmt!(cx, let x = $a; );
let a: P<syntax::ast::Expr> = quote_expr!(cx, 1 + 2);
let _b: Option<P<syntax::ast::Item>> = quote_item!(cx, static foo : int = $e_toks; );
let _c: P<syntax::ast::Pat> = quote_pat!(cx, (x, 1 .. 4, *) );
let _d: P<syntax::ast::Stmt> = quote_stmt!(cx, let x = $a; );
let _d: syntax::ast::Arm = quote_arm!(cx, (ref x, ref y) = (x, y) );
let _e: Gc<syntax::ast::Expr> = quote_expr!(cx, match foo { $p_toks => 10 } );
let _e: P<syntax::ast::Expr> = quote_expr!(cx, match foo { $p_toks => 10 } );
let _f: Gc<syntax::ast::Expr> = quote_expr!(cx, ());
let _g: Gc<syntax::ast::Expr> = quote_expr!(cx, true);
let _h: Gc<syntax::ast::Expr> = quote_expr!(cx, 'a');
let _f: P<syntax::ast::Expr> = quote_expr!(cx, ());
let _g: P<syntax::ast::Expr> = quote_expr!(cx, true);
let _h: P<syntax::ast::Expr> = quote_expr!(cx, 'a');
let i: Option<Gc<syntax::ast::Item>> = quote_item!(cx, #[deriving(Eq)] struct Foo; );
let i: Option<P<syntax::ast::Item>> = quote_item!(cx, #[deriving(Eq)] struct Foo; );
assert!(i.is_some());
}