Skip to content

Commit deeeaf0

Browse files
committed
rustdoc: Show all impls of traits. #5406
1 parent ebba8b4 commit deeeaf0

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/librustdoc/prune_private_pass.rs

+23-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,19 @@ fn is_visible(srv: astsrv::Srv, doc: doc::ItemDoc) -> bool {
5959
do astsrv::exec(srv) |ctxt| {
6060
match ctxt.ast_map.get(&id) {
6161
ast_map::node_item(item, _) => {
62-
item.vis == ast::public
62+
match item.node {
63+
ast::item_impl(_, Some(_), _, _) => {
64+
// This is a trait implementation, make it visible
65+
// NOTE: This is not quite right since this could be an impl
66+
// of a private trait. We can't know that without running
67+
// resolve though.
68+
true
69+
}
70+
_ => {
71+
// Otherwise just look at the visibility
72+
item.vis == ast::public
73+
}
74+
}
6375
}
6476
_ => util::unreachable()
6577
}
@@ -72,6 +84,16 @@ fn should_prune_items_without_pub_modifier() {
7284
fail_unless!(vec::is_empty(doc.cratemod().mods()));
7385
}
7486

87+
#[test]
88+
fn unless_they_are_trait_impls() {
89+
let doc = test::mk_doc(
90+
~" \
91+
trait Foo { } \
92+
impl Foo for int { } \
93+
");
94+
fail_unless!(!doc.cratemod().impls().is_empty());
95+
}
96+
7597
#[cfg(test)]
7698
pub mod test {
7799
use astsrv;

0 commit comments

Comments
 (0)