Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix wrong names when inlining
  • Loading branch information
jyn514 committed Nov 21, 2020
commit 788840612e9da529158ada25d2160ca07d5a8dc9
12 changes: 8 additions & 4 deletions src/librustdoc/clean/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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,
Expand Down
5 changes: 3 additions & 2 deletions src/librustdoc/doctree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ crate use self::StructType::*;

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;
Expand All @@ -20,7 +20,8 @@ crate struct Module<'hir> {
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>>,
Expand Down
12 changes: 6 additions & 6 deletions src/librustdoc/visit_ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,21 +370,21 @@ impl<'a, 'tcx> RustdocVisitor<'a, 'tcx> {
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) => {
Expand Down