Skip to content

Commit aa8c9b0

Browse files
committed
Remove TypeKind hack in favor of with_crate_prefix
1 parent 6ab1f05 commit aa8c9b0

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/librustdoc/passes/collect_intra_doc_links.rs

+3-9
Original file line numberDiff line numberDiff line change
@@ -847,18 +847,12 @@ impl<'a, 'tcx> DocFolder for LinkCollector<'a, 'tcx> {
847847

848848
// FIXME(jynelson): this shouldn't go through stringification, rustdoc should just use the DefId directly
849849
let self_name = self_id.and_then(|self_id| {
850-
use ty::TyKind;
851850
if matches!(self.cx.tcx.def_kind(self_id), DefKind::Impl) {
852851
// using `ty.to_string()` directly has issues with shortening paths
853-
// FIXME: this is a hack, isn't there a better way?
854852
let ty = self.cx.tcx.type_of(self_id);
855-
let name = match ty.kind() {
856-
TyKind::Adt(def, _) => Some(self.cx.tcx.item_name(def.did).to_string()),
857-
other if other.is_primitive() => Some(ty.to_string()),
858-
_ => None,
859-
};
860-
debug!("using type_of(): {:?}", name);
861-
name
853+
let name = ty::print::with_crate_prefix(|| ty.to_string());
854+
debug!("using type_of(): {}", name);
855+
Some(name)
862856
} else {
863857
let name = self.cx.tcx.opt_item_name(self_id).map(|sym| sym.to_string());
864858
debug!("using item_name(): {:?}", name);

0 commit comments

Comments
 (0)