Get rid of doctree::ForeignItem
This commit is contained in:
parent
53d19b37c5
commit
35e7beed0e
|
@ -2186,11 +2186,12 @@ impl Clean<Vec<Item>> for doctree::Import<'_> {
|
|||
}
|
||||
}
|
||||
|
||||
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);
|
||||
|
@ -2207,15 +2208,13 @@ impl Clean<Item> for doctree::ForeignItem<'_> {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ crate struct Module<'hir> {
|
|||
// (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,
|
||||
|
@ -87,12 +87,6 @@ crate struct Trait<'hir> {
|
|||
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 {
|
||||
|
|
|
@ -418,15 +418,9 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
|||
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.
|
||||
|
|
Loading…
Reference in a new issue