diff options
| author | Huon Wilson <dbau.pp+github@gmail.com> | 2014-05-01 23:39:00 +1000 |
|---|---|---|
| committer | Huon Wilson <dbau.pp+github@gmail.com> | 2014-05-02 22:54:55 +1000 |
| commit | 1d43a98deadf9d1866d99e253db14651c36726e3 (patch) | |
| tree | 6e087689d8f77021267368459d81de613c060bfb /src/libsyntax | |
| parent | 5c424ba34ad8b45cfba4619832d23b0278ede696 (diff) | |
| download | rust-1d43a98deadf9d1866d99e253db14651c36726e3.tar.gz rust-1d43a98deadf9d1866d99e253db14651c36726e3.zip | |
syntax: implement ToSource for more things in the quasiquoter.
The last few primitive types were missing.
Diffstat (limited to 'src/libsyntax')
| -rw-r--r-- | src/libsyntax/ext/quote.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs index 68b0ef40b16..fc7f7722354 100644 --- a/src/libsyntax/ext/quote.rs +++ b/src/libsyntax/ext/quote.rs @@ -125,6 +125,26 @@ pub mod rt { } } + impl ToSource for () { + fn to_source(&self) -> ~str { + "()".to_owned() + } + } + + impl ToSource for bool { + fn to_source(&self) -> ~str { + let lit = dummy_spanned(ast::LitBool(*self)); + pprust::lit_to_str(&lit) + } + } + + impl ToSource for char { + fn to_source(&self) -> ~str { + let lit = dummy_spanned(ast::LitChar(*self)); + pprust::lit_to_str(&lit) + } + } + impl ToSource for int { fn to_source(&self) -> ~str { let lit = dummy_spanned(ast::LitInt(*self as i64, ast::TyI)); @@ -227,6 +247,9 @@ pub mod rt { impl_to_tokens!(@ast::Expr) impl_to_tokens!(ast::Block) impl_to_tokens_self!(&'a str) + impl_to_tokens!(()) + impl_to_tokens!(char) + impl_to_tokens!(bool) impl_to_tokens!(int) impl_to_tokens!(i8) impl_to_tokens!(i16) |
