Skip to content

Commit 9fd4551

Browse files
committed
Rollup merge of rust-lang#22578 - nagisa:deprecated-fallout, r=alexcrichton
Fixes rust-lang#22575 Fixes rust-lang#22618
2 parents e1c2f77 + d99af37 commit 9fd4551

File tree

1 file changed

+15
-12
lines changed

1 file changed

+15
-12
lines changed

src/librustdoc/html/format.rs

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use clean;
2525
use stability_summary::ModuleSummary;
2626
use html::item_type::ItemType;
2727
use html::render;
28+
use html::escape::Escape;
2829
use html::render::{cache, CURRENT_LOCATION_KEY};
2930

3031
/// Helper to render an optional visibility with a space after it (if the
@@ -710,13 +711,14 @@ impl<'a> fmt::Display for Stability<'a> {
710711
let Stability(stab) = *self;
711712
match *stab {
712713
Some(ref stability) => {
714+
let lvl = if stability.deprecated_since.is_empty() {
715+
format!("{}", stability.level)
716+
} else {
717+
"Deprecated".to_string()
718+
};
713719
write!(f, "<a class='stability {lvl}' title='{reason}'>{lvl}</a>",
714-
lvl = if stability.deprecated_since.is_empty() {
715-
format!("{}", stability.level)
716-
} else {
717-
"Deprecated".to_string()
718-
},
719-
reason = stability.reason)
720+
lvl = Escape(&*lvl),
721+
reason = Escape(&*stability.reason))
720722
}
721723
None => Ok(())
722724
}
@@ -728,14 +730,15 @@ impl<'a> fmt::Display for ConciseStability<'a> {
728730
let ConciseStability(stab) = *self;
729731
match *stab {
730732
Some(ref stability) => {
733+
let lvl = if stability.deprecated_since.is_empty() {
734+
format!("{}", stability.level)
735+
} else {
736+
"Deprecated".to_string()
737+
};
731738
write!(f, "<a class='stability {lvl}' title='{lvl}{colon}{reason}'></a>",
732-
lvl = if stability.deprecated_since.is_empty() {
733-
format!("{}", stability.level)
734-
} else {
735-
"Deprecated".to_string()
736-
},
739+
lvl = Escape(&*lvl),
737740
colon = if stability.reason.len() > 0 { ": " } else { "" },
738-
reason = stability.reason)
741+
reason = Escape(&*stability.reason))
739742
}
740743
None => {
741744
write!(f, "<a class='stability Unmarked' title='No stability level'></a>")

0 commit comments

Comments
 (0)