diff options
| author | Michael Howell <michael@notriddle.com> | 2022-09-09 15:02:28 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-09-09 15:02:28 -0700 |
| commit | 624f972358b2d1a33ce50bc27d33074be24981e0 (patch) | |
| tree | 839e60c0a218d2d92516d3d5ee509618a1bc5489 | |
| parent | 1f8d552d6dfd4bb534c98b79150f21a122ed0b4c (diff) | |
| download | rust-624f972358b2d1a33ce50bc27d33074be24981e0.tar.gz rust-624f972358b2d1a33ce50bc27d33074be24981e0.zip | |
rustdoc: when removing duplicate names, ignore `#[doc(hidden)]` items
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index ecbfc636314..bca3f4db4a8 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -50,7 +50,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext< let mut inserted = FxHashSet::default(); items.extend(doc.foreigns.iter().map(|(item, renamed)| { let item = clean_maybe_renamed_foreign_item(cx, item, *renamed); - if let Some(name) = item.name { + if let Some(name) = item.name && !item.attrs.lists(sym::doc).has_word(sym::hidden) { inserted.insert((item.type_(), name)); } item @@ -59,7 +59,14 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext< if !inserted.insert((ItemType::Module, x.name)) { return None; } - Some(clean_doc_module(x, cx)) + let item = clean_doc_module(x, cx); + if item.attrs.lists(sym::doc).has_word(sym::hidden) { + // Hidden modules are stripped at a later stage. + // If a hidden module has the same name as a visible one, we want + // to keep both of them around. + inserted.remove(&(ItemType::Module, x.name)); + } + Some(item) })); // Split up imports from all other items. @@ -74,7 +81,7 @@ pub(crate) fn clean_doc_module<'tcx>(doc: &DocModule<'tcx>, cx: &mut DocContext< } let v = clean_maybe_renamed_item(cx, item, *renamed); for item in &v { - if let Some(name) = item.name { + if let Some(name) = item.name && !item.attrs.lists(sym::doc).has_word(sym::hidden) { inserted.insert((item.type_(), name)); } } |
