1
Fork 0

Rollup merge of #58202 - varkor:deprecated-future-external, r=GuillaumeGomez

Ignore future deprecations in #[deprecated]

The future deprecation warnings should only apply to `#[rustc_deprecated]` as they take into account rustc's version. Fixes #57952.

I've also slightly modified rustdoc's display of future deprecation notices to make it more consistent, so I'm assigning a rustdoc team member for review to make sure this is okay.

r? @GuillaumeGomez
This commit is contained in:
Mazdak Farrokhzad 2019-02-13 18:12:30 +01:00 committed by GitHub
commit 193c3773c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 134 additions and 92 deletions

View file

@ -2823,7 +2823,17 @@ fn stability_tags(item: &clean::Item) -> String {
// The trailing space after each tag is to space it properly against the rest of the docs.
if item.deprecation().is_some() {
tags += &tag_html("deprecated", "Deprecated");
let mut message = "Deprecated";
if let Some(ref stab) = item.stability {
if let Some(ref depr) = stab.deprecation {
if let Some(ref since) = depr.since {
if !stability::deprecation_in_effect(&since) {
message = "Deprecation planned";
}
}
}
}
tags += &tag_html("deprecated", message);
}
if let Some(stab) = item
@ -2851,16 +2861,23 @@ fn short_stability(item: &clean::Item, cx: &Context) -> Vec<String> {
let mut stability = vec![];
let error_codes = ErrorCodes::from(UnstableFeatures::from_environment().is_nightly_build());
if let Some(Deprecation { since, note }) = &item.deprecation() {
if let Some(Deprecation { note, since }) = &item.deprecation() {
// We display deprecation messages for #[deprecated] and #[rustc_deprecated]
// but only display the future-deprecation messages for #[rustc_deprecated].
let mut message = if let Some(since) = since {
if stability::deprecation_in_effect(since) {
format!("Deprecated since {}", Escape(since))
} else {
format!("Deprecating in {}", Escape(since))
}
format!("Deprecated since {}", Escape(since))
} else {
String::from("Deprecated")
};
if let Some(ref stab) = item.stability {
if let Some(ref depr) = stab.deprecation {
if let Some(ref since) = depr.since {
if !stability::deprecation_in_effect(&since) {
message = format!("Deprecating in {}", Escape(&since));
}
}
}
}
if let Some(note) = note {
let mut ids = cx.id_map.borrow_mut();