Fix wrong names when inlining
This commit is contained in:
parent
8c94f8be99
commit
788840612e
3 changed files with 17 additions and 12 deletions
|
@ -1922,13 +1922,17 @@ impl Clean<BareFunctionDecl> for hir::BareFnTy<'_> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Clean<Item> for hir::Item<'_> {
|
impl Clean<Item> for (&hir::Item<'_>, Option<Ident>) {
|
||||||
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
fn clean(&self, cx: &DocContext<'_>) -> Item {
|
||||||
use hir::ItemKind;
|
use hir::ItemKind;
|
||||||
|
|
||||||
let def_id = cx.tcx.hir().local_def_id(self.hir_id).to_def_id();
|
let (item, renamed) = self;
|
||||||
let name = cx.tcx.hir().name(self.hir_id);
|
let def_id = cx.tcx.hir().local_def_id(item.hir_id).to_def_id();
|
||||||
let kind = match self.kind {
|
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 {
|
ItemKind::Static(ty, mutability, body_id) => StaticItem(Static {
|
||||||
type_: ty.clean(cx),
|
type_: ty.clean(cx),
|
||||||
mutability,
|
mutability,
|
||||||
|
|
|
@ -4,7 +4,7 @@ crate use self::StructType::*;
|
||||||
|
|
||||||
use rustc_ast as ast;
|
use rustc_ast as ast;
|
||||||
use rustc_span::hygiene::MacroKind;
|
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 as hir;
|
||||||
use rustc_hir::def_id::CrateNum;
|
use rustc_hir::def_id::CrateNum;
|
||||||
|
@ -20,7 +20,8 @@ crate struct Module<'hir> {
|
||||||
crate fns: Vec<Function<'hir>>,
|
crate fns: Vec<Function<'hir>>,
|
||||||
crate mods: Vec<Module<'hir>>,
|
crate mods: Vec<Module<'hir>>,
|
||||||
crate id: hir::HirId,
|
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 traits: Vec<Trait<'hir>>,
|
||||||
crate impls: Vec<Impl<'hir>>,
|
crate impls: Vec<Impl<'hir>>,
|
||||||
crate foreigns: Vec<ForeignItem<'hir>>,
|
crate foreigns: Vec<ForeignItem<'hir>>,
|
||||||
|
|
|
@ -370,21 +370,21 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
|
||||||
Some(ident.name),
|
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) => {
|
hir::ItemKind::Fn(ref sig, ref gen, body) => {
|
||||||
self.visit_fn(om, item, ident.name, &sig.decl, sig.header, 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::OpaqueTy(..)
|
||||||
| hir::ItemKind::Static(..)
|
| hir::ItemKind::Static(..)
|
||||||
| hir::ItemKind::TraitAlias(..) => om.items.push(item),
|
| hir::ItemKind::TraitAlias(..) => om.items.push((item, renamed)),
|
||||||
hir::ItemKind::Const(..) => {
|
hir::ItemKind::Const(..) => {
|
||||||
// Underscore constants do not correspond to a nameable item and
|
// Underscore constants do not correspond to a nameable item and
|
||||||
// so are never useful in documentation.
|
// so are never useful in documentation.
|
||||||
if ident.name != kw::Underscore {
|
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) => {
|
hir::ItemKind::Trait(is_auto, unsafety, ref generics, ref bounds, ref item_ids) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue