diff options
| author | Michael Howell <michael@notriddle.com> | 2022-07-25 16:35:12 -0700 |
|---|---|---|
| committer | Michael Howell <michael@notriddle.com> | 2022-07-25 16:35:12 -0700 |
| commit | 225ac9efc10bfd4149fd6de3d09e70d6c2387a8b (patch) | |
| tree | 034895846a2b8e62690e2e4a17097aa10103b0ce /src/librustdoc | |
| parent | bdf520fd419cd4dea184332f57206f1cf5ca3e8f (diff) | |
rustdoc: avoid inlining modules with duplicate names
Fixes rust-lang/rust#99734
Diffstat (limited to 'src/librustdoc')
| -rw-r--r-- | src/librustdoc/clean/mod.rs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index c9ef4748a48..cf03979a934 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -51,19 +51,22 @@ pub(crate) trait Clean<'tcx, T> { impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> { fn clean(&self, cx: &mut DocContext<'tcx>) -> Item { let mut items: Vec<Item> = vec![]; + let mut inserted = FxHashSet::default(); items.extend( self.foreigns .iter() .map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)), ); - items.extend(self.mods.iter().map(|x| x.clean(cx))); + items.extend(self.mods.iter().map(|x| { + inserted.insert((ItemType::Module, x.name)); + x.clean(cx) + })); // Split up imports from all other items. // // This covers the case where somebody does an import which should pull in an item, // but there's already an item with the same namespace and same name. Rust gives // priority to the not-imported one, so we should, too. - let mut inserted = FxHashSet::default(); items.extend(self.items.iter().flat_map(|(item, renamed)| { // First, lower everything other than imports. if matches!(item.kind, hir::ItemKind::Use(..)) { |
