rustdoc: Don't print struct drop blocks
This commit is contained in:
parent
38595e6664
commit
e0f5f25911
1 changed files with 28 additions and 0 deletions
|
@ -333,6 +333,7 @@ fn fold_struct(
|
||||||
sig: do astsrv::exec(srv) |ctxt| {
|
sig: do astsrv::exec(srv) |ctxt| {
|
||||||
match ctxt.ast_map.get(doc.id()) {
|
match ctxt.ast_map.get(doc.id()) {
|
||||||
ast_map::node_item(item, _) => {
|
ast_map::node_item(item, _) => {
|
||||||
|
let item = strip_struct_drop_block(item);
|
||||||
Some(pprust::item_to_str(item,
|
Some(pprust::item_to_str(item,
|
||||||
extract::interner()))
|
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]
|
#[test]
|
||||||
fn should_add_struct_defs() {
|
fn should_add_struct_defs() {
|
||||||
let doc = test::mk_doc(~"struct S { field: () }");
|
let doc = test::mk_doc(~"struct S { field: () }");
|
||||||
assert doc.cratemod().structs()[0].sig.get().contains("struct S {");
|
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)]
|
#[cfg(test)]
|
||||||
mod test {
|
mod test {
|
||||||
fn mk_doc(source: ~str) -> doc::Doc {
|
fn mk_doc(source: ~str) -> doc::Doc {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue