Skip to content

Commit 3a5ddc2

Browse files
committed
---
yaml --- r: 32728 b: refs/heads/dist-snap c: e0f5f25 h: refs/heads/master v: v3
1 parent 1aaa1f1 commit 3a5ddc2

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 38595e66643c3dd47e6f6c8ca443a33398561f8f
10+
refs/heads/dist-snap: e0f5f259115b2f45f7290fad48fd32b29ce7b8b7
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/rustdoc/tystr_pass.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,7 @@ fn fold_struct(
333333
sig: do astsrv::exec(srv) |ctxt| {
334334
match ctxt.ast_map.get(doc.id()) {
335335
ast_map::node_item(item, _) => {
336+
let item = strip_struct_drop_block(item);
336337
Some(pprust::item_to_str(item,
337338
extract::interner()))
338339
}
@@ -343,12 +344,39 @@ fn fold_struct(
343344
}
344345
}
345346

347+
/// Removes the drop block from structs so that they aren't displayed
348+
/// as part of the type
349+
fn strip_struct_drop_block(item: @ast::item) -> @ast::item {
350+
let node = match item.node {
351+
ast::item_class(def, tys) => {
352+
let def = @{
353+
dtor: None,
354+
.. *def
355+
};
356+
ast::item_class(def, tys)
357+
}
358+
_ => fail ~"not a struct"
359+
};
360+
361+
@{
362+
node: node,
363+
.. *item
364+
}
365+
}
366+
346367
#[test]
347368
fn should_add_struct_defs() {
348369
let doc = test::mk_doc(~"struct S { field: () }");
349370
assert doc.cratemod().structs()[0].sig.get().contains("struct S {");
350371
}
351372

373+
#[test]
374+
fn should_not_serialize_struct_drop_blocks() {
375+
// All we care about are the fields
376+
let doc = test::mk_doc(~"struct S { field: (), drop { } }");
377+
assert !doc.cratemod().structs()[0].sig.get().contains("drop");
378+
}
379+
352380
#[cfg(test)]
353381
mod test {
354382
fn mk_doc(source: ~str) -> doc::Doc {

0 commit comments

Comments
 (0)