Skip to content

Commit 370c9c5

Browse files
committed
rustdoc: hide private traits in strip-private pass
Fix #16563
1 parent b69cd73 commit 370c9c5

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/librustdoc/passes.rs

+12-1
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,18 @@ impl<'a> fold::DocFolder for Stripper<'a> {
134134
clean::StructItem(..) | clean::EnumItem(..) |
135135
clean::TraitItem(..) | clean::FunctionItem(..) |
136136
clean::VariantItem(..) | clean::MethodItem(..) |
137-
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) |
137+
clean::ForeignFunctionItem(..) | clean::ForeignStaticItem(..) => {
138+
if ast_util::is_local(i.def_id) {
139+
if !self.exported_items.contains(&i.def_id.node) {
140+
return None;
141+
}
142+
// Traits are in exported_items even when they're totally private.
143+
if i.is_trait() && i.visibility != Some(ast::Public) {
144+
return None;
145+
}
146+
}
147+
}
148+
138149
clean::ConstantItem(..) => {
139150
if ast_util::is_local(i.def_id) &&
140151
!self.exported_items.contains(&i.def_id.node) {

0 commit comments

Comments
 (0)