Skip to content

Commit a0c445b

Browse files
committed
---
yaml --- r: 21958 b: refs/heads/snap-stage3 c: e0f5f25 h: refs/heads/master v: v3
1 parent 5e236a7 commit a0c445b

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
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 38595e66643c3dd47e6f6c8ca443a33398561f8f
4+
refs/heads/snap-stage3: e0f5f259115b2f45f7290fad48fd32b29ce7b8b7
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/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)