Skip to content

Commit 0e079c2

Browse files
Remove support for printing HRef in alternate mode
The alternate mode merely prints out the passed in text which is largely useless (as the text can simply be directly printed).
1 parent 95f5698 commit 0e079c2

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/librustdoc/html/format.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ pub struct WhereClause<'a>{
7272
}
7373

7474
pub struct HRef<'a> {
75-
pub did: DefId,
76-
pub text: &'a str,
75+
did: DefId,
76+
text: &'a str,
7777
}
7878

7979
impl<'a> VisSpace<'a> {
@@ -452,7 +452,7 @@ fn resolved_path(w: &mut fmt::Formatter<'_>, did: DefId, path: &clean::Path,
452452
}
453453
}
454454
if w.alternate() {
455-
write!(w, "{:#}{:#}", HRef::new(did, &last.name), last.args)?;
455+
write!(w, "{}{:#}", &last.name, last.args)?;
456456
} else {
457457
let path = if use_absolute {
458458
match href(did) {
@@ -538,14 +538,11 @@ impl<'a> HRef<'a> {
538538

539539
impl<'a> fmt::Display for HRef<'a> {
540540
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
541-
match href(self.did) {
542-
Some((url, shortty, fqp)) => if !f.alternate() {
543-
write!(f, "<a class=\"{}\" href=\"{}\" title=\"{} {}\">{}</a>",
544-
shortty, url, shortty, fqp.join("::"), self.text)
545-
} else {
546-
write!(f, "{}", self.text)
547-
},
548-
_ => write!(f, "{}", self.text),
541+
if let Some((url, short_ty, fqp)) = href(self.did) {
542+
write!(f, r#"<a class="{}" href="{}" title="{} {}">{}</a>"#,
543+
short_ty, url, short_ty, fqp.join("::"), self.text)
544+
} else {
545+
write!(f, "{}", self.text)
549546
}
550547
}
551548
}

0 commit comments

Comments
 (0)