diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index 824265bc3b3..6b128467770 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1640,8 +1640,8 @@ fn plain_summary_line(s: Option<&str>) -> String {
}
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
- if let Some(s) = short_stability(item, cx, true) {
- write!(w, "
{}
", s)?;
+ for stability in short_stability(item, cx, true) {
+ write!(w, "{}
", stability)?;
}
if let Some(s) = item.doc_value() {
write!(w, "{}
", Markdown(s))?;
@@ -1761,8 +1761,15 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
_ => {
if myitem.name.is_none() { continue }
- let stab_docs = if let Some(s) = short_stability(myitem, cx, false) {
- format!("[{}]", s)
+
+ let stabilities = short_stability(myitem, cx, false);
+
+ let stab_docs = if !stabilities.is_empty() {
+ stabilities.iter()
+ .map(|s| format!("[{}]", s))
+ .collect::>()
+ .as_slice()
+ .join(" ")
} else {
String::new()
};
@@ -1789,21 +1796,26 @@ fn item_module(w: &mut fmt::Formatter, cx: &Context,
write!(w, "")
}
-fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Option {
- item.stability.as_ref().and_then(|stab| {
+fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Vec {
+ let mut stability = vec![];
+
+ if let Some(stab) = item.stability.as_ref() {
let reason = if show_reason && !stab.reason.is_empty() {
format!(": {}", stab.reason)
} else {
String::new()
};
- let text = if !stab.deprecated_since.is_empty() {
+ if !stab.deprecated_since.is_empty() {
let since = if show_reason {
format!(" since {}", Escape(&stab.deprecated_since))
} else {
String::new()
};
- format!("Deprecated{}{}", since, Markdown(&reason))
- } else if stab.level == stability::Unstable {
+ let text = format!("Deprecated{}{}", since, Markdown(&reason));
+ stability.push(format!("{}", text))
+ };
+
+ if stab.level == stability::Unstable {
let unstable_extra = if show_reason {
match (!stab.feature.is_empty(), &cx.shared.issue_tracker_base_url, stab.issue) {
(true, &Some(ref tracker_url), Some(issue_no)) if issue_no > 0 =>
@@ -1819,29 +1831,26 @@ fn short_stability(item: &clean::Item, cx: &Context, show_reason: bool) -> Optio
} else {
String::new()
};
- format!("Unstable{}{}", unstable_extra, Markdown(&reason))
- } else {
- return None
+ let text = format!("Unstable{}{}", unstable_extra, Markdown(&reason));
+ stability.push(format!("{}", text))
+ };
+ } else if let Some(depr) = item.deprecation.as_ref() {
+ let note = if show_reason && !depr.note.is_empty() {
+ format!(": {}", depr.note)
+ } else {
+ String::new()
+ };
+ let since = if show_reason && !depr.since.is_empty() {
+ format!(" since {}", Escape(&depr.since))
+ } else {
+ String::new()
};
- Some(format!("{}",
- item.stability_class(), text))
- }).or_else(|| {
- item.deprecation.as_ref().and_then(|depr| {
- let note = if show_reason && !depr.note.is_empty() {
- format!(": {}", depr.note)
- } else {
- String::new()
- };
- let since = if show_reason && !depr.since.is_empty() {
- format!(" since {}", Escape(&depr.since))
- } else {
- String::new()
- };
- let text = format!("Deprecated{}{}", since, Markdown(¬e));
- Some(format!("{}", text))
- })
- })
+ let text = format!("Deprecated{}{}", since, Markdown(¬e));
+ stability.push(format!("{}", text))
+ }
+
+ stability
}
struct Initializer<'a>(&'a str);
diff --git a/src/test/rustdoc/issue-32374.rs b/src/test/rustdoc/issue-32374.rs
new file mode 100644
index 00000000000..cdb4094ffe0
--- /dev/null
+++ b/src/test/rustdoc/issue-32374.rs
@@ -0,0 +1,25 @@
+// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 or the MIT license
+// , at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+#![feature(staged_api)]
+#![doc(issue_tracker_base_url = "http://issue_url/")]
+
+#![unstable(feature="test", issue = "32374")]
+
+// @has issue_32374/index.html '//*[@class="docblock short"]' \
+// '[Deprecated] [Unstable]'
+
+// @has issue_32374/struct.T.html '//*[@class="stab deprecated"]' \
+// 'Deprecated since 1.0.0: text'
+// @has - 'test
'
+// @has - '#32374'
+#[rustc_deprecated(since = "1.0.0", reason = "text")]
+#[unstable(feature = "test", issue = "32374")]
+pub struct T;