diff --git a/src/librustdoc/html/markdown.rs b/src/librustdoc/html/markdown.rs
index 8633d2a1c2e..9fd476bfbab 100644
--- a/src/librustdoc/html/markdown.rs
+++ b/src/librustdoc/html/markdown.rs
@@ -250,7 +250,9 @@ pub fn render(w: &mut fmt::Formatter, s: &str, print_toc: bool) -> fmt::Result {
let text = lines.collect::>().join("\n");
if rendered { return }
PLAYGROUND_KRATE.with(|krate| {
- let mut s = String::new();
+ // insert newline to clearly separate it from the
+ // previous block so we can shorten the html output
+ let mut s = String::from("\n");
krate.borrow().as_ref().map(|krate| {
let test = origtext.lines().map(|l| {
stripped_filtered_line(l).unwrap_or(l)
diff --git a/src/librustdoc/html/render.rs b/src/librustdoc/html/render.rs
index d7100f9f220..af6dec8dc86 100644
--- a/src/librustdoc/html/render.rs
+++ b/src/librustdoc/html/render.rs
@@ -1657,8 +1657,8 @@ fn shorter<'a>(s: Option<&'a str>) -> String {
#[inline]
fn plain_summary_line(s: Option<&str>) -> String {
- let md = markdown::plain_summary_line(s.unwrap_or(""));
- shorter(Some(&md)).replace("\n", " ")
+ let line = shorter(s).replace("\n", " ");
+ markdown::plain_summary_line(&line[..])
}
fn document(w: &mut fmt::Formatter, cx: &Context, item: &clean::Item) -> fmt::Result {
diff --git a/src/test/rustdoc/issue-31899.rs b/src/test/rustdoc/issue-31899.rs
new file mode 100644
index 00000000000..0722dc4e052
--- /dev/null
+++ b/src/test/rustdoc/issue-31899.rs
@@ -0,0 +1,70 @@
+// 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.
+
+
+// @has issue_31899/index.html
+// @has - 'Make this line a bit longer.'
+// @!has - 'rust rust-example-rendered'
+// @!has - 'use ndarray::arr2'
+// @!has - 'prohibited'
+
+/// A tuple or fixed size array that can be used to index an array.
+/// Make this line a bit longer.
+///
+/// ```
+/// use ndarray::arr2;
+///
+/// let mut a = arr2(&[[0, 1], [0, 0]]);
+/// a[[1, 1]] = 1;
+/// assert_eq!(a[[0, 1]], 1);
+/// assert_eq!(a[[1, 1]], 1);
+/// ```
+///
+/// **Note** the blanket implementation that's not visible in rustdoc:
+/// `impl NdIndex for D where D: Dimension { ... }`
+pub fn bar() {}
+
+/// Some line
+///
+/// # prohibited
+pub fn foo() {}
+
+/// Some line
+///
+/// 1. prohibited
+/// 2. bar
+pub fn baz() {}
+
+/// Some line
+///
+/// - prohibited
+/// - bar
+pub fn qux() {}
+
+/// Some line
+///
+/// * prohibited
+/// * bar
+pub fn quz() {}
+
+/// Some line
+///
+/// > prohibited
+/// > bar
+pub fn qur() {}
+
+/// Some line
+///
+/// prohibited
+/// =====
+///
+/// Second
+/// ------
+pub fn qut() {}