Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 12 pull requests #120209

Closed
wants to merge 25 commits into from
Closed

Conversation

TaKO8Ki
Copy link
Member

@TaKO8Ki TaKO8Ki commented Jan 21, 2024

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

The-Ludwig and others added 25 commits December 7, 2023 17:50
By "actual" we refer to the uplifting logic where we may not compile the requested stage;
instead, we uplift it from the previous stages. Which can lead to bootstrap failures in
specific situations where we request stage X from other steps. However we may end up
uplifting it from stage Y, causing the other stage to fail when attempting to link with
stage X which was never actually built.

Signed-off-by: onur-ozkan <[email protected]>
This shortens the `#[must_use]` diagnostics displayed, in light of the [review comment](https://github.com/rust-lang/rust/pull/62431/files#r300819839) on when this was originally added.
Removing opener 0.5.2, and updating cargo_metadata 0.15.4 -> cargo_metadata 0.18.0

Reverting rustfmt change

Reverting rustfmt patch

Reverting dependency change for clippy
This increases the maximum supported file size (previously limited to 4GB)
and avoids potential issues with u32 to u64 conversions, which are no longer
needed.

Signed-off-by: onur-ozkan <[email protected]>
…tc-crates, r=WaffleLapkin

Undeprecate lint `unstable_features` and make use of it in the compiler

See also rust-lang#117937.

r? compiler
…_field, r=Nilstrieb

 Explanation that fields are being used when deriving `(Partial)Ord` on enums

When deriving `std::cmp::Ord` or `std::cmp::PartialOrd` on enums, their fields are compared if the variants are equal.
This means that the last assertion in the following snipped panics.
```rust
use std::cmp::{PartialEq, Eq, PartialOrd, Ord};

#[derive(PartialEq, Eq, PartialOrd, Ord)]
enum Sizes {
    Small(usize),
    Big(usize),
}

fn main() {
    let a = Sizes::Big(3);
    let b = Sizes::Big(5);
    let c = Sizes::Small(10);
    assert!( c < a);
    assert_eq!(a, c);
}
```

This is more often expected behavior than not, and can be easily circumvented, as discussed in [this thread](https://users.rust-lang.org/t/how-to-sort-enum-variants/52291/4).
But it is addressed nowhere in the documentation, yet.
So I stumbled across this, as I personally did not expect fields being used in `PartialOrd`.
I added the explanation to the documentation.
…n,Nilstrieb

Fix deallocation with wrong allocator in (A)Rc::from_box_in

Deallocate the `Box` with the original allocator (via `&A`), not `Global`.

Fixes rust-lang#119749

<details> <summary>Example code with error and Miri output</summary>

(Note that this UB is not observable on stable, because the only usable allocator on stable is `Global` anyway.)

Code ([playground link](https://play.rust-lang.org/?version=nightly&mode=debug&edition=2021&gist=96193c2c6a1912d7f669fbbe39174b09)):

```rs
#![feature(allocator_api)]
use std::alloc::System;

// uncomment one of these
use std::rc::Rc;
//use std::sync::Arc as Rc;

fn main() {
    let x: Box<[u32], System> = Box::new_in([1,2,3], System);
    let _: Rc<[u32], System> = Rc::from(x);
}
```

Miri output:

```rs
error: Undefined Behavior: deallocating alloc904, which is C heap memory, using Rust heap deallocation operation
   --> /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:117:14
    |
117 |     unsafe { __rust_dealloc(ptr, layout.size(), layout.align()) }
    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ deallocating alloc904, which is C heap memory, using Rust heap deallocation operation
    |
    = help: this indicates a bug in the program: it performed an invalid operation, and caused Undefined Behavior
    = help: see https://doc.rust-lang.org/nightly/reference/behavior-considered-undefined.html for further information
    = note: BACKTRACE:
    = note: inside `std::alloc::dealloc` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:117:14: 117:64
    = note: inside `<std::alloc::Global as std::alloc::Allocator>::deallocate` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/alloc.rs:254:22: 254:51
    = note: inside `<std::boxed::Box<std::mem::ManuallyDrop<[u32]>> as std::ops::Drop>::drop` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/boxed.rs:1244:17: 1244:66
    = note: inside `std::ptr::drop_in_place::<std::boxed::Box<std::mem::ManuallyDrop<[u32]>>> - shim(Some(std::boxed::Box<std::mem::ManuallyDrop<[u32]>>))` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ptr/mod.rs:507:1: 507:56
    = note: inside `std::mem::drop::<std::boxed::Box<std::mem::ManuallyDrop<[u32]>>>` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/mem/mod.rs:992:24: 992:25
    = note: inside `std::rc::Rc::<[u32], std::alloc::System>::from_box_in` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/rc.rs:1928:13: 1928:22
    = note: inside `<std::rc::Rc<[u32], std::alloc::System> as std::convert::From<std::boxed::Box<[u32], std::alloc::System>>>::from` at /playground/.rustup/toolchains/nightly-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/alloc/src/rc.rs:2504:9: 2504:27
note: inside `main`
   --> src/main.rs:10:32
    |
10  |     let _: Rc<[u32], System> = Rc::from(x);
    |                                ^^^^^^^^^^^

note: some details are omitted, run with `MIRIFLAGS=-Zmiri-backtrace=full` for a verbose backtrace

error: aborting due to 1 previous error
```

</details>
…fn_fix, r=TaKO8Ki

Make `unsafe_op_in_unsafe_fn` migrated in edition 2024

fixes rust-lang#119823
…rk-Simulacrum

remote-test: use u64 to represent file size

Currently, triggering a transfer of data exceeding the size of 4294967295 bytes results in a panic on the `remote-test-server` as `io::copy(&mut file, dst) failed with Connection reset by peer (os error 104)`. This issue happens because the size is transmitted as u32 to `remote-test-server`.

First commit increases the supported file size. But I am not sure about its necessity — can we realistically encounter file sizes exceeding 4GB in builds, perhaps through some complicated configurations?

~The second commit adds a sanity check to avoid encountering the error `io::copy(&mut file, dst) failed with Connection reset by peer (os error 104)` on the `remote-test-server` side.~
…rk-Simulacrum

bootstrap: improvements for compiler builds

Reverted rust-lang#108288 and applied a proper fix with the following commit.

r? `@Mark-Simulacrum`
…lnay

Manually implement derived `NonZero` traits.

Step 3 as mentioned in rust-lang#100428 (review).

Manually implement the traits that would cause “borrow of layout constrained field with interior mutability” errors when switching to `NonZero<T>`.

r? `@dtolnay`
…trieb

Remove duplicate dependencies for rustc

Removed several duplicates for rustc: rust-lang#75704

Several duplicates still exist, but an external library would have to be updated first.

These are the duplicate dependencies still outstanding:
```
annotate-snippets v0.9.1
annotate-snippets v0.10.1

bitflags v1.3.2
bitflags v2.4.1

cargo_metadata v0.15.4
cargo_metadata v0.18.0

darling v0.14.4
darling v0.20.3

darling_core v0.14.4
darling_core v0.20.3

darling_macro v0.14.4
darling_macro v0.20.3

regex-automata v0.1.10
regex-automata v0.2.0
regex-automata v0.4.3

regex-syntax v0.6.29
regex-syntax v0.7.2
regex-syntax v0.8.2

self_cell v0.10.3
self_cell v1.0.2

syn v1.0.109
syn v2.0.32

toml v0.5.11
toml v0.7.5
```

It should not be hard to consolidate these remaining duplicate dependencies, but it will take time as it would be pull requests for external crates.

r? `@jyn514`
coverage: Don't instrument `#[automatically_derived]` functions

This PR makes the coverage instrumentor detect and skip functions that have [`#[automatically_derived]`](https://doc.rust-lang.org/reference/attributes/derive.html#the-automatically_derived-attribute) on their enclosing impl block.

Most notably, this means that methods generated by built-in derives (e.g. `Clone`, `Debug`, `PartialEq`) are now ignored by coverage instrumentation, and won't appear as executed or not-executed in coverage reports.

This is a noticeable change in user-visible behaviour, but overall I think it's a net improvement. For example, we've had a few user requests for this sort of change (e.g. rust-lang#105055, rust-lang#84605 (comment)), and I believe it's the behaviour that most users will expect/prefer by default.

It's possible to imagine situations where users would want to instrument these derived implementations, but I think it's OK to treat that as an opportunity to consider adding more fine-grained option flags to control the details of coverage instrumentation, while leaving this new behaviour as the default.

(Also note that while `-Cinstrument-coverage` is a stable feature, the exact details of coverage instrumentation are allowed to change. So we *can* make this change; the main question is whether we *should*.)

Fixes rust-lang#105055.
…-option-must-use, r=Nilstrieb

Shorten `#[must_use]` Diagnostic Message for `Option::is_none`

This shortens the `#[must_use]` diagnostics displayed, in light of the [review comment](https://github.com/rust-lang/rust/pull/62431/files#r300819839) on when this was originally added.
…link, r=dtolnay

Correct the anchor of an URL in an error message

Following error message from rustc points to a URL, but its anchor does not exist.
The destination seems to be https://doc.rust-lang.org/cargo/reference/build-scripts.html#rustc-link-lib.
This PR makes that correction.

      = note: use the `cargo:rustc-link-lib` directive to specify the native libraries to link with Cargo (see https://doc.rust-lang.org/cargo/reference/build-scripts.html#cargorustc-link-libkindname)
…ler-errors

Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests

This allows the rust-installer tests to pass on NixOS

This change has [already been made](rust-lang@302ad21) for the actual installer, it appears that the tests were just forgotten.
@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 21, 2024
@rustbot rustbot added the rollup A PR which is a rollup label Jan 21, 2024
@TaKO8Ki
Copy link
Member Author

TaKO8Ki commented Jan 21, 2024

@bors r+ rollup=never p=12

@bors
Copy link
Contributor

bors commented Jan 21, 2024

📌 Commit 1024093 has been approved by TaKO8Ki

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 21, 2024
@bors
Copy link
Contributor

bors commented Jan 21, 2024

⌛ Testing commit 1024093 with merge 8ace346...

bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 21, 2024
Rollup of 12 pull requests

Successful merges:

 - rust-lang#118639 (Undeprecate lint `unstable_features` and make use of it in the compiler)
 - rust-lang#118714 ( Explanation that fields are being used when deriving `(Partial)Ord` on enums)
 - rust-lang#119801 (Fix deallocation with wrong allocator in (A)Rc::from_box_in)
 - rust-lang#119948 (Make `unsafe_op_in_unsafe_fn` migrated in edition 2024)
 - rust-lang#119999 (remote-test: use u64 to represent file size)
 - rust-lang#120058 (bootstrap: improvements for compiler builds)
 - rust-lang#120160 (Manually implement derived `NonZero` traits.)
 - rust-lang#120177 (Remove duplicate dependencies for rustc)
 - rust-lang#120185 (coverage: Don't instrument `#[automatically_derived]` functions)
 - rust-lang#120194 (Shorten `#[must_use]` Diagnostic Message for `Option::is_none`)
 - rust-lang#120200 (Correct the anchor of an URL in an error message)
 - rust-lang#120203 (Replace `#!/bin/bash` with `#!/usr/bin/env bash` in rust-installer tests)

r? `@ghost`
`@rustbot` modify labels: rollup
@rust-log-analyzer
Copy link
Collaborator

The job aarch64-gnu failed! Check out the build log: (web) (plain)

Click to see the possible cause of the failure (guessed by this bot)

---- [coverage-run] tests/coverage-run-rustdoc/doctest.rs stdout ----
diff of coverage:

34    LL|       |//!
35    LL|       |//! doctest returning a result:
36    LL|      1|//! ```
-    LL|      2|//! #[derive(Debug, PartialEq)]
-                        ^1
+    LL|      1|//! #[derive(Debug, PartialEq)]
39    LL|      1|//! struct SomeError {
40    LL|      1|//!     msg: String,
41    LL|      1|//! }

63    LL|      1|//!     println!("called some_func()");
64    LL|      1|//! }
65    LL|       |//!
-    LL|      0|//! #[derive(Debug)]
Build completed unsuccessfully in 0:25:51
+    LL|       |//! #[derive(Debug)]
67    LL|       |//! struct SomeError;
68    LL|       |//!
69    LL|       |//! extern crate doctest_crate;

The actual coverage differed from the expected coverage.
The actual coverage differed from the expected coverage.
Actual coverage saved to /checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/doctest.coverage
error: 1 errors occurred comparing coverage output.
status: exit status: 0
status: exit status: 0
command: "/checkout/obj/build/aarch64-unknown-linux-gnu/llvm/build/bin/llvm-cov" "show" "--format=text" "--show-line-counts-or-regions" "--Xdemangler" "/checkout/obj/build/aarch64-unknown-linux-gnu/stage0-tools-bin/rust-demangler" "--instr-profile" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/default.profdata" "--object" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/a" "--object" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/doc_bins/_checkout_tests_coverage_run_rustdoc_doctest_rs_18_0/rust_out" "--object" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/doc_bins/_checkout_tests_coverage_run_rustdoc_doctest_rs_24_0/rust_out" "--object" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/doc_bins/_checkout_tests_coverage_run_rustdoc_doctest_rs_46_0/rust_out" "--object" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/doc_bins/_checkout_tests_coverage_run_rustdoc_doctest_rs_70_0/rust_out" "--object" "/checkout/obj/build/aarch64-unknown-linux-gnu/test/coverage-run-rustdoc/doctest.coverage-run/doc_bins/_checkout_tests_coverage_run_rustdoc_doctest_rs_7_0/rust_out"
/checkout/tests/coverage-run-rustdoc/auxiliary/doctest_crate.rs:
/checkout/tests/coverage-run-rustdoc/auxiliary/doctest_crate.rs:
    1|       |/// A function run only from within doctests
    2|      3|pub fn fn_run_in_doctests(conditional: usize) {
    3|      3|    match conditional {
    4|      1|        1 => assert_eq!(1, 1), // this is run,
    5|      1|        2 => assert_eq!(1, 1), // this,
    6|      1|        3 => assert_eq!(1, 1), // and this too
    7|      0|        _ => assert_eq!(1, 2), // however this is not
    9|      3|}

/checkout/tests/coverage-run-rustdoc/doctest.rs:
/checkout/tests/coverage-run-rustdoc/doctest.rs:
    1|       |// aux-build:doctest_crate.rs
    2|       |
    3|       |//! This test ensures that code from doctests is properly re-mapped.
    4|       |//! See <https://github.com/rust-lang/rust/issues/79417> for more info.
    5|       |//!
    6|       |//! Just some random code:
    7|      1|//! ```
    8|      1|//! if true {
    9|       |//!     // this is executed!
   10|      1|//!     assert_eq!(1, 1);
   11|       |//! } else {
   12|       |//!     // this is not!
   13|      0|//!     assert_eq!(1, 2);
   14|       |//! }
   15|      1|//! ```
   16|       |//!
   17|       |//! doctest testing external code:
   18|       |//! ```
   19|      1|//! extern crate doctest_crate;
   20|      1|//! doctest_crate::fn_run_in_doctests(1);
   21|      1|//! ```
   22|       |//!
   23|       |//! doctest returning a result:
   24|      1|//! ```
   25|      1|//! #[derive(Debug, PartialEq)]
   26|      1|//! struct SomeError {
   27|      1|//!     msg: String,
   28|      1|//! }
   29|      1|//! let mut res = Err(SomeError { msg: String::from("a message") });
   30|      1|//! if res.is_ok() {
   31|      0|//!     res?;
   32|       |//! } else {
   33|      1|//!     if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() {
   34|      1|//!         println!("{:?}", res);
   35|      1|//!     }
                   ^0
   36|      1|//!     if *res.as_ref().unwrap_err() == *res.as_ref().unwrap_err() {
   37|      1|//!         res = Ok(1);
   38|      1|//!     }
                   ^0
   39|      1|//!     res = Ok(0);
   40|       |//! }
   41|       |//! // need to be explicit because rustdoc cant infer the return type
   42|      1|//! Ok::<(), SomeError>(())
   43|      1|//! ```
   44|       |//!
   45|       |//! doctest with custom main:
   46|       |//! ```
   47|      1|//! fn some_func() {
   48|      1|//!     println!("called some_func()");
   49|      1|//! }
   50|       |//!
   51|       |//! #[derive(Debug)]
   52|       |//! struct SomeError;
   53|       |//!
   54|       |//! extern crate doctest_crate;
   55|       |//!
   56|      1|//! fn doctest_main() -> Result<(), SomeError> {
   57|      1|//!     some_func();
   58|      1|//!     doctest_crate::fn_run_in_doctests(2);
   59|      1|//!     Ok(())
   60|      1|//! }
   61|       |//!
   62|       |//! // this `main` is not shown as covered, as it clashes with all the other
   63|       |//! // `main` functions that were automatically generated for doctests
   64|       |//! fn main() -> Result<(), SomeError> {
   65|       |//!     doctest_main()
   66|       |//! }
   67|       |//! ```
   68|       |
   69|       |/// doctest attached to fn testing external code:
   70|       |/// ```
   71|      1|/// extern crate doctest_crate;
   72|      1|/// doctest_crate::fn_run_in_doctests(3);
   73|      1|/// ```
   74|       |///
   75|      1|fn main() {
   77|      1|        assert_eq!(1, 1);
   78|       |    } else {
   79|      0|        assert_eq!(1, 2);
   80|       |    }
   80|       |    }
   81|      1|}
   82|       |
   83|       |// FIXME(Swatinem): Fix known issue that coverage code region columns need to be offset by the
   84|       |// doc comment line prefix (`///` or `//!`) and any additional indent (before or after the doc
   85|       |// comment characters). This test produces `llvm-cov show` results demonstrating the problem.
   86|       |//
   87|       |// One of the above tests now includes: `derive(Debug, PartialEq)`, producing an `llvm-cov show`
   88|       |// result with a distinct count for `Debug`, denoted by `^1`, but the caret points to the wrong
   89|       |// column. Similarly, the `if` blocks without `else` blocks show `^0`, which should point at, or
   90|       |// one character past, the `if` block's closing brace. In both cases, these are most likely off
   91|       |// by the number of characters stripped from the beginning of each doc comment line: indent
   92|       |// whitespace, if any, doc comment prefix (`//!` in this case) and (I assume) one space character
   93|       |// (?). Note, when viewing `llvm-cov show` results in `--color` mode, the column offset errors are
   94|       |// more pronounced, and show up in more places, with background color used to show some distinct
   95|       |// code regions with different coverage counts.
   96|       |//
   97|       |// NOTE: Since the doc comment line prefix may vary, one possible solution is to replace each
   98|       |// character stripped from the beginning of doc comment lines with a space. This will give coverage
   99|       |// results the correct column offsets, and I think it should compile correctly, but I don't know
  100|       |// what affect it might have on diagnostic messages from the compiler, and whether anyone would care
  101|       |// if the indentation changed. I don't know if there is a more viable solution.
stderr: none



@bors
Copy link
Contributor

bors commented Jan 21, 2024

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Jan 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc rollup A PR which is a rollup S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.