From 30f75e396a82d9c84372d14708822d68f7cd36b3 Mon Sep 17 00:00:00 2001 From: Andy Russell Date: Sun, 13 Nov 2016 15:56:23 -0500 Subject: [PATCH] do not use deprecated text for unstable docs --- src/librustdoc/clean/mod.rs | 16 +++++++++------- src/librustdoc/html/render.rs | 13 +++++++++---- src/libsyntax/attr.rs | 3 --- src/test/rustdoc/issue-32374.rs | 10 ++++++++++ 4 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/librustdoc/clean/mod.rs b/src/librustdoc/clean/mod.rs index f4df28a1476..4d70c64634f 100644 --- a/src/librustdoc/clean/mod.rs +++ b/src/librustdoc/clean/mod.rs @@ -2890,7 +2890,8 @@ pub struct Stability { pub feature: String, pub since: String, pub deprecated_since: String, - pub reason: String, + pub deprecated_reason: String, + pub unstable_reason: String, pub issue: Option } @@ -2913,12 +2914,13 @@ impl Clean for attr::Stability { Some(attr::RustcDeprecation {ref since, ..}) => since.to_string(), _=> "".to_string(), }, - reason: { - match (&self.rustc_depr, &self.level) { - (&Some(ref depr), _) => depr.reason.to_string(), - (&None, &attr::Unstable {reason: Some(ref reason), ..}) => reason.to_string(), - _ => "".to_string(), - } + deprecated_reason: match self.rustc_depr { + Some(ref depr) => depr.reason.to_string(), + _ => "".to_string(), + }, + unstable_reason: match self.level { + attr::Unstable { reason: Some(ref reason), .. } => reason.to_string(), + _ => "".to_string(), }, issue: match self.level { attr::Unstable {issue, ..} => Some(issue), diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs index 5aed37edbd4..90f954aa86a 100644 --- a/src/librustdoc/html/render.rs +++ b/src/librustdoc/html/render.rs @@ -1878,8 +1878,8 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec Vec{}", text)) }; @@ -1909,7 +1909,12 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec{}", text)) }; } else if let Some(depr) = item.deprecation.as_ref() { diff --git a/src/libsyntax/attr.rs b/src/libsyntax/attr.rs index 57a936bf9b0..2977e340a3c 100644 --- a/src/libsyntax/attr.rs +++ b/src/libsyntax/attr.rs @@ -789,9 +789,6 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler, // Merge the deprecation info into the stability info if let Some(rustc_depr) = rustc_depr { if let Some(ref mut stab) = stab { - if let Unstable {reason: ref mut reason @ None, ..} = stab.level { - *reason = Some(rustc_depr.reason.clone()) - } stab.rustc_depr = Some(rustc_depr); } else { span_err!(diagnostic, item_sp, E0549, diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs index 262a1ffce74..dea73317e5e 100644 --- a/src/test/rustdoc/issue-32374.rs +++ b/src/test/rustdoc/issue-32374.rs @@ -20,6 +20,16 @@ // 'Deprecated since 1.0.0: text' // @has - 'test' // @has - '#32374' +// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \ +// 'Unstable \(test #32374\)$' #[rustc_deprecated(since = "1.0.0", reason = "text")] #[unstable(feature = "test", issue = "32374")] pub struct T; + +// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \ +// 'Deprecated since 1.0.0: deprecated' +// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \ +// 'Unstable (test #32374): unstable' +#[rustc_deprecated(since = "1.0.0", reason = "deprecated")] +#[unstable(feature = "test", issue = "32374", reason = "unstable")] +pub struct U;