Skip to content

Commit

Permalink
fix(rustdoc): print the doc(hidden) attribute the same as others
Browse files Browse the repository at this point in the history
  • Loading branch information
poliorcetics committed Dec 26, 2024
1 parent 4ed8cf4 commit bdec113
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
6 changes: 6 additions & 0 deletions src/librustdoc/clean/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,11 @@ impl Item {
}
})
.collect();

if !keep_as_is && self.is_doc_hidden() {
attrs.push("#[doc(hidden)]".into());
}

if !keep_as_is
&& let Some(def_id) = self.def_id()
&& let ItemType::Struct | ItemType::Enum | ItemType::Union = self.type_()
Expand Down Expand Up @@ -822,6 +827,7 @@ impl Item {
attrs.push(format!("#[repr({})]", out.join(", ")));
}
}

attrs
}

Expand Down
9 changes: 1 addition & 8 deletions src/librustdoc/html/format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1610,14 +1610,7 @@ pub(crate) fn visibility_print_with_space<'a, 'tcx: 'a>(
}
};

let is_doc_hidden = item.is_doc_hidden();
display_fn(move |f| {
if is_doc_hidden {
f.write_str("#[doc(hidden)] ")?;
}

f.write_str(&vis)
})
display_fn(move |f| f.write_str(&vis))
}

pub(crate) trait PrintWithSpace {
Expand Down

0 comments on commit bdec113

Please sign in to comment.