Skip to content

Commit a781126

Browse files
committed
ForeignItem
1 parent 42d4dbb commit a781126

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

src/librustdoc/clean/mod.rs

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
261261
}
262262
// TODO: this should also take the span into account (inner or outer)
263263
ItemKind::Mod(ref mod_) => NotInlined(mod_.clean(cx)),
264+
ItemKind::ForeignMod(ref mod_) => NotInlined(mod_.clean(cx)),
264265
ItemKind::Union(ref variant_data, ref generics) => NotInlined(UnionItem(Union {
265266
struct_type: doctree::struct_type_from_def(&variant_data),
266267
generics: generics.clean(cx),
@@ -360,6 +361,12 @@ impl Clean<ItemKind> for hir::Mod<'_> {
360361
}
361362
}
362363

364+
impl Clean<ItemKind> for hir::ForeignMod<'_> {
365+
fn clean(&self, cx: &DocContext<'_>) -> ItemKind {
366+
ModuleItem(Module { is_crate: false, items: self.items.clean(cx) })
367+
}
368+
}
369+
363370
impl Clean<Vec<Item>> for hir::ItemId {
364371
fn clean(&self, cx: &DocContext<'_>) -> Vec<Item> {
365372
cx.tcx.hir().item(self.id).clean(cx)
@@ -2275,11 +2282,11 @@ fn clean_import(
22752282
MaybeInlined::NotInlined(ImportItem(kind))
22762283
}
22772284

2278-
impl Clean<Item> for doctree::ForeignItem<'_> {
2285+
impl Clean<Item> for hir::ForeignItem<'_> {
22792286
fn clean(&self, cx: &DocContext<'_>) -> Item {
22802287
let kind = match self.kind {
22812288
hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
2282-
let abi = cx.tcx.hir().get_foreign_abi(self.id);
2289+
let abi = cx.tcx.hir().get_foreign_abi(self.hir_id);
22832290
let (generics, decl) =
22842291
enter_impl_trait(cx, || (generics.clean(cx), (&**decl, &names[..]).clean(cx)));
22852292
let (all_types, ret_types) = get_all_types(&generics, &decl, cx);
@@ -2296,15 +2303,13 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
22962303
ret_types,
22972304
})
22982305
}
2299-
hir::ForeignItemKind::Static(ref ty, mutbl) => ForeignStaticItem(Static {
2300-
type_: ty.clean(cx),
2301-
mutability: *mutbl,
2302-
expr: String::new(),
2303-
}),
2306+
hir::ForeignItemKind::Static(ref ty, mutability) => {
2307+
ForeignStaticItem(Static { type_: ty.clean(cx), mutability, expr: String::new() })
2308+
}
23042309
hir::ForeignItemKind::Type => ForeignTypeItem,
23052310
};
23062311

2307-
Item::from_hir_id_and_parts(self.id, Some(self.name), kind, cx)
2312+
Item::from_hir_id_and_parts(self.hir_id, Some(self.ident.name), kind, cx)
23082313
}
23092314
}
23102315

src/librustdoc/doctree.rs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,15 +98,6 @@ crate struct Impl<'hir> {
9898
crate id: hir::HirId,
9999
}
100100

101-
crate struct ForeignItem<'hir> {
102-
crate vis: &'hir hir::Visibility<'hir>,
103-
crate id: hir::HirId,
104-
crate name: Symbol,
105-
crate kind: &'hir hir::ForeignItemKind<'hir>,
106-
crate attrs: &'hir [ast::Attribute],
107-
crate span: Span,
108-
}
109-
110101
#[derive(Debug)]
111102
crate struct Import<'hir> {
112103
crate name: Symbol,

0 commit comments

Comments
 (0)