about summary refs log tree commit diff
path: root/src/libsyntax/print/pprust.rs
diff options
context:
space:
mode:
authorSergio Benitez <sb@sergio.bz>2016-08-19 18:58:14 -0700
committerSergio Benitez <sb@sergio.bz>2016-08-25 13:25:22 -0700
commit8250a26b5bcea9190ac63e756c35d8a54bf9da0c (patch)
treef95baa037c52c307de53d605ad752afd4880ffa4 /src/libsyntax/print/pprust.rs
parent528c6f3ed6a23a374dc5a40582d1bea2f2cfda65 (diff)
downloadrust-8250a26b5bcea9190ac63e756c35d8a54bf9da0c.tar.gz
rust-8250a26b5bcea9190ac63e756c35d8a54bf9da0c.zip
Implement RFC#1559: allow all literals in attributes.
Diffstat (limited to 'src/libsyntax/print/pprust.rs')
-rw-r--r--src/libsyntax/print/pprust.rs19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs
index a77c678248b..562cc896aef 100644
--- a/src/libsyntax/print/pprust.rs
+++ b/src/libsyntax/print/pprust.rs
@@ -120,7 +120,7 @@ pub fn print_crate<'a>(cm: &'a CodeMap,
         // of the feature gate, so we fake them up here.
 
         // #![feature(prelude_import)]
-        let prelude_import_meta = attr::mk_word_item(InternedString::new("prelude_import"));
+        let prelude_import_meta = attr::mk_list_word_item(InternedString::new("prelude_import"));
         let list = attr::mk_list_item(InternedString::new("feature"),
                                       vec![prelude_import_meta]);
         let fake_attr = attr::mk_attr_inner(attr::mk_attr_id(), list);
@@ -406,6 +406,10 @@ pub fn block_to_string(blk: &ast::Block) -> String {
     })
 }
 
+pub fn meta_list_item_to_string(li: &ast::NestedMetaItem) -> String {
+    to_string(|s| s.print_meta_list_item(li))
+}
+
 pub fn meta_item_to_string(mi: &ast::MetaItem) -> String {
     to_string(|s| s.print_meta_item(mi))
 }
@@ -764,6 +768,17 @@ pub trait PrintState<'a> {
         }
     }
 
+    fn print_meta_list_item(&mut self, item: &ast::NestedMetaItem) -> io::Result<()> {
+        match item.node {
+            ast::NestedMetaItemKind::MetaItem(ref mi) => {
+                self.print_meta_item(mi)
+            },
+            ast::NestedMetaItemKind::Literal(ref lit) => {
+                self.print_literal(lit)
+            }
+        }
+    }
+
     fn print_meta_item(&mut self, item: &ast::MetaItem) -> io::Result<()> {
         try!(self.ibox(INDENT_UNIT));
         match item.node {
@@ -780,7 +795,7 @@ pub trait PrintState<'a> {
                 try!(self.popen());
                 try!(self.commasep(Consistent,
                               &items[..],
-                              |s, i| s.print_meta_item(&i)));
+                              |s, i| s.print_meta_list_item(&i)));
                 try!(self.pclose());
             }
         }