Skip to content

Commit

Permalink
rustdoc: avoid inlining foreigns with duplicate names
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Aug 2, 2022
1 parent 225ac9e commit 8724ca3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,13 @@ 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.foreigns.iter().map(|(item, renamed)| {
let item = clean_maybe_renamed_foreign_item(cx, item, *renamed);
if let Some(name) = item.name {
inserted.insert((item.type_(), name));
}
item
}));
items.extend(self.mods.iter().map(|x| {
inserted.insert((ItemType::Module, x.name));
x.clean(cx)
Expand Down
4 changes: 4 additions & 0 deletions src/test/rustdoc/auxiliary/issue-99734-aux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ impl Option {

/// [`Option::unwrap`]
pub mod task {}

extern "C" {
pub fn main() -> std::ffi::c_int;
}
16 changes: 16 additions & 0 deletions src/test/rustdoc/issue-99734-multiple-foreigns-w-same-name.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// aux-build:issue-99734-aux.rs
// build-aux-docs
// ignore-cross-compile

#![crate_name = "foo"]

#[macro_use]
extern crate issue_99734_aux;

pub use issue_99734_aux::*;

// @count foo/index.html '//a[@class="fn"][@title="foo::main fn"]' 1

extern "C" {
pub fn main() -> std::ffi::c_int;
}

0 comments on commit 8724ca3

Please sign in to comment.