diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 04c3f699cd7..9174bb65b24 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -32,6 +32,7 @@ use std::gc::Gc; pub mod rt { use ast; + use codemap::Spanned; use ext::base::ExtCtxt; use parse::token; use parse; @@ -48,12 +49,25 @@ pub mod rt { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec ; } + impl ToTokens for TokenTree { + fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { + vec!(self.clone()) + } + } + impl ToTokens for Vec { fn to_tokens(&self, _cx: &ExtCtxt) -> Vec { (*self).clone() } } + impl ToTokens for Spanned { + fn to_tokens(&self, cx: &ExtCtxt) -> Vec { + // FIXME: use the span? + self.node.to_tokens(cx) + } + } + /* Should be (when bugs in default methods are fixed): trait ToSource : ToTokens { @@ -121,6 +135,7 @@ pub mod rt { impl_to_source!(Generics, generics_to_str) impl_to_source!(Gc, item_to_str) impl_to_source!(Gc, expr_to_str) + impl_to_source!(Gc, pat_to_str) impl_to_source_slice!(ast::Ty, ", ") impl_to_source_slice!(Gc, "\n\n") @@ -207,6 +222,7 @@ pub mod rt { impl_to_tokens!(ast::Ident) impl_to_tokens!(Gc) + impl_to_tokens!(Gc) impl_to_tokens_lifetime!(&'a [Gc]) impl_to_tokens!(ast::Ty) impl_to_tokens_lifetime!(&'a [ast::Ty])