Skip to content

File tree

4 files changed

+28
-14
lines changed

4 files changed

+28
-14
lines changed

src/librustdoc/clean/mod.rs

+9-7
Original file line numberDiff line numberDiff line change
@@ -2890,7 +2890,8 @@ pub struct Stability {
28902890
pub feature: String,
28912891
pub since: String,
28922892
pub deprecated_since: String,
2893-
pub reason: String,
2893+
pub deprecated_reason: String,
2894+
pub unstable_reason: String,
28942895
pub issue: Option<u32>
28952896
}
28962897

@@ -2913,12 +2914,13 @@ impl Clean<Stability> for attr::Stability {
29132914
Some(attr::RustcDeprecation {ref since, ..}) => since.to_string(),
29142915
_=> "".to_string(),
29152916
},
2916-
reason: {
2917-
match (&self.rustc_depr, &self.level) {
2918-
(&Some(ref depr), _) => depr.reason.to_string(),
2919-
(&None, &attr::Unstable {reason: Some(ref reason), ..}) => reason.to_string(),
2920-
_ => "".to_string(),
2921-
}
2917+
deprecated_reason: match self.rustc_depr {
2918+
Some(ref depr) => depr.reason.to_string(),
2919+
_ => "".to_string(),
2920+
},
2921+
unstable_reason: match self.level {
2922+
attr::Unstable { reason: Some(ref reason), .. } => reason.to_string(),
2923+
_ => "".to_string(),
29222924
},
29232925
issue: match self.level {
29242926
attr::Unstable {issue, ..} => Some(issue),

src/librustdoc/html/render.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1878,8 +1878,8 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18781878
let mut stability = vec![];
18791879

18801880
if let Some(stab) = item.stability.as_ref() {
1881-
let reason = if show_reason && !stab.reason.is_empty() {
1882-
format!(": {}", stab.reason)
1881+
let deprecated_reason = if show_reason && !stab.deprecated_reason.is_empty() {
1882+
format!(": {}", stab.deprecated_reason)
18831883
} else {
18841884
String::new()
18851885
};
@@ -1889,7 +1889,7 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
18891889
} else {
18901890
String::new()
18911891
};
1892-
let text = format!("Deprecated{}{}", since, Markdown(&reason));
1892+
let text = format!("Deprecated{}{}", since, Markdown(&deprecated_reason));
18931893
stability.push(format!("<em class='stab deprecated'>{}</em>", text))
18941894
};
18951895

@@ -1909,7 +1909,12 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec<S
19091909
} else {
19101910
String::new()
19111911
};
1912-
let text = format!("Unstable{}{}", unstable_extra, Markdown(&reason));
1912+
let unstable_reason = if show_reason && !stab.unstable_reason.is_empty() {
1913+
format!(": {}", stab.unstable_reason)
1914+
} else {
1915+
String::new()
1916+
};
1917+
let text = format!("Unstable{}{}", unstable_extra, Markdown(&unstable_reason));
19131918
stability.push(format!("<em class='stab unstable'>{}</em>", text))
19141919
};
19151920
} else if let Some(depr) = item.deprecation.as_ref() {

src/libsyntax/attr.rs

-3
Original file line numberDiff line numberDiff line change
@@ -789,9 +789,6 @@ fn find_stability_generic<'a, I>(diagnostic: &Handler,
789789
// Merge the deprecation info into the stability info
790790
if let Some(rustc_depr) = rustc_depr {
791791
if let Some(ref mut stab) = stab {
792-
if let Unstable {reason: ref mut reason @ None, ..} = stab.level {
793-
*reason = Some(rustc_depr.reason.clone())
794-
}
795792
stab.rustc_depr = Some(rustc_depr);
796793
} else {
797794
span_err!(diagnostic, item_sp, E0549,

src/test/rustdoc/issue-32374.rs

+10
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,16 @@
2020
// 'Deprecated since 1.0.0: text'
2121
// @has - '<code>test</code>'
2222
// @has - '<a href="http://issue_url/32374">#32374</a>'
23+
// @matches issue_32374/struct.T.html '//*[@class="stab unstable"]' \
24+
// 'Unstable \(test #32374\)$'
2325
#[rustc_deprecated(since = "1.0.0", reason = "text")]
2426
#[unstable(feature = "test", issue = "32374")]
2527
pub struct T;
28+
29+
// @has issue_32374/struct.U.html '//*[@class="stab deprecated"]' \
30+
// 'Deprecated since 1.0.0: deprecated'
31+
// @has issue_32374/struct.U.html '//*[@class="stab unstable"]' \
32+
// 'Unstable (test #32374): unstable'
33+
#[rustc_deprecated(since = "1.0.0", reason = "deprecated")]
34+
#[unstable(feature = "test", issue = "32374", reason = "unstable")]
35+
pub struct U;

0 commit comments

Comments
 (0)