}
}
-impl Clean<Item> for doctree::ForeignItem<'_> {
+impl Clean<Item> for (&hir::ForeignItem<'_>, Option<Ident>) {
fn clean(&self, cx: &DocContext<'_>) -> Item {
- let kind = match self.kind {
+ let (item, renamed) = self;
+ let kind = match item.kind {
hir::ForeignItemKind::Fn(ref decl, ref names, ref generics) => {
- let abi = cx.tcx.hir().get_foreign_abi(self.id);
+ let abi = cx.tcx.hir().get_foreign_abi(item.hir_id);
let (generics, decl) =
enter_impl_trait(cx, || (generics.clean(cx), (&**decl, &names[..]).clean(cx)));
let (all_types, ret_types) = get_all_types(&generics, &decl, cx);
ret_types,
})
}
- hir::ForeignItemKind::Static(ref ty, mutbl) => ForeignStaticItem(Static {
- type_: ty.clean(cx),
- mutability: *mutbl,
- expr: String::new(),
- }),
+ hir::ForeignItemKind::Static(ref ty, mutability) => {
+ ForeignStaticItem(Static { type_: ty.clean(cx), mutability, expr: String::new() })
+ }
hir::ForeignItemKind::Type => ForeignTypeItem,
};
- Item::from_hir_id_and_parts(self.id, Some(self.name), kind, cx)
+ Item::from_hir_id_and_parts(item.hir_id, Some(renamed.unwrap_or(item.ident).name), kind, cx)
}
}
// (item, renamed)
crate items: Vec<(&'hir hir::Item<'hir>, Option<Ident>)>,
crate traits: Vec<Trait<'hir>>,
- crate foreigns: Vec<ForeignItem<'hir>>,
+ crate foreigns: Vec<(&'hir hir::ForeignItem<'hir>, Option<Ident>)>,
crate macros: Vec<Macro>,
crate proc_macros: Vec<ProcMacro>,
crate is_crate: bool,
crate id: hir::HirId,
}
-crate struct ForeignItem<'hir> {
- crate id: hir::HirId,
- crate name: Symbol,
- crate kind: &'hir hir::ForeignItemKind<'hir>,
-}
-
// For Macro we store the DefId instead of the NodeId, since we also create
// these imported macro_rules (which only have a DUMMY_NODE_ID).
crate struct Macro {
om: &mut Module<'tcx>,
) {
// If inlining we only want to include public functions.
- if self.inlining && !item.vis.node.is_pub() {
- return;
+ if !self.inlining || item.vis.node.is_pub() {
+ om.foreigns.push((item, renamed));
}
-
- om.foreigns.push(ForeignItem {
- id: item.hir_id,
- name: renamed.unwrap_or(item.ident).name,
- kind: &item.kind,
- });
}
// Convert each `exported_macro` into a doc item.