diff --git a/src/librustdoc/html/static/main.js b/src/librustdoc/html/static/main.js
index 5e78e8fe5694c..88c25567d2963 100644
--- a/src/librustdoc/html/static/main.js
+++ b/src/librustdoc/html/static/main.js
@@ -223,7 +223,25 @@
}
}
}
- highlightSourceLines(null);
+
+ function expandSection(id) {
+ var elem = document.getElementById(id);
+ if (elem && isHidden(elem)) {
+ var h3 = elem.parentNode.previousSibling;
+ if (h3 && h3.tagName !== 'H3') {
+ h3 = h3.previousSibling; // skip div.docblock
+ }
+
+ if (h3) {
+ var collapses = h3.getElementsByClassName("collapse-toggle");
+ if (collapses.length > 0) {
+ // The element is not visible, we need to make it appear!
+ collapseDocs(collapses[0], "show");
+ }
+ }
+ }
+ }
+
window.onhashchange = highlightSourceLines;
// Gets the human-readable string for the virtual-key code of the
@@ -317,6 +335,15 @@
}
}
+ function findParentElement(elem, tagName) {
+ do {
+ if (elem && elem.tagName === tagName) {
+ return elem;
+ }
+ } while (elem = elem.parentNode);
+ return null;
+ }
+
document.onkeypress = handleShortcut;
document.onkeydown = handleShortcut;
document.onclick = function(ev) {
@@ -354,6 +381,13 @@
} else if (!hasClass(document.getElementById("help"), "hidden")) {
addClass(document.getElementById("help"), "hidden");
removeClass(document.body, "blur");
+ } else {
+ // Making a collapsed element visible on onhashchange seems
+ // too late
+ var a = findParentElement(ev.target, 'A');
+ if (a && a.hash) {
+ expandSection(a.hash.replace(/^#/, ''));
+ }
}
};
@@ -2213,21 +2247,7 @@
autoCollapse(getPageId(), getCurrentValue("rustdoc-collapse") === "true");
if (window.location.hash && window.location.hash.length > 0) {
- var hash = getPageId();
- if (hash !== null) {
- var elem = document.getElementById(hash);
- if (elem && elem.offsetParent === null) {
- if (elem.parentNode && elem.parentNode.previousSibling) {
- var collapses = elem.parentNode
- .previousSibling
- .getElementsByClassName("collapse-toggle");
- if (collapses.length > 0) {
- // The element is not visible, we need to make it appear!
- collapseDocs(collapses[0], "show");
- }
- }
- }
- }
+ expandSection(window.location.hash.replace(/^#/, ''));
}
}());
diff --git a/src/librustdoc/html/static/rustdoc.css b/src/librustdoc/html/static/rustdoc.css
index 57a111daa8977..ffe6a40b36998 100644
--- a/src/librustdoc/html/static/rustdoc.css
+++ b/src/librustdoc/html/static/rustdoc.css
@@ -497,6 +497,19 @@ h4 > code, h3 > code, .invisible > code {
font-size: 90%;
}
+.content .stability {
+ position: relative;
+ margin-left: 33px;
+ margin-top: -13px;
+}
+.content .stability::before {
+ content: '˪';
+ font-size: 30px;
+ position: absolute;
+ top: -9px;
+ left: -13px;
+}
+
nav {
border-bottom: 1px solid;
padding-bottom: 10px;
@@ -545,10 +558,8 @@ a {
left: -5px;
}
.small-section-header > .anchor {
- left: -20px;
-}
-.small-section-header > .anchor:not(.field) {
left: -28px;
+ padding-right: 10px; /* avoid gap that causes hover to disappear */
}
.anchor:before {
content: '\2002\00a7\2002';
@@ -745,6 +756,7 @@ a.test-arrow:hover{
.section-header:hover a:before {
position: absolute;
left: -25px;
+ padding-right: 10px; /* avoid gap that causes hover to disappear */
content: '\2002\00a7\2002';
}
diff --git a/src/libstd/keyword_docs.rs b/src/libstd/keyword_docs.rs
index 4f6bda6cfe379..d70cf132b3c3a 100644
--- a/src/libstd/keyword_docs.rs
+++ b/src/libstd/keyword_docs.rs
@@ -56,3 +56,24 @@ mod fn_keyword { }
///
/// [book]: https://doc.rust-lang.org/book/second-edition/ch03-01-variables-and-mutability.html
mod let_keyword { }
+
+#[doc(keyword = "struct")]
+//
+/// The `struct` keyword.
+///
+/// The `struct` keyword is used to define a struct type.
+///
+/// Example:
+///
+/// ```
+/// struct Foo {
+/// field1: u32,
+/// field2: String,
+/// }
+/// ```
+///
+/// There are different kinds of structs. For more information, take a look at the
+/// [Rust Book][book].
+///
+/// [book]: https://doc.rust-lang.org/book/second-edition/ch05-01-defining-structs.html
+mod struct_keyword { }
diff --git a/src/libtest/formatters/terse.rs b/src/libtest/formatters/terse.rs
index 22a06b9f605db..6f7dfee53facc 100644
--- a/src/libtest/formatters/terse.rs
+++ b/src/libtest/formatters/terse.rs
@@ -18,6 +18,7 @@ pub(crate) struct TerseFormatter {
max_name_len: usize,
test_count: usize,
+ total_test_count: usize,
}
impl TerseFormatter {
@@ -33,6 +34,7 @@ impl TerseFormatter {
max_name_len,
is_multithreaded,
test_count: 0,
+ total_test_count: 0, // initialized later, when write_run_start is called
}
}
@@ -66,7 +68,8 @@ impl TerseFormatter {
// we insert a new line every 100 dots in order to flush the
// screen when dealing with line-buffered output (e.g. piping to
// `stamp` in the rust CI).
- self.write_plain("\n")?;
+ let out = format!(" {}/{}\n", self.test_count+1, self.total_test_count);
+ self.write_plain(&out)?;
}
self.test_count += 1;
@@ -160,6 +163,7 @@ impl TerseFormatter {
impl OutputFormatter for TerseFormatter {
fn write_run_start(&mut self, test_count: usize) -> io::Result<()> {
+ self.total_test_count = test_count;
let noun = if test_count != 1 { "tests" } else { "test" };
self.write_plain(&format!("\nrunning {} {}\n", test_count, noun))
}