Skip to content

Commit

Permalink
Auto merge of rust-lang#94648 - RalfJung:rollup-4iorcrd, r=RalfJung
Browse files Browse the repository at this point in the history
Rollup of 4 pull requests

Successful merges:

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

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
  • Loading branch information
bors committed Mar 5, 2022
2 parents ab2bd41 + 00fd87e commit c274e49
Show file tree
Hide file tree
Showing 8 changed files with 93 additions and 11 deletions.
10 changes: 10 additions & 0 deletions compiler/rustc_parse/src/parser/item.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
5 changes: 5 additions & 0 deletions library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
6 changes: 4 additions & 2 deletions src/doc/rustc/src/platform-support.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
-------|-------
Expand Down Expand Up @@ -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
-------|:---:|-------
Expand Down
16 changes: 7 additions & 9 deletions src/librustdoc/html/static/js/source-script.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand All @@ -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) {
Expand All @@ -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);
}
Expand Down Expand Up @@ -230,15 +228,15 @@ var handleSourceHighlight = (function() {
window.addEventListener("hashchange", function() {
var match = window.location.hash.match(lineNumbersRegex);
if (match) {
return highlightSourceLines(false, match);
return highlightSourceLines(match);
}
});

onEachLazy(document.getElementsByClassName("line-numbers"), function(el) {
el.addEventListener("click", handleSourceHighlight);
});

highlightSourceLines(true);
highlightSourceLines();

window.createSourceSidebar = createSourceSidebar;
})();
20 changes: 20 additions & 0 deletions src/test/rustdoc-gui/source-anchor-scroll.goml
Original file line number Diff line number Diff line change
@@ -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"})
29 changes: 29 additions & 0 deletions src/test/rustdoc-gui/src/link_to_definition/lib.rs
Original file line number Diff line number Diff line change
@@ -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();
}
4 changes: 4 additions & 0 deletions src/test/ui/parser/attr-with-a-semicolon.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#[derive(Debug, Clone)]; //~ERROR expected item after attributes
struct Foo;

fn main() {}
14 changes: 14 additions & 0 deletions src/test/ui/parser/attr-with-a-semicolon.stderr
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c274e49

Please sign in to comment.