Skip to content

Commit 2a8a25b

Browse files
committed
Display "Deprecation planned" in rustdoc for future rustc deprecations
1 parent 87cd09b commit 2a8a25b

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

src/librustdoc/html/render.rs

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2817,7 +2817,17 @@ fn stability_tags(item: &clean::Item) -> String {
28172817

28182818
// The trailing space after each tag is to space it properly against the rest of the docs.
28192819
if item.deprecation().is_some() {
2820-
tags += &tag_html("deprecated", "Deprecated");
2820+
let mut message = "Deprecated";
2821+
if let Some(ref stab) = item.stability {
2822+
if let Some(ref depr) = stab.deprecation {
2823+
if let Some(ref since) = depr.since {
2824+
if !stability::deprecation_in_effect(&since) {
2825+
message = "Deprecation planned";
2826+
}
2827+
}
2828+
}
2829+
}
2830+
tags += &tag_html("deprecated", message);
28212831
}
28222832

28232833
if let Some(stab) = item
@@ -2848,15 +2858,18 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
28482858
if let Some(Deprecation { note, .. }) = &item.deprecation() {
28492859
// We display deprecation messages for #[deprecated] and #[rustc_deprecated]
28502860
// but only display the future-deprecation messages for #[rustc_deprecated].
2851-
let mut message = if let Some(since) = item.stability.deprecation.since {
2852-
if stability::deprecation_in_effect(since) {
2853-
format!("Deprecated since {}", Escape(since))
2854-
} else {
2855-
format!("Deprecating in {}", Escape(since))
2861+
let mut message = String::from("Deprecated");
2862+
if let Some(ref stab) = item.stability {
2863+
if let Some(ref depr) = stab.deprecation {
2864+
if let Some(ref since) = depr.since {
2865+
if stability::deprecation_in_effect(&since) {
2866+
message = format!("Deprecated since {}", Escape(&since));
2867+
} else {
2868+
message = format!("Deprecating in {}", Escape(&since));
2869+
}
2870+
}
28562871
}
2857-
} else {
2858-
String::from("Deprecated")
2859-
};
2872+
}
28602873

28612874
if let Some(note) = note {
28622875
let mut ids = cx.id_map.borrow_mut();

0 commit comments

Comments
 (0)