From 80fe0bb76e601054398eb3c4763a6e9125d8101c Mon Sep 17 00:00:00 2001 From: lcnr Date: Tue, 5 Oct 2021 16:20:43 +0200 Subject: add a `rustc::query_stability` lint --- .../ui-fulldeps/internal-lints/query_stability.rs | 24 +++++++++++++ .../internal-lints/query_stability.stderr | 39 ++++++++++++++++++++++ .../internal-lints/query_stability_incorrect.rs | 15 +++++++++ .../query_stability_incorrect.stderr | 17 ++++++++++ 4 files changed, 95 insertions(+) create mode 100644 src/test/ui-fulldeps/internal-lints/query_stability.rs create mode 100644 src/test/ui-fulldeps/internal-lints/query_stability.stderr create mode 100644 src/test/ui-fulldeps/internal-lints/query_stability_incorrect.rs create mode 100644 src/test/ui-fulldeps/internal-lints/query_stability_incorrect.stderr (limited to 'src') diff --git a/src/test/ui-fulldeps/internal-lints/query_stability.rs b/src/test/ui-fulldeps/internal-lints/query_stability.rs new file mode 100644 index 00000000000..560675b4486 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/query_stability.rs @@ -0,0 +1,24 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![deny(rustc::potential_query_instability)] + +extern crate rustc_data_structures; + +use rustc_data_structures::fx::{FxHashMap, FxHashSet}; + +fn main() { + let mut x = FxHashMap::::default(); + + for _ in x.drain() {} + //~^ ERROR using `drain` can result in unstable + + for _ in x.iter() {} + //~^ ERROR using `iter` + + for _ in Some(&mut x).unwrap().iter_mut() {} + //~^ ERROR using `iter_mut` + + for _ in x {} + //~^ ERROR using `into_iter` +} diff --git a/src/test/ui-fulldeps/internal-lints/query_stability.stderr b/src/test/ui-fulldeps/internal-lints/query_stability.stderr new file mode 100644 index 00000000000..7e8b448f41a --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/query_stability.stderr @@ -0,0 +1,39 @@ +error: using `drain` can result in unstable query results + --> $DIR/query_stability.rs:13:16 + | +LL | for _ in x.drain() {} + | ^^^^^ + | +note: the lint level is defined here + --> $DIR/query_stability.rs:4:9 + | +LL | #![deny(rustc::potential_query_instability)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: using `iter` can result in unstable query results + --> $DIR/query_stability.rs:16:16 + | +LL | for _ in x.iter() {} + | ^^^^ + | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: using `iter_mut` can result in unstable query results + --> $DIR/query_stability.rs:19:36 + | +LL | for _ in Some(&mut x).unwrap().iter_mut() {} + | ^^^^^^^^ + | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: using `into_iter` can result in unstable query results + --> $DIR/query_stability.rs:22:14 + | +LL | for _ in x {} + | ^ + | + = note: if you believe this case to be fine, allow this lint and add a comment explaining your rationale + +error: aborting due to 4 previous errors + diff --git a/src/test/ui-fulldeps/internal-lints/query_stability_incorrect.rs b/src/test/ui-fulldeps/internal-lints/query_stability_incorrect.rs new file mode 100644 index 00000000000..f478b73329e --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/query_stability_incorrect.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_attrs)] + +#[rustc_lint_query_instability] +//~^ ERROR attribute should be applied to a function +struct Foo; + +impl Foo { + #[rustc_lint_query_instability(a)] + //~^ ERROR malformed `rustc_lint_query_instability` + fn bar() {} +} + +fn main() {} diff --git a/src/test/ui-fulldeps/internal-lints/query_stability_incorrect.stderr b/src/test/ui-fulldeps/internal-lints/query_stability_incorrect.stderr new file mode 100644 index 00000000000..b5156f2ac59 --- /dev/null +++ b/src/test/ui-fulldeps/internal-lints/query_stability_incorrect.stderr @@ -0,0 +1,17 @@ +error: malformed `rustc_lint_query_instability` attribute input + --> $DIR/query_stability_incorrect.rs:10:5 + | +LL | #[rustc_lint_query_instability(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]` + +error: attribute should be applied to a function + --> $DIR/query_stability_incorrect.rs:5:1 + | +LL | #[rustc_lint_query_instability] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct Foo; + | ----------- not a function + +error: aborting due to 2 previous errors + -- cgit 1.4.1-3-g733a5 From 9a3c02473b922e91ad7c37beed8bd48da0ef05db Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 20 Oct 2021 11:58:20 -0400 Subject: Skip documentation for tier 2 targets --- .github/workflows/ci.yml | 2 +- src/ci/github-actions/ci.yml | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d921286ba34..3c3f5e3100d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -287,7 +287,7 @@ jobs: os: ubuntu-latest-xl - name: dist-x86_64-apple env: - SCRIPT: "./x.py dist" + SCRIPT: "./x.py dist --exclude src/doc --exclude extended && ./x.py dist --target=x86_64-apple-darwin src/doc && ./x.py dist extended" RUST_CONFIGURE_ARGS: "--host=x86_64-apple-darwin --target=x86_64-apple-darwin,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false" RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 MACOSX_DEPLOYMENT_TARGET: 10.7 diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index eb16cf3c762..2b37a6fde7e 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -448,9 +448,11 @@ jobs: # macOS Builders # #################### + # Only generate documentation for x86_64-apple-darwin, not other + # tier 2 targets produced by this builder. - name: dist-x86_64-apple env: - SCRIPT: ./x.py dist + SCRIPT: ./x.py dist --exclude src/doc --exclude extended && ./x.py dist --target=x86_64-apple-darwin src/doc && ./x.py dist extended RUST_CONFIGURE_ARGS: --host=x86_64-apple-darwin --target=x86_64-apple-darwin,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 MACOSX_DEPLOYMENT_TARGET: 10.7 -- cgit 1.4.1-3-g733a5 From 5503dd9b0e2bb8518147591c66090729b5bea1bd Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Wed, 20 Oct 2021 12:15:45 -0400 Subject: [do not merge] try build --- .github/workflows/ci.yml | 13 ++++++++++--- src/ci/github-actions/ci.yml | 12 +++++++++++- 2 files changed, 21 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3c3f5e3100d..84842899929 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -528,9 +528,16 @@ jobs: strategy: matrix: include: - - name: dist-x86_64-linux - os: ubuntu-latest-xl - env: {} + - name: dist-x86_64-apple + env: + SCRIPT: "./x.py dist --exclude src/doc --exclude extended && ./x.py dist --target=x86_64-apple-darwin src/doc && ./x.py dist extended" + RUST_CONFIGURE_ARGS: "--host=x86_64-apple-darwin --target=x86_64-apple-darwin,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false" + RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 + MACOSX_DEPLOYMENT_TARGET: 10.7 + NO_LLVM_ASSERTIONS: 1 + NO_DEBUG_ASSERTIONS: 1 + DIST_REQUIRE_ALL_TOOLS: 1 + os: macos-latest timeout-minutes: 600 runs-on: "${{ matrix.os }}" steps: diff --git a/src/ci/github-actions/ci.yml b/src/ci/github-actions/ci.yml index 2b37a6fde7e..9616594b5a3 100644 --- a/src/ci/github-actions/ci.yml +++ b/src/ci/github-actions/ci.yml @@ -668,7 +668,17 @@ jobs: strategy: matrix: include: - - *dist-x86_64-linux + - name: dist-x86_64-apple + env: + SCRIPT: ./x.py dist --exclude src/doc --exclude extended && ./x.py dist --target=x86_64-apple-darwin src/doc && ./x.py dist extended + RUST_CONFIGURE_ARGS: --host=x86_64-apple-darwin --target=x86_64-apple-darwin,aarch64-apple-ios,x86_64-apple-ios,aarch64-apple-ios-sim --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc --set llvm.ninja=false + RUSTC_RETRY_LINKER_ON_SEGFAULT: 1 + MACOSX_DEPLOYMENT_TARGET: 10.7 + NO_LLVM_ASSERTIONS: 1 + NO_DEBUG_ASSERTIONS: 1 + DIST_REQUIRE_ALL_TOOLS: 1 + <<: *job-macos-xl + master: name: master -- cgit 1.4.1-3-g733a5 From 9296efe3ef5544ec0eadb594d1fcbb5d7cc47276 Mon Sep 17 00:00:00 2001 From: Mark Rousskov Date: Thu, 21 Oct 2021 09:16:16 -0400 Subject: Print step timings for try builds --- src/ci/run.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/ci/run.sh b/src/ci/run.sh index b5019d83af4..73175b43470 100755 --- a/src/ci/run.sh +++ b/src/ci/run.sh @@ -43,7 +43,7 @@ else PYTHON="python2" fi -if ! isCI || isCiBranch auto || isCiBranch beta; then +if ! isCI || isCiBranch auto || isCiBranch beta || isCiBranch try; then RUST_CONFIGURE_ARGS="$RUST_CONFIGURE_ARGS --set build.print-step-timings --enable-verbose-tests" fi -- cgit 1.4.1-3-g733a5 From 542ab2daa6eb4b05a01403114783aa323315b416 Mon Sep 17 00:00:00 2001 From: Jacob Hoffman-Andrews Date: Thu, 21 Oct 2021 18:46:47 -0700 Subject: Outdent method headings so they stand out The makes the heading / documentation distinction clearer. --- src/librustdoc/html/static/css/rustdoc.css | 28 ++++++++++------------------ src/test/rustdoc-gui/anchor-navigable.goml | 11 +++++++++++ 2 files changed, 21 insertions(+), 18 deletions(-) create mode 100644 src/test/rustdoc-gui/anchor-navigable.goml (limited to 'src') diff --git a/src/librustdoc/html/static/css/rustdoc.css b/src/librustdoc/html/static/css/rustdoc.css index e41c993a528..8336f4c1859 100644 --- a/src/librustdoc/html/static/css/rustdoc.css +++ b/src/librustdoc/html/static/css/rustdoc.css @@ -152,10 +152,15 @@ h1.fqn > .in-band > a:hover { h2, h3, h4 { border-bottom: 1px solid; } -h3.code-header, h4.code-header { +h3.code-header { + font-size: 1.1em; +} +h4.code-header { font-size: 1em; +} +h3.code-header, h4.code-header { font-weight: 600; - border: none; + border-bottom-style: none; padding: 0; margin: 0; } @@ -174,12 +179,6 @@ h3.code-header, h4.code-header { margin-bottom: 10px; position: relative; } -.impl, .method.trait-impl, -.type.trait-impl, -.associatedconstant.trait-impl, -.associatedtype.trait-impl { - padding-left: 15px; -} div.impl-items > div { padding-left: 0; @@ -669,13 +668,6 @@ nav.sub { left: -19px; } -.content .impl-items .method, .content .impl-items > .type, .impl-items > .associatedconstant, -.impl-items > .associatedtype, .content .impl-items details > summary > .type, -.impl-items details > summary > .associatedconstant, -.impl-items details > summary > .associatedtype { - margin-left: 20px; -} - .content .impl-items .docblock, .content .impl-items .item-info { margin-bottom: .6em; } @@ -746,7 +738,7 @@ a { .anchor { display: none; position: absolute; - left: 0; + left: -0.5em; background: none !important; } .anchor.field { @@ -1579,14 +1571,14 @@ details.rustdoc-toggle > summary.hideme::before { details.rustdoc-toggle > summary:not(.hideme)::before { position: absolute; - left: -23px; + left: -24px; top: 3px; } .impl-items > details.rustdoc-toggle > summary:not(.hideme)::before, .undocumented > details.rustdoc-toggle > summary:not(.hideme)::before { position: absolute; - left: -2px; + left: -24px; } /* When a "hideme" summary is open and the "Expand description" or "Show diff --git a/src/test/rustdoc-gui/anchor-navigable.goml b/src/test/rustdoc-gui/anchor-navigable.goml new file mode 100644 index 00000000000..424c312233b --- /dev/null +++ b/src/test/rustdoc-gui/anchor-navigable.goml @@ -0,0 +1,11 @@ +// The `impl Foo` heading underneath `Implementations` has a ยง +// anchor to its left (used for linking to that heading). The anchor only shows +// up when hovering the `impl Foo`. This test ensures there's no gap between the +// anchor and the `impl Foo`. If there were a gap, this would cause an annoying +// problem: you hover `impl Foo` to see the anchor, then when you move your +// mouse to the left, the anchor disappears before you reach it. +goto: file://|DOC_PATH|/test_docs/struct.Foo.html +// We check that ".item-info" is bigger than its content. +move-cursor-to: ".impl" +assert-property: (".impl > a.anchor", {"offsetWidth": "9"}) +assert-css: (".impl > a.anchor", {"left": "-8px"}) -- cgit 1.4.1-3-g733a5 From 4b970231fd1254580fbddabab74a125404fea0de Mon Sep 17 00:00:00 2001 From: Jakob Degen Date: Sun, 24 Oct 2021 00:33:29 -0400 Subject: Fix ICE when forgetting to `Box` a parameter to a `Self::func` call --- compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs | 2 +- .../issue-90213-expected-boxfuture-self-ice.rs | 13 +++++++++++++ .../issue-90213-expected-boxfuture-self-ice.stderr | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs create mode 100644 src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr (limited to 'src') diff --git a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs index babc06822ac..dcc635a1f00 100644 --- a/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs +++ b/compiler/rustc_typeck/src/check/fn_ctxt/suggestions.rs @@ -420,7 +420,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> { .. }, method, - )) if Some(recv_ty.def_id()) == pin_did && method.ident.name == sym::new => { + )) if recv_ty.opt_def_id() == pin_did && method.ident.name == sym::new => { err.span_suggestion( fn_name.span, "use `Box::pin` to pin and box this expression", diff --git a/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs new file mode 100644 index 00000000000..1e36b2fabf2 --- /dev/null +++ b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.rs @@ -0,0 +1,13 @@ +// Checks that we do not ICE when comparing `Self` to `Pin` +// edition:2021 + +struct S; + +impl S { + fn foo(_: Box>) {} + fn bar() { + Self::foo(None) //~ ERROR mismatched types + } +} + +fn main() {} diff --git a/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr new file mode 100644 index 00000000000..c15b772b79c --- /dev/null +++ b/src/test/ui/suggestions/issue-90213-expected-boxfuture-self-ice.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/issue-90213-expected-boxfuture-self-ice.rs:9:19 + | +LL | Self::foo(None) + | ^^^^ expected struct `Box`, found enum `Option` + | + = note: expected struct `Box>` + found enum `Option<_>` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Self::foo(Box::new(None)) + | +++++++++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. -- cgit 1.4.1-3-g733a5