提交 78884061 编写于 作者: J Joshua Nelson

Fix wrong names when inlining

上级 8c94f8be
......@@ -1922,13 +1922,17 @@ fn clean(&self, cx: &DocContext<'_>) -> BareFunctionDecl {
}
}
impl Clean<Item> for hir::Item<'_> {
impl Clean<Item> for (&hir::Item<'_>, Option<Ident>) {
fn clean(&self, cx: &DocContext<'_>) -> Item {
use hir::ItemKind;
let def_id = cx.tcx.hir().local_def_id(self.hir_id).to_def_id();
let name = cx.tcx.hir().name(self.hir_id);
let kind = match self.kind {
let (item, renamed) = self;
let def_id = cx.tcx.hir().local_def_id(item.hir_id).to_def_id();
let name = match renamed {
Some(ident) => ident.name,
None => cx.tcx.hir().name(item.hir_id),
};
let kind = match item.kind {
ItemKind::Static(ty, mutability, body_id) => StaticItem(Static {
type_: ty.clean(cx),
mutability,
......
......@@ -4,7 +4,7 @@
use rustc_ast as ast;
use rustc_span::hygiene::MacroKind;
use rustc_span::{self, Span, Symbol};
use rustc_span::{self, symbol::Ident, Span, Symbol};
use rustc_hir as hir;
use rustc_hir::def_id::CrateNum;
......@@ -20,7 +20,8 @@
crate fns: Vec<Function<'hir>>,
crate mods: Vec<Module<'hir>>,
crate id: hir::HirId,
crate items: Vec<&'hir hir::Item<'hir>>,
// (item, renamed)
crate items: Vec<(&'hir hir::Item<'hir>, Option<Ident>)>,
crate traits: Vec<Trait<'hir>>,
crate impls: Vec<Impl<'hir>>,
crate foreigns: Vec<ForeignItem<'hir>>,
......
......@@ -370,21 +370,21 @@ fn visit_item(
Some(ident.name),
));
}
hir::ItemKind::Enum(..) => om.items.push(item),
hir::ItemKind::Struct(..) => om.items.push(item),
hir::ItemKind::Union(..) => om.items.push(item),
hir::ItemKind::Fn(ref sig, ref gen, body) => {
self.visit_fn(om, item, ident.name, &sig.decl, sig.header, gen, body)
}
hir::ItemKind::TyAlias(..)
hir::ItemKind::Enum(..)
| hir::ItemKind::Struct(..)
| hir::ItemKind::Union(..)
| hir::ItemKind::TyAlias(..)
| hir::ItemKind::OpaqueTy(..)
| hir::ItemKind::Static(..)
| hir::ItemKind::TraitAlias(..) => om.items.push(item),
| hir::ItemKind::TraitAlias(..) => om.items.push((item, renamed)),
hir::ItemKind::Const(..) => {
// Underscore constants do not correspond to a nameable item and
// so are never useful in documentation.
if ident.name != kw::Underscore {
om.items.push(item);
om.items.push((item, renamed));
}
}
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册