Skip to content

Commit 03301ef

Browse files
committed
Auto merge of #84246 - notriddle:rustdoc-path-printing-cleanup, r=jyn514
rustdoc: get rid of unused path printing code The code for printing a raw path is only used in utils.rs, which only prints the alternative (non-HTML) format. Path has a function that does the same thing without HTML support, so use that instead.
2 parents 080d302 + 6109cee commit 03301ef

File tree

2 files changed

+1
-43
lines changed

2 files changed

+1
-43
lines changed

src/librustdoc/clean/utils.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ crate fn resolve_type(cx: &mut DocContext<'_>, path: Path, id: hir::HirId) -> Ty
401401
return Generic(kw::SelfUpper);
402402
}
403403
Res::Def(DefKind::TyParam, _) if path.segments.len() == 1 => {
404-
return Generic(Symbol::intern(&format!("{:#}", path.print(&cx.cache, cx.tcx))));
404+
return Generic(Symbol::intern(&path.whole_name()));
405405
}
406406
Res::SelfTy(..) | Res::Def(DefKind::TyParam | DefKind::AssocTy, _) => true,
407407
_ => false,

src/librustdoc/html/format.rs

-42
Original file line numberDiff line numberDiff line change
@@ -453,48 +453,6 @@ impl clean::GenericArgs {
453453
}
454454
}
455455

456-
impl clean::PathSegment {
457-
crate fn print<'a, 'tcx: 'a>(
458-
&'a self,
459-
cache: &'a Cache,
460-
tcx: TyCtxt<'tcx>,
461-
) -> impl fmt::Display + 'a + Captures<'tcx> {
462-
display_fn(move |f| {
463-
if f.alternate() {
464-
write!(f, "{}{:#}", self.name, self.args.print(cache, tcx))
465-
} else {
466-
write!(f, "{}{}", self.name, self.args.print(cache, tcx))
467-
}
468-
})
469-
}
470-
}
471-
472-
impl clean::Path {
473-
crate fn print<'a, 'tcx: 'a>(
474-
&'a self,
475-
cache: &'a Cache,
476-
tcx: TyCtxt<'tcx>,
477-
) -> impl fmt::Display + 'a + Captures<'tcx> {
478-
display_fn(move |f| {
479-
if self.global {
480-
f.write_str("::")?
481-
}
482-
483-
for (i, seg) in self.segments.iter().enumerate() {
484-
if i > 0 {
485-
f.write_str("::")?
486-
}
487-
if f.alternate() {
488-
write!(f, "{:#}", seg.print(cache, tcx))?;
489-
} else {
490-
write!(f, "{}", seg.print(cache, tcx))?;
491-
}
492-
}
493-
Ok(())
494-
})
495-
}
496-
}
497-
498456
crate fn href(did: DefId, cache: &Cache) -> Option<(String, ItemType, Vec<String>)> {
499457
if !did.is_local() && !cache.access_levels.is_public(did) && !cache.document_private {
500458
return None;

0 commit comments

Comments
 (0)