Skip to content
/ rust Public
forked from rust-lang/rust

Commit 76c35a1

Browse files
committed
Auto merge of rust-lang#159779 - camelid:even-better-impls, r=GuillaumeGomez
rustdoc: Only synthesize auto/blanket impls for documented items Previously, the code would skip synthesizing impls if the *trait* was not documented, but it would still synthesize even if the *type* was not documented. This is wasted work.
2 parents 89c61a7 + ab70c36 commit 76c35a1

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

src/librustdoc/passes/collect_trait_impls.rs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,12 +168,14 @@ struct SyntheticImplCollector<'a, 'tcx> {
168168
impl DocVisitor<'_> for SyntheticImplCollector<'_, '_> {
169169
fn visit_item(&mut self, i: &Item) {
170170
if i.is_struct() || i.is_enum() || i.is_union() {
171+
let item_def_id = i.item_id.expect_def_id();
171172
// FIXME(eddyb) is this `doc(hidden)` check needed?
172-
if !self.cx.tcx.is_doc_hidden(i.item_id.expect_def_id()) {
173-
self.impls.extend(synthesize_auto_trait_and_blanket_impls(
174-
self.cx,
175-
i.item_id.expect_def_id(),
176-
));
173+
// FIXME(camelid) should we skip the `doc(hidden)` check if --document-hidden-items is passed?
174+
if (self.cx.document_private()
175+
|| self.cx.cache.effective_visibilities.is_reachable(self.cx.tcx, item_def_id))
176+
&& !self.cx.tcx.is_doc_hidden(item_def_id)
177+
{
178+
self.impls.extend(synthesize_auto_trait_and_blanket_impls(self.cx, item_def_id));
177179
}
178180
}
179181

0 commit comments

Comments
 (0)