Skip to content

Commit 94a868d

Browse files
notriddleMark-Simulacrum
authored andcommitted
rustdoc: avoid inlining foreigns with duplicate names
1 parent 39814b1 commit 94a868d

File tree

3 files changed

+27
-5
lines changed

3 files changed

+27
-5
lines changed

src/librustdoc/clean/mod.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,13 @@ impl<'tcx> Clean<'tcx, Item> for DocModule<'tcx> {
5252
fn clean(&self, cx: &mut DocContext<'tcx>) -> Item {
5353
let mut items: Vec<Item> = vec![];
5454
let mut inserted = FxHashSet::default();
55-
items.extend(
56-
self.foreigns
57-
.iter()
58-
.map(|(item, renamed)| clean_maybe_renamed_foreign_item(cx, item, *renamed)),
59-
);
55+
items.extend(self.foreigns.iter().map(|(item, renamed)| {
56+
let item = clean_maybe_renamed_foreign_item(cx, item, *renamed);
57+
if let Some(name) = item.name {
58+
inserted.insert((item.type_(), name));
59+
}
60+
item
61+
}));
6062
items.extend(self.mods.iter().map(|x| {
6163
inserted.insert((ItemType::Module, x.name));
6264
x.clean(cx)

src/test/rustdoc/auxiliary/issue-99734-aux.rs

+4
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ impl Option {
55

66
/// [`Option::unwrap`]
77
pub mod task {}
8+
9+
extern "C" {
10+
pub fn main() -> std::ffi::c_int;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// aux-build:issue-99734-aux.rs
2+
// build-aux-docs
3+
// ignore-cross-compile
4+
5+
#![crate_name = "foo"]
6+
7+
#[macro_use]
8+
extern crate issue_99734_aux;
9+
10+
pub use issue_99734_aux::*;
11+
12+
// @count foo/index.html '//a[@class="fn"][@title="foo::main fn"]' 1
13+
14+
extern "C" {
15+
pub fn main() -> std::ffi::c_int;
16+
}

0 commit comments

Comments
 (0)