Skip to content

Commit a79eb20

Browse files
committed
Fix crash on items only named in HIR
1 parent 44cef3e commit a79eb20

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

src/librustdoc/clean/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
240240
use MaybeInlined::NotInlined;
241241

242242
let def_id = cx.tcx.hir().local_def_id(self.hir_id).to_def_id();
243-
let name = cx.tcx.item_name(def_id).clean(cx);
243+
let name = cx.tcx.hir().name(self.hir_id);
244244
let maybe_inlined = match self.kind {
245245
ItemKind::ExternCrate(renamed) => clean_extern_crate(self, renamed, cx),
246246
ItemKind::Use(path, kind) => clean_import(self, path, kind, cx),
@@ -318,7 +318,7 @@ impl Clean<Vec<Item>> for hir::Item<'_> {
318318
let build_item = |kind| Item {
319319
def_id,
320320
kind,
321-
name: Some(name),
321+
name: Some(name.to_string()),
322322
source: cx.tcx.def_span(def_id).clean(cx),
323323
attrs: self.attrs.clean(cx), // TODO: should this use tcx.attrs instead?
324324
visibility: self.vis.clean(cx), // TODO: should this use tcx.visibility instead?
@@ -2193,8 +2193,7 @@ fn clean_import(
21932193
}
21942194
Import::new_glob(resolve_use_source(cx, path), true)
21952195
} else {
2196-
let def_id = cx.tcx.hir().local_def_id(item.hir_id).to_def_id();
2197-
let name = cx.tcx.item_name(def_id);
2196+
let name = cx.tcx.hir().name(item.hir_id);
21982197
if !please_inline {
21992198
if let Res::Def(DefKind::Mod, did) = path.res {
22002199
if !did.is_local() && did.index == CRATE_DEF_INDEX {

0 commit comments

Comments
 (0)