Skip to content

Commit ee0cad5

Browse files
committed
Fix broken handling of extern "ABI" blocks
ForeignModule is just such a terrible name for these.
1 parent ba301ac commit ee0cad5

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/librustdoc/clean/mod.rs

+5-4
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
260260
}
261261
// TODO: this should also take the span into account (inner or outer)
262262
ItemKind::Mod(ref mod_) => NotInlined(mod_.clean(cx)),
263-
ItemKind::ForeignMod(ref mod_) => NotInlined(mod_.clean(cx)),
263+
// `extern "C" { ... }`
264+
ItemKind::ForeignMod(ref mod_) => MaybeInlined::InlinedWithoutOriginal(mod_.clean(cx)),
264265
ItemKind::GlobalAsm(..) => MaybeInlined::InlinedWithoutOriginal(vec![]), // not handled
265266
ItemKind::TyAlias(ty, ref generics) => {
266267
let rustdoc_ty = ty.clean(cx);
@@ -403,9 +404,9 @@ impl Clean<ItemKind> for hir::Mod<'_> {
403404
}
404405
}
405406

406-
impl Clean<ItemKind> for hir::ForeignMod<'_> {
407-
fn clean(&self, cx: &DocContext<'_>) -> ItemKind {
408-
ModuleItem(Module { is_crate: false, items: self.items.clean(cx) })
407+
impl Clean<Vec<Item>> for hir::ForeignMod<'_> {
408+
fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
409+
self.items.iter().map(|x| x.clean(cx)).collect()
409410
}
410411
}
411412

src/librustdoc/formats/renderer.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ crate fn run_format<T: FormatRenderer>(
8282
// recurse into the items of the module as well.
8383
let name = item.name.as_ref().unwrap().to_string();
8484
if name.is_empty() {
85-
panic!("Unexpected module with empty name");
85+
panic!("Unexpected module with empty name: {:?}", item);
8686
}
8787

8888
cx.mod_item_in(&item, &name, &cache)?;

0 commit comments

Comments
 (0)