@@ -32,6 +32,7 @@ use std::gc::Gc;
32
32
33
33
pub mod rt {
34
34
use ast;
35
+ use codemap:: Spanned ;
35
36
use ext:: base:: ExtCtxt ;
36
37
use parse:: token;
37
38
use parse;
@@ -48,12 +49,25 @@ pub mod rt {
48
49
fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > ;
49
50
}
50
51
52
+ impl ToTokens for TokenTree {
53
+ fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
54
+ vec ! ( self . clone( ) )
55
+ }
56
+ }
57
+
51
58
impl ToTokens for Vec < TokenTree > {
52
59
fn to_tokens ( & self , _cx : & ExtCtxt ) -> Vec < TokenTree > {
53
60
( * self ) . clone ( )
54
61
}
55
62
}
56
63
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
+
57
71
/* Should be (when bugs in default methods are fixed):
58
72
59
73
trait ToSource : ToTokens {
@@ -121,6 +135,7 @@ pub mod rt {
121
135
impl_to_source ! ( Generics , generics_to_str)
122
136
impl_to_source ! ( Gc <ast:: Item >, item_to_str)
123
137
impl_to_source ! ( Gc <ast:: Expr >, expr_to_str)
138
+ impl_to_source ! ( Gc <ast:: Pat >, pat_to_str)
124
139
impl_to_source_slice ! ( ast:: Ty , ", " )
125
140
impl_to_source_slice ! ( Gc <ast:: Item >, "\n \n " )
126
141
@@ -207,6 +222,7 @@ pub mod rt {
207
222
208
223
impl_to_tokens ! ( ast:: Ident )
209
224
impl_to_tokens ! ( Gc <ast:: Item >)
225
+ impl_to_tokens ! ( Gc <ast:: Pat >)
210
226
impl_to_tokens_lifetime ! ( & ' a [ Gc <ast:: Item >] )
211
227
impl_to_tokens ! ( ast:: Ty )
212
228
impl_to_tokens_lifetime ! ( & ' a [ ast:: Ty ] )
0 commit comments