@@ -32,6 +32,7 @@ use std::gc::Gc;
3232
3333pub mod rt {
3434 use ast;
35+ use codemap:: Spanned ;
3536 use ext:: base:: ExtCtxt ;
3637 use parse:: token;
3738 use parse;
@@ -48,12 +49,25 @@ pub mod rt {
4849 fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > ;
4950 }
5051
52+ impl ToTokens for TokenTree {
53+ fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
54+ vec ! ( self . clone( ) )
55+ }
56+ }
57+
5158 impl ToTokens for Vec < TokenTree > {
5259 fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
5360 ( * self ) . clone ( )
5461 }
5562 }
5663
64+ impl < T : ToTokens > ToTokens for Spanned < T > {
65+ fn to_tokens ( & self , cx : & ExtCtxt ) -> Vec < TokenTree > {
66+ // FIXME: use the span?
67+ self . node . to_tokens ( cx)
68+ }
69+ }
70+
5771 /* Should be (when bugs in default methods are fixed):
5872
5973 trait ToSource : ToTokens {
@@ -121,6 +135,7 @@ pub mod rt {
121135 impl_to_source ! ( Generics , generics_to_str)
122136 impl_to_source ! ( Gc <ast:: Item >, item_to_str)
123137 impl_to_source ! ( Gc <ast:: Expr >, expr_to_str)
138+ impl_to_source ! ( Gc <ast:: Pat >, pat_to_str)
124139 impl_to_source_slice ! ( ast:: Ty , ", " )
125140 impl_to_source_slice ! ( Gc <ast:: Item >, "\n \n " )
126141
@@ -207,6 +222,7 @@ pub mod rt {
207222
208223 impl_to_tokens ! ( ast:: Ident )
209224 impl_to_tokens ! ( Gc <ast:: Item >)
225+ impl_to_tokens ! ( Gc <ast:: Pat >)
210226 impl_to_tokens_lifetime ! ( & ' a [ Gc <ast:: Item >] )
211227 impl_to_tokens ! ( ast:: Ty )
212228 impl_to_tokens_lifetime ! ( & ' a [ ast:: Ty ] )
0 commit comments