about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-03-05 19:53:45 +0000
committerbors <bors@rust-lang.org>2022-03-05 19:53:45 +0000
commitc274e4969f058b1c644243181ece9f829efa7594 (patch)
tree0ddc168615acabe0f03bfb299bc268c6a7327285
parentab2bd41ce0da79f82e7bfd281bb746a6eee21346 (diff)
parent00fd87e68ae02bb2a8b04fc00d6e9dd471470485 (diff)
downloadrust-c274e4969f058b1c644243181ece9f829efa7594.tar.gz
rust-c274e4969f058b1c644243181ece9f829efa7594.zip
Auto merge of #94648 - RalfJung:rollup-4iorcrd, r=RalfJung
Rollup of 4 pull requests

Successful merges:

 - #94630 (Update note about tier 2 docs.)
 - #94633 (Suggest removing a semicolon after derive attributes)
 - #94642 (Fix source code pages scroll)
 - #94645 (do not attempt to open cgroup files under Miri)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
-rw-r--r--compiler/rustc_parse/src/parser/item.rs10
-rw-r--r--library/std/src/sys/unix/thread.rs5
-rw-r--r--src/doc/rustc/src/platform-support.md6
-rw-r--r--src/librustdoc/html/static/js/source-script.js16
-rw-r--r--src/test/rustdoc-gui/source-anchor-scroll.goml20
-rw-r--r--src/test/rustdoc-gui/src/link_to_definition/lib.rs29
-rw-r--r--src/test/ui/parser/attr-with-a-semicolon.rs4
-rw-r--r--src/test/ui/parser/attr-with-a-semicolon.stderr14
8 files changed, 93 insertions, 11 deletions
diff --git a/compiler/rustc_parse/src/parser/item.rs b/compiler/rustc_parse/src/parser/item.rs
index ae46bfe3540..4f91f1fecba 100644
--- a/compiler/rustc_parse/src/parser/item.rs
+++ b/compiler/rustc_parse/src/parser/item.rs
@@ -449,6 +449,16 @@ impl<'a> Parser<'a> {
         if end.is_doc_comment() {
             err.span_label(end.span, "this doc comment doesn't document anything");
         }
+        if end.meta_kind().is_some() {
+            if self.token.kind == TokenKind::Semi {
+                err.span_suggestion_verbose(
+                    self.token.span,
+                    "consider removing this semicolon",
+                    String::new(),
+                    Applicability::MaybeIncorrect,
+                );
+            }
+        }
         if let [.., penultimate, _] = attrs {
             err.span_label(start.span.to(penultimate.span), "other attributes here");
         }
diff --git a/library/std/src/sys/unix/thread.rs b/library/std/src/sys/unix/thread.rs
index ff01ce27333..2d5d306ed62 100644
--- a/library/std/src/sys/unix/thread.rs
+++ b/library/std/src/sys/unix/thread.rs
@@ -384,6 +384,11 @@ fn cgroup2_quota() -> usize {
     use crate::path::PathBuf;
 
     let mut quota = usize::MAX;
+    if cfg!(miri) {
+        // Attempting to open a file fails under default flags due to isolation.
+        // And Miri does not have parallelism anyway.
+        return quota;
+    }
 
     let _: Option<()> = try {
         let mut buf = Vec::with_capacity(128);
diff --git a/src/doc/rustc/src/platform-support.md b/src/doc/rustc/src/platform-support.md
index 4c05818440b..7a00b048a9b 100644
--- a/src/doc/rustc/src/platform-support.md
+++ b/src/doc/rustc/src/platform-support.md
@@ -73,7 +73,8 @@ Tier Policy.
 
 All tier 2 targets with host tools support the full standard library.
 
-**NOTE:** Tier 2 targets currently do not build the `rust-docs` component.
+**NOTE:** The `rust-docs` component is not usually built for tier 2 targets,
+so Rustup may install the documentation for a similar tier 1 target instead.
 
 target | notes
 -------|-------
@@ -114,7 +115,8 @@ The `std` column in the table below has the following meanings:
 
 [`no_std`]: https://rust-embedded.github.io/book/intro/no-std.html
 
-**NOTE:** Tier 2 targets currently do not build the `rust-docs` component.
+**NOTE:** The `rust-docs` component is not usually built for tier 2 targets,
+so Rustup may install the documentation for a similar tier 1 target instead.
 
 target | std | notes
 -------|:---:|-------
diff --git a/src/librustdoc/html/static/js/source-script.js b/src/librustdoc/html/static/js/source-script.js
index 90490acccfd..aa77e62ba5a 100644
--- a/src/librustdoc/html/static/js/source-script.js
+++ b/src/librustdoc/html/static/js/source-script.js
@@ -149,7 +149,7 @@ function createSourceSidebar() {
 
 var lineNumbersRegex = /^#?(\d+)(?:-(\d+))?$/;
 
-function highlightSourceLines(scrollTo, match) {
+function highlightSourceLines(match) {
     if (typeof match === "undefined") {
         match = window.location.hash.match(lineNumbersRegex);
     }
@@ -170,11 +170,9 @@ function highlightSourceLines(scrollTo, match) {
     if (!elem) {
         return;
     }
-    if (scrollTo) {
-        var x = document.getElementById(from);
-        if (x) {
-            x.scrollIntoView();
-        }
+    var x = document.getElementById(from);
+    if (x) {
+        x.scrollIntoView();
     }
     onEachLazy(document.getElementsByClassName("line-numbers"), function(e) {
         onEachLazy(e.getElementsByTagName("span"), function(i_e) {
@@ -198,7 +196,7 @@ var handleSourceHighlight = (function() {
             y = window.scrollY;
         if (searchState.browserSupportsHistoryApi()) {
             history.replaceState(null, null, "#" + name);
-            highlightSourceLines(true);
+            highlightSourceLines();
         } else {
             location.replace("#" + name);
         }
@@ -230,7 +228,7 @@ var handleSourceHighlight = (function() {
 window.addEventListener("hashchange", function() {
     var match = window.location.hash.match(lineNumbersRegex);
     if (match) {
-        return highlightSourceLines(false, match);
+        return highlightSourceLines(match);
     }
 });
 
@@ -238,7 +236,7 @@ onEachLazy(document.getElementsByClassName("line-numbers"), function(el) {
     el.addEventListener("click", handleSourceHighlight);
 });
 
-highlightSourceLines(true);
+highlightSourceLines();
 
 window.createSourceSidebar = createSourceSidebar;
 })();
diff --git a/src/test/rustdoc-gui/source-anchor-scroll.goml b/src/test/rustdoc-gui/source-anchor-scroll.goml
new file mode 100644
index 00000000000..4e51c8dcac0
--- /dev/null
+++ b/src/test/rustdoc-gui/source-anchor-scroll.goml
@@ -0,0 +1,20 @@
+// We check that when the anchor changes and is output of the displayed content,
+// the page is scrolled to it.
+goto: file://|DOC_PATH|/src/link_to_definition/lib.rs.html
+
+// We reduce the window size to make it easier to make an element "out of the page".
+size: (600, 800)
+// We check that the scroll is at the top first.
+assert-property: ("html", {"scrollTop": "0"})
+
+click: '//a[text() = "barbar"]'
+assert-property: ("html", {"scrollTop": "125"})
+click: '//a[text() = "bar"]'
+assert-property: ("html", {"scrollTop": "166"})
+click: '//a[text() = "sub_fn"]'
+assert-property: ("html", {"scrollTop": "53"})
+
+// We now check that clicking on lines doesn't change the scroll
+// Extra information: the "sub_fn" function header is on line 1.
+click: '//*[@id="6"]'
+assert-property: ("html", {"scrollTop": "53"})
diff --git a/src/test/rustdoc-gui/src/link_to_definition/lib.rs b/src/test/rustdoc-gui/src/link_to_definition/lib.rs
index de9ee66a2ba..419a9cceec5 100644
--- a/src/test/rustdoc-gui/src/link_to_definition/lib.rs
+++ b/src/test/rustdoc-gui/src/link_to_definition/lib.rs
@@ -1,6 +1,35 @@
+pub fn sub_fn() {
+    barbar();
+}
+fn barbar() {
+    bar(vec![], vec![], vec![], vec![], Bar { a: "a".into(), b: 0 });
+}
+
 pub struct Bar {
     pub a: String,
     pub b: u32,
 }
 
 pub fn foo(_b: &Bar) {}
+
+// The goal now is to add
+// a lot of lines so
+// that the next content
+// will be out of the screen
+// to allow us to test that
+// if the anchor changes to
+// something outside of the
+// current view, it'll
+// scroll to it as expected.
+
+// More filling content.
+
+pub fn bar(
+  _a: Vec<String>,
+  _b: Vec<String>,
+  _c: Vec<String>,
+  _d: Vec<String>,
+  _e: Bar,
+) {
+    sub_fn();
+}
diff --git a/src/test/ui/parser/attr-with-a-semicolon.rs b/src/test/ui/parser/attr-with-a-semicolon.rs
new file mode 100644
index 00000000000..56fe40b916b
--- /dev/null
+++ b/src/test/ui/parser/attr-with-a-semicolon.rs
@@ -0,0 +1,4 @@
+#[derive(Debug, Clone)]; //~ERROR expected item after attributes
+struct Foo;
+
+fn main() {}
diff --git a/src/test/ui/parser/attr-with-a-semicolon.stderr b/src/test/ui/parser/attr-with-a-semicolon.stderr
new file mode 100644
index 00000000000..49ed30150d0
--- /dev/null
+++ b/src/test/ui/parser/attr-with-a-semicolon.stderr
@@ -0,0 +1,14 @@
+error: expected item after attributes
+  --> $DIR/attr-with-a-semicolon.rs:1:1
+   |
+LL | #[derive(Debug, Clone)];
+   | ^^^^^^^^^^^^^^^^^^^^^^^
+   |
+help: consider removing this semicolon
+   |
+LL - #[derive(Debug, Clone)];
+LL + #[derive(Debug, Clone)]
+   | 
+
+error: aborting due to previous error
+