Skip to content

Rollup of 12 pull requests #144440

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

Merged
merged 29 commits into from
Jul 25, 2025
Merged

Rollup of 12 pull requests #144440

merged 29 commits into from
Jul 25, 2025

Conversation

matthiaskrgr
Copy link
Member

@matthiaskrgr matthiaskrgr commented Jul 25, 2025

Successful merges:

r? @ghost
@rustbot modify labels: rollup

Create a similar rollup

xizheyin and others added 29 commits June 17, 2025 23:42
The `Display` implementation for `Backtrace` used to print

    stack backtrace:

but that print was later removed. To make the existing test pass, the
print was added to the existing test. But it doesn't make sense to check
for something that the test itself does since that will not detect any
regressions in the implementation of `Backtrace`. Fully remove the
checks.
When encountering a non-`Copy` value that is moved into a closure which is coming directly from a fn parameter, point at the parameter's type when mentioning it is not `Copy`.

Before:

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             --- captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            ---
   |            |
   |            variable moved due to use in coroutine
   |            move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
```

After:

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             ---  ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
   |             |
   |             captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- variable moved due to use in coroutine
```
Account not only for `fn` parameters when moving non-`Copy` values into closure, but also for let bindings.

```
error[E0507]: cannot move out of `bar`, a captured variable in an `FnMut` closure
  --> $DIR/borrowck-move-by-capture.rs:9:29
   |
LL |     let bar: Box<_> = Box::new(3);
   |         ---  ------ move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait
   |         |
   |         captured outer variable
LL |     let _g = to_fn_mut(|| {
   |                        -- captured by this `FnMut` closure
LL |         let _h = to_fn_once(move || -> isize { *bar });
   |                             ^^^^^^^^^^^^^^^^   ---- variable moved due to use in closure
   |                             |
   |                             `bar` is moved here
   |
help: consider cloning the value before moving it into the closure
   |
LL ~         let value = bar.clone();
LL ~         let _h = to_fn_once(move || -> isize { value });
   |
```

```
error[E0507]: cannot move out of `y`, a captured variable in an `Fn` closure
  --> $DIR/unboxed-closures-move-upvar-from-non-once-ref-closure.rs:12:9
   |
LL |     let y = vec![format!("World")];
   |         -   ---------------------- move occurs because `y` has type `Vec<String>`, which does not implement the `Copy` trait
   |         |
   |         captured outer variable
LL |     call(|| {
   |          -- captured by this `Fn` closure
LL |         y.into_iter();
   |         ^ ----------- `y` moved due to this method call
   |         |
   |         `y` is moved here
   |
note: `into_iter` takes ownership of the receiver `self`, which moves `y`
  --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL
help: you can `clone` the value and consume it, but this might not be your desired behavior
   |
LL |         <Vec<String> as Clone>::clone(&y).into_iter();
   |         +++++++++++++++++++++++++++++++ +
help: consider cloning the value if the performance cost is acceptable
   |
LL |         y.clone().into_iter();
   |          ++++++++
```
```
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
  --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
   |
LL |     let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
   |         ----- captured outer variable
...
LL |     f(Box::new(|a| {
   |                --- captured by this `FnMut` closure
LL |
LL |         foo(f);
   |             ^ move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait
```

instead of

```
error[E0507]: cannot move out of `f`, a captured variable in an `FnMut` closure
  --> $DIR/borrowck-call-is-borrow-issue-12224.rs:57:13
   |
LL |       let mut f = move |g: Box<dyn FnMut(isize)>, b: isize| {
   |  _________-----___-
   | |         |
   | |         captured outer variable
LL | |         let _ = s.len();
LL | |     };
   | |_____- move occurs because `f` has type `{closure@$DIR/borrowck-call-is-borrow-issue-12224.rs:52:17: 52:58}`, which does not implement the `Copy` trait
LL |       f(Box::new(|a| {
   |                  --- captured by this `FnMut` closure
LL |
LL |           foo(f);
   |               ^ `f` is moved here
```
For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.

Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
We lost the following comment during refactorings:

The current code for niche-filling relies on variant indices instead of actual discriminants, so enums with explicit discriminants (RFC 2363) would misbehave.
Use `Scope::Module` with the crate root module inside instead, which should be identical.
Suggest clone in user-write-code instead of inside macro

Fixes rust-lang#139253

Inspired by rust-lang#142543

r? ````@fmease````
…n-display, r=davidtwco

tests: Don't check for self-printed output in std-backtrace.rs test

The `Display` implementation for `Backtrace` used to print

    stack backtrace:

but that print was since removed. See rust-lang/backtrace-rs#286 and rust-lang#69042. To make the existing test pass, the print was added to the test instead. But it doesn't make sense to check for something that the test itself does since that will not detect any regressions in the implementation of `Backtrace`.

What the test _should_ check is that "stack backtrace:" is _not_ printed in `Display` of `Backtrace`. So do that instead.

This is one small steps towards resolving rust-lang#71706. The next steps after this step involves extending and hardening that test further.
clippy fix: rely on autoderef

Changes instances of `&**self` to `self`.
… r=scottmcm

Update core::mem::copy documentation

Update the documentation of `core::mem::copy` to include a `const` on the definition of the function.
…nkov

Test fixes for Arm64EC Windows

* `tests/ui/cfg/conditional-compile-arch.rs` needs an Arm64EC case.
* `tests/ui/runtime/backtrace-debuginfo.rs` should skip Arm64EC as it suffers from the same truncated backtraces as Arm64 Windows.
* `tests/ui/linkage-attr/incompatible-flavor.rs` is a general issue: it assumes that the Rust compiler is always built with the x86 target enabled in the backend, but I only enabled AArch64 when building locally to speed up the LLVM compilation.
…lcnr

Tweak output for non-`Clone` values moved into closures

When we encounter a non-`Clone` value being moved into a closure, try to find the corresponding type of the binding being moved, if it is a `let`-binding or a function parameter. If any of those cases, we point at them with the note explaining that the type is not `Copy`, instead of giving that label to the place where it is captured. When it is a `let`-binding with no explicit type, we point at the initializer (if it fits in a single line).

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             ---  ----------- move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
   |             |
   |             captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            --- variable moved due to use in coroutine
```

instead of

```
error[E0507]: cannot move out of `foo`, a captured variable in an `Fn` closure
  --> f111.rs:14:25
   |
13 | fn do_stuff(foo: Option<Foo>) {
   |             --- captured outer variable
14 |     require_fn_trait(|| async {
   |                      -- ^^^^^ `foo` is moved here
   |                      |
   |                      captured by this `Fn` closure
15 |         if foo.map_or(false, |f| f.foo()) {
   |            ---
   |            |
   |            variable moved due to use in coroutine
   |            move occurs because `foo` has type `Option<Foo>`, which does not implement the `Copy` trait
```
Don't emit two `assume`s in transmutes when one is a subset of the other

For example, transmuting between `bool` and `Ordering` doesn't need two `assume`s because one range is a superset of the other.

Multiple are still used for things like `char` <-> `NonZero<u32>`, which overlap but where neither fully contains the other.
Hint that choose_pivot returns index in bounds

Instead of using `unsafe` in multiple places, one `hint::assert_unchecked` allows use of safe code instead.

Part of #rust-lang#144326
…eyouxu

UI test suite clarity changes: Rename `tests/ui/SUMMARY.md` and update rustc dev guide on `error-pattern`

To match convention, rename `tests/ui/SUMMARY.md` to `tests/ui/README.md`.

Also, remove misleading lines in the rustc development guide about `error-pattern` being "not recommended", when it really is just a last resort which *should* be used in the niche situations where it is useful.

r? ````@jieyouxu````
resolve: Remove `Scope::CrateRoot`

Use `Scope::Module` with the crate root module inside instead, which should be identical.
This is a simplification by itself, but it will be even larger simplification if something like rust-lang#144131 is implemented, because `Scope::CrateRoot` is also a module with two actual scopes in it (for globs and non-globs).

I also did some renamings for consistency:
- `ScopeSet::AbsolutePath` -> `ScopeSet::ModuleAndExternPrelude`
- `ModuleOrUniformRoot::CrateRootAndExternPrelude` -> `ModuleOrUniformRoot::ModuleAndExternPrelude`
- `is_absolute_path` -> `module_and_extern_prelude`
…parrowLii

Remove dead code and extend test coverage and diagnostics around it

I was staring a bit at the `dont_niche_optimize_enum` variable and figured out that part of it is dead code (at least today it is). I changed the diagnostic and test around the code that makes that part dead code, so everything that makes removing that code sound is visible in this PR
rustc_public: Remove movability from `RigidTy/AggregateKind::Coroutine`

Part of rust-lang#119174 .
I think we should be good now to sync this change in rustc_public.
@rustbot rustbot added the A-rustc-dev-guide Area: rustc-dev-guide label Jul 25, 2025
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. 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. rollup A PR which is a rollup labels Jul 25, 2025
@matthiaskrgr
Copy link
Member Author

@bors r+ rollup=never p=5

@bors
Copy link
Collaborator

bors commented Jul 25, 2025

📌 Commit 1caf701 has been approved by matthiaskrgr

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 Jul 25, 2025
@bors
Copy link
Collaborator

bors commented Jul 25, 2025

⌛ Testing commit 1caf701 with merge a955f1c...

@bors
Copy link
Collaborator

bors commented Jul 25, 2025

☀️ Test successful - checks-actions
Approved by: matthiaskrgr
Pushing a955f1c to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 25, 2025
@bors bors merged commit a955f1c into rust-lang:master Jul 25, 2025
11 checks passed
@rustbot rustbot added this to the 1.90.0 milestone Jul 25, 2025
@rust-timer
Copy link
Collaborator

📌 Perf builds for each rolled up PR:

PR# Message Perf Build Sha
#142569 Suggest clone in user-write-code instead of inside macro bb0dab1076ef027d6578af5bca0d5d6c2e25c05f (link)
#143401 tests: Don't check for self-printed output in std-backtrace… 522f13ee8ec2fc7e31e6049f86ea56a4d979d1fc (link)
#143424 clippy fix: rely on autoderef e37d1105e70afd7128a023e231de5ee949ab8823 (link)
#143970 Update core::mem::copy documentation 8091a56c94a22a44193b262ed7533ca0bc06d64c (link)
#143979 Test fixes for Arm64EC Windows 3653f9c9fb1746bf577284d84549cadb5cfc2507 (link)
#144200 Tweak output for non-Clone values moved into closures 7ae145500b639c4ddbdb65e177ba92df098638e8 (link)
#144209 Don't emit two assumes in transmutes when one is a subset… b40ba4a93bf7cf433968304e2d9bd8bab56d37cf (link)
#144314 Hint that choose_pivot returns index in bounds 978fc5852253e7174c171efbbfa5a7176c8e0497 (link)
#144340 UI test suite clarity changes: Rename tests/ui/SUMMARY.md 7666f5756e0ca069827c33ea9d47e7e5604f1c75 (link)
#144368 resolve: Remove Scope::CrateRoot 1a65d896a3ef5f0be510cb3db33b5ad3e30c7cc9 (link)
#144390 Remove dead code and extend test coverage and diagnostics a… 5ac25969d155cfb06945365eb35a8f37ac825dcf (link)
#144392 rustc_public: Remove movability from `RigidTy/AggregateKind… fb41a7e9473038662d89f6b5d61e37098e4b3938 (link)

previous master: b56aaec52b

In the case of a perf regression, run the following command for each PR you suspect might be the cause: @rust-timer build $SHA

Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing b56aaec (parent) -> a955f1c (this PR)

Test differences

Show 33 test diffs

Stage 1

  • tests::wrapping_range_contains_range: [missing] -> pass (J0)
  • [ui] tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs: [missing] -> pass (J1)

Stage 2

  • [ui] tests/ui/typeck/suggestions/suggest-clone-in-macro-issue-139253.rs: [missing] -> pass (J2)

Additionally, 30 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard a955f1cd09a027363729ceed919952d09f76f28e --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-apple-various: 8014.6s -> 5975.7s (-25.4%)
  2. dist-aarch64-apple: 5362.0s -> 6580.8s (22.7%)
  3. x86_64-apple-2: 4202.7s -> 4792.2s (14.0%)
  4. tidy: 112.1s -> 99.0s (-11.7%)
  5. dist-x86_64-apple: 9420.4s -> 10390.2s (10.3%)
  6. aarch64-apple: 4665.0s -> 5119.9s (9.8%)
  7. dist-arm-linux-gnueabi: 4704.4s -> 5141.0s (9.3%)
  8. x86_64-gnu-llvm-19: 2630.8s -> 2397.7s (-8.9%)
  9. dist-aarch64-msvc: 5607.2s -> 6065.1s (8.2%)
  10. aarch64-msvc-1: 7225.3s -> 6642.1s (-8.1%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (a955f1c): comparison URL.

Overall result: ❌✅ regressions and improvements - no action needed

@rustbot label: -perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.3% [0.3%, 0.3%] 2
Improvements ✅
(primary)
-0.2% [-0.2%, -0.2%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -0.2% [-0.2%, -0.2%] 1

Max RSS (memory usage)

Results (primary -2.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-2.8% [-3.7%, -2.1%] 3
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.8% [-3.7%, -2.1%] 3

Cycles

Results (secondary -2.7%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-2.7% [-2.7%, -2.7%] 1
All ❌✅ (primary) - - 0

Binary size

Results (primary 0.0%, secondary 0.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
0.2% [0.0%, 0.5%] 5
Regressions ❌
(secondary)
0.5% [0.5%, 0.5%] 1
Improvements ✅
(primary)
-0.1% [-0.1%, -0.0%] 10
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 2
All ❌✅ (primary) 0.0% [-0.1%, 0.5%] 15

Bootstrap: 469.891s -> 467.355s (-0.54%)
Artifact size: 374.63 MiB -> 374.67 MiB (0.01%)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustc-dev-guide Area: rustc-dev-guide merged-by-bors This PR was explicitly merged by bors. rollup A PR which is a rollup S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.