about summary refs log tree commit diff
path: root/src/rustdoc
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2012-09-20 14:40:55 -0700
committerBrian Anderson <banderson@mozilla.com>2012-09-20 14:41:09 -0700
commite0f5f259115b2f45f7290fad48fd32b29ce7b8b7 (patch)
tree2ef690d0d79e83414ae1fa931b1ca7ed9fb152ef /src/rustdoc
parent38595e66643c3dd47e6f6c8ca443a33398561f8f (diff)
rustdoc: Don't print struct drop blocks
Diffstat (limited to 'src/rustdoc')
-rw-r--r--src/rustdoc/tystr_pass.rs28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/rustdoc/tystr_pass.rs b/src/rustdoc/tystr_pass.rs
index 64c99e7abd2..e6582bd053e 100644
--- a/src/rustdoc/tystr_pass.rs
+++ b/src/rustdoc/tystr_pass.rs
@@ -333,6 +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);
                     Some(pprust::item_to_str(item,
                                              extract::interner()))
                 }
@@ -343,12 +344,39 @@ 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 {
+    let node = match item.node {
+        ast::item_class(def, tys) => {
+            let def = @{
+                dtor: None,
+                .. *def
+            };
+            ast::item_class(def, tys)
+        }
+        _ => fail ~"not a struct"
+    };
+
+    @{
+        node: node,
+        .. *item
+    }
+}
+
 #[test]
 fn should_add_struct_defs() {
     let doc = test::mk_doc(~"struct S { field: () }");
     assert doc.cratemod().structs()[0].sig.get().contains("struct S {");
 }
 
+#[test]
+fn should_not_serialize_struct_drop_blocks() {
+    // All we care about are the fields
+    let doc = test::mk_doc(~"struct S { field: (), drop { } }");
+    assert !doc.cratemod().structs()[0].sig.get().contains("drop");
+}
+
 #[cfg(test)]
 mod test {
     fn mk_doc(source: ~str) -> doc::Doc {