From aa8c9b0d294717a566b0d69721e8c7648309667c Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Sun, 29 Nov 2020 13:37:43 -0500 Subject: [PATCH] Remove `TypeKind` hack in favor of `with_crate_prefix` --- src/librustdoc/passes/collect_intra_doc_links.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/librustdoc/passes/collect_intra_doc_links.rs b/src/librustdoc/passes/collect_intra_doc_links.rs index c1fbf6d9f5884..3dcc0f240a3f8 100644 --- a/src/librustdoc/passes/collect_intra_doc_links.rs +++ b/src/librustdoc/passes/collect_intra_doc_links.rs @@ -847,18 +847,12 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> { // FIXME(jynelson): this shouldn't go through stringification, rustdoc should just use the DefId directly let self_name = self_id.and_then(|self_id| { - use ty::TyKind; if matches!(self.cx.tcx.def_kind(self_id), DefKind::Impl) { // using `ty.to_string()` directly has issues with shortening paths - // FIXME: this is a hack, isn't there a better way? let ty = self.cx.tcx.type_of(self_id); - let name = match ty.kind() { - TyKind::Adt(def, _) => Some(self.cx.tcx.item_name(def.did).to_string()), - other if other.is_primitive() => Some(ty.to_string()), - _ => None, - }; - debug!("using type_of(): {:?}", name); - name + let name = ty::print::with_crate_prefix(|| ty.to_string()); + debug!("using type_of(): {}", name); + Some(name) } else { let name = self.cx.tcx.opt_item_name(self_id).map(|sym| sym.to_string()); debug!("using item_name(): {:?}", name);