about summary refs log tree commit diff
path: root/src/libsyntax
diff options
context:
space:
mode:
authorHanno Braun <mail@hannobraun.de>2014-06-07 13:46:41 +0000
committerHanno Braun <mail@hannobraun.de>2014-06-07 13:46:41 +0000
commitcc28ae5201b0927683b253dbe893a62a188aa5a5 (patch)
tree7f16fc4bd6a8ff23fff1a5a4ae9ee95d98e8ddf1 /src/libsyntax
parent8e9e484d7089590ce63bfe21723d7ee0c50be8f4 (diff)
downloadrust-cc28ae5201b0927683b253dbe893a62a188aa5a5.tar.gz
rust-cc28ae5201b0927683b253dbe893a62a188aa5a5.zip
Implement ToSource and ToToken for ast::Arg
This makes ast::Arg usable in the quote_ macros.

Please note that this commit doesn't include a regression test. There
are tests that use the quote macros, but all of them are ignored. Due to
that, there is no obvious (to me) way to test this.

Since this change is absolutely trivial and only hooks up an additional
type to existing infrastructure (which presumably is tested elsewhere),
I concluded it's not worth the effort to follow up on this.
Diffstat (limited to 'src/libsyntax')
-rw-r--r--src/libsyntax/ext/quote.rs7
-rw-r--r--src/libsyntax/print/pprust.rs4
2 files changed, 11 insertions, 0 deletions
diff --git a/src/libsyntax/ext/quote.rs b/src/libsyntax/ext/quote.rs
index d7bab3e2ffa..0f5928ee198 100644
--- a/src/libsyntax/ext/quote.rs
+++ b/src/libsyntax/ext/quote.rs
@@ -135,6 +135,12 @@ pub mod rt {
         }
     }
 
+    impl ToSource for ast::Arg {
+        fn to_source(&self) -> String {
+            pprust::arg_to_str(self)
+        }
+    }
+
     impl<'a> ToSource for &'a str {
         fn to_source(&self) -> String {
             let lit = dummy_spanned(ast::LitStr(
@@ -264,6 +270,7 @@ pub mod rt {
     impl_to_tokens!(Generics)
     impl_to_tokens!(@ast::Expr)
     impl_to_tokens!(ast::Block)
+    impl_to_tokens!(ast::Arg)
     impl_to_tokens_self!(&'a str)
     impl_to_tokens!(())
     impl_to_tokens!(char)
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index 440070e70a6..05c2558da48 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -242,6 +242,10 @@ pub fn variant_to_str(var: &ast::Variant) -> String {
     to_str(|s| s.print_variant(var))
 }
 
+pub fn arg_to_str(arg: &ast::Arg) -> String {
+    to_str(|s| s.print_arg(arg))
+}
+
 pub fn visibility_qualified(vis: ast::Visibility, s: &str) -> String {
     match vis {
         ast::Public => format!("pub {}", s).to_string(),