about summary refs log tree commit diff
path: root/src/rustdoc
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-09-20 15:14:20 -0700
committerBrian Anderson <banderson@mozilla.com>2012-09-20 15:14:32 -0700
commit0bd02b113c02c1b3eea33cc339d71697a316d412 (patch)
treeb80c41f6ca4e3574f94eadde0f955a4633a98d38 /src/rustdoc
parent5558ebb6b7bf54a370111a46ea7c75b5becf85ec (diff)
rustdoc: Also don't print struct attributes
Diffstat (limited to 'src/rustdoc')
-rw-r--r--src/rustdoc/tystr_pass.rs20
1 files changed, 15 insertions, 5 deletions
diff --git a/src/rustdoc/tystr_pass.rs b/src/rustdoc/tystr_pass.rs
index e6582bd053e..76a5815c942 100644
--- a/src/rustdoc/tystr_pass.rs
+++ b/src/rustdoc/tystr_pass.rs
@@ -333,7 +333,7 @@ fn fold_struct(
         sig: do astsrv::exec(srv) |ctxt| {
             match ctxt.ast_map.get(doc.id()) {
                 ast_map::node_item(item, _) => {
-                    let item = strip_struct_drop_block(item);
+                    let item = strip_struct_extra_stuff(item);
                     Some(pprust::item_to_str(item,
                                              extract::interner()))
                 }
@@ -344,13 +344,15 @@ fn fold_struct(
     }
 }
 
-/// Removes the drop block from structs so that they aren't displayed
-/// as part of the type
-fn strip_struct_drop_block(item: @ast::item) -> @ast::item {
+/// Removes various things from the struct item definition that
+/// shouldn't be displayed in the struct signature. Probably there
+/// should be a simple pprust::struct_to_str function that does
+/// what I actually want
+fn strip_struct_extra_stuff(item: @ast::item) -> @ast::item {
     let node = match item.node {
         ast::item_class(def, tys) => {
             let def = @{
-                dtor: None,
+                dtor: None, // Remove the drop { } block
                 .. *def
             };
             ast::item_class(def, tys)
@@ -359,6 +361,7 @@ fn strip_struct_drop_block(item: @ast::item) -> @ast::item {
     };
 
     @{
+        attrs: ~[], // Remove the attributes
         node: node,
         .. *item
     }
@@ -377,6 +380,13 @@ fn should_not_serialize_struct_drop_blocks() {
     assert !doc.cratemod().structs()[0].sig.get().contains("drop");
 }
 
+#[test]
+fn should_not_serialize_struct_attrs() {
+    // All we care about are the fields
+    let doc = test::mk_doc(~"#[wut] struct S { field: () }");
+    assert !doc.cratemod().structs()[0].sig.get().contains("wut");
+}
+
 #[cfg(test)]
 mod test {
     fn mk_doc(source: ~str) -> doc::Doc {