Skip to content

Introduce -Z pack-coroutine-layout flag - #159795

Open
dingxiangfei2009 wants to merge 1 commit into
rust-lang:mainfrom
dingxiangfei2009:coro-layout-flag
Open

Introduce -Z pack-coroutine-layout flag#159795
dingxiangfei2009 wants to merge 1 commit into
rust-lang:mainfrom
dingxiangfei2009:coro-layout-flag

Conversation

@dingxiangfei2009

@dingxiangfei2009 dingxiangfei2009 commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This is still mostly cosmetic, but more stuff is coming over from #135527.

Only the tip of the branch matters, the other commit will be shipped from another PR. It will go away after a rebase, hopefully.

r? @cjgillot

@rustbot

rustbot commented Jul 23, 2026

Copy link
Copy Markdown
Collaborator

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

These commits modify the Cargo.lock file. Unintentional changes to Cargo.lock can be introduced when switching branches and rebasing PRs.

If this was unintentional then you should revert the changes before this PR is merged.
Otherwise, you can ignore this comment.

@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. labels Jul 23, 2026
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot

Copy link
Copy Markdown
Contributor

The second commit is not what I'd describe as cosmetic. It contains quite a lot of behaviour changes that should stay in the main PR.

@rust-bors

This comment has been minimized.

@rustbot

rustbot commented Sep 8, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@dingxiangfei2009

Copy link
Copy Markdown
Contributor Author

Sorry for the late reply.

I wasn't completely splitting this commit in a proper way. This time it should stay very cosmetic.

@dingxiangfei2009 dingxiangfei2009 changed the title Introduce -Z coroutine-layout flag Introduce -Z pack-coroutine-layout flag Sep 8, 2026
We will now give users two options, to go with the traditional coroutine
layout as of Dec 2025 or the new proposed compact layout.

The compact layout will be documented in the RelocateUpvar MIR pass
later.

Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>

Signed-off-by: Xiangfei Ding <dingxiangfei2009@protonmail.ch>
@rust-log-analyzer

Copy link
Copy Markdown
Collaborator

The job test-x86_64-gnu-miri failed! Check out the build log: (web) (plain enhanced) (plain)

Click to see the possible cause of the failure (guessed by this bot)
tests/pass/shims/x86/rounding-error.rs ... ok
tests/pass/shims/x86/intrinsics-x86-gfni.rs ... ok

FAILED TEST: tests/pass/async-drop.rs (revision `stack`)
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-6X2FAG" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/pass" "tests/pass/async-drop.rs" "-Zmiri-strict-provenance" "--edition" "2021" "--cfg=stack" "-Cextra-filename=stack"

error: test got exit status: 1, but expected 0
 = note: compilation failed, but was expected to succeed

error: no output was expected
Execute `./miri test --bless` to update `tests/pass/async-drop.stack.stderr` to the actual output
+++ <stderr output>
error: Undefined Behavior: constructing invalid value of type {async fn body of std::future::async_drop_in_place<{async fn body of std::future::async_drop_in_place<Int>()}>()}: at .<coroutine-state(0)>.<captured-var(0)>, encountered uninitialized memory, but expected a reference
##[error]  --> /checkout/library/core/src/future/async_drop.rs:55:70
   |
LL |   pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: &mut T) {
   |  ______________________________________________________________________^
...  |
LL | | }
   | |_^ Undefined Behavior occurred here
   |
   = 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: stack backtrace:
           0: std::future::async_drop_in_place::<{async fn body of std::future::async_drop_in_place<Int>()}> - shim(Some({async fn body of std::future::async_drop_in_place<Int>()}))
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           1: std::future::async_drop_in_place::<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>::{closure#0} - shim({async fn body of std::future::async_drop_in_place<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>()})
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           2: test_async_drop::<Int>::{closure#0}
               at tests/pass/async-drop.rs:24:1: 24:2
           3: main::{closure#0}
               at tests/pass/async-drop.rs:43:33: 43:38
---
error: no output was emitted
Execute `./miri test --bless` to remove `tests/pass/async-drop.stack.stdout`

full stderr:
error: Undefined Behavior: constructing invalid value of type {async fn body of std::future::async_drop_in_place<{async fn body of std::future::async_drop_in_place<Int>()}>()}: at .<coroutine-state(0)>.<captured-var(0)>, encountered uninitialized memory, but expected a reference
##[error]  --> /checkout/library/core/src/future/async_drop.rs:55:70
   |
LL |   pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: &mut T) {
   |  ______________________________________________________________________^
...  |
LL | | }
   | |_^ Undefined Behavior occurred here
   |
   = 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: stack backtrace:
           0: std::future::async_drop_in_place::<{async fn body of std::future::async_drop_in_place<Int>()}> - shim(Some({async fn body of std::future::async_drop_in_place<Int>()}))
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           1: std::future::async_drop_in_place::<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>::{closure#0} - shim({async fn body of std::future::async_drop_in_place<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>()})
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           2: test_async_drop::<Int>::{closure#0}
               at tests/pass/async-drop.rs:24:1: 24:2
           3: main::{closure#0}
               at tests/pass/async-drop.rs:43:33: 43:38
---



FAILED TEST: tests/pass/async-drop.rs (revision `tree`)
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-6X2FAG" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/pass" "tests/pass/async-drop.rs" "-Zmiri-strict-provenance" "-Zmiri-tree-borrows" "--edition" "2021" "--cfg=tree" "-Cextra-filename=tree"

error: test got exit status: 1, but expected 0
 = note: compilation failed, but was expected to succeed

error: no output was expected
Execute `./miri test --bless` to update `tests/pass/async-drop.tree.stderr` to the actual output
+++ <stderr output>
error: Undefined Behavior: constructing invalid value of type {async fn body of std::future::async_drop_in_place<{async fn body of std::future::async_drop_in_place<Int>()}>()}: at .<coroutine-state(0)>.<captured-var(0)>, encountered uninitialized memory, but expected a reference
##[error]  --> /checkout/library/core/src/future/async_drop.rs:55:70
   |
LL |   pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: &mut T) {
   |  ______________________________________________________________________^
...  |
LL | | }
   | |_^ Undefined Behavior occurred here
   |
   = 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: stack backtrace:
           0: std::future::async_drop_in_place::<{async fn body of std::future::async_drop_in_place<Int>()}> - shim(Some({async fn body of std::future::async_drop_in_place<Int>()}))
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           1: std::future::async_drop_in_place::<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>::{closure#0} - shim({async fn body of std::future::async_drop_in_place<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>()})
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           2: test_async_drop::<Int>::{closure#0}
               at tests/pass/async-drop.rs:24:1: 24:2
           3: main::{closure#0}
               at tests/pass/async-drop.rs:43:33: 43:38
---
error: no output was emitted
Execute `./miri test --bless` to remove `tests/pass/async-drop.tree.stdout`

full stderr:
error: Undefined Behavior: constructing invalid value of type {async fn body of std::future::async_drop_in_place<{async fn body of std::future::async_drop_in_place<Int>()}>()}: at .<coroutine-state(0)>.<captured-var(0)>, encountered uninitialized memory, but expected a reference
##[error]  --> /checkout/library/core/src/future/async_drop.rs:55:70
   |
LL |   pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: &mut T) {
   |  ______________________________________________________________________^
...  |
LL | | }
   | |_^ Undefined Behavior occurred here
   |
   = 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: stack backtrace:
           0: std::future::async_drop_in_place::<{async fn body of std::future::async_drop_in_place<Int>()}> - shim(Some({async fn body of std::future::async_drop_in_place<Int>()}))
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           1: std::future::async_drop_in_place::<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>::{closure#0} - shim({async fn body of std::future::async_drop_in_place<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>()})
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           2: test_async_drop::<Int>::{closure#0}
               at tests/pass/async-drop.rs:24:1: 24:2
           3: main::{closure#0}
               at tests/pass/async-drop.rs:43:33: 43:38
---



FAILED TEST: tests/pass/async-drop.rs (revision `tree_implicit_writes`)
command: MIRI_ENV_VAR_TEST="0" MIRI_TEMP="/tmp/miri-uitest-6X2FAG" RUST_BACKTRACE="1" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/miri" "--error-format=json" "-Dwarnings" "-Dunused" "-Ainternal_features" "-Zui-testing" "--sysroot=/checkout/obj/build/x86_64-unknown-linux-gnu/miri-sysroot" "--out-dir" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/tmp/miri_ui/0/tests/pass" "tests/pass/async-drop.rs" "-Zmiri-strict-provenance" "-Zmiri-tree-borrows" "-Zmiri-tree-borrows-implicit-writes" "--edition" "2021" "--cfg=tree_implicit_writes" "-Cextra-filename=tree_implicit_writes"

error: test got exit status: 1, but expected 0
 = note: compilation failed, but was expected to succeed

error: no output was expected
Execute `./miri test --bless` to update `tests/pass/async-drop.tree_implicit_writes.stderr` to the actual output
+++ <stderr output>
error: Undefined Behavior: constructing invalid value of type {async fn body of std::future::async_drop_in_place<{async fn body of std::future::async_drop_in_place<Int>()}>()}: at .<coroutine-state(0)>.<captured-var(0)>, encountered uninitialized memory, but expected a reference
##[error]  --> /checkout/library/core/src/future/async_drop.rs:55:70
   |
LL |   pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: &mut T) {
   |  ______________________________________________________________________^
...  |
LL | | }
   | |_^ Undefined Behavior occurred here
   |
   = 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: stack backtrace:
           0: std::future::async_drop_in_place::<{async fn body of std::future::async_drop_in_place<Int>()}> - shim(Some({async fn body of std::future::async_drop_in_place<Int>()}))
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           1: std::future::async_drop_in_place::<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>::{closure#0} - shim({async fn body of std::future::async_drop_in_place<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>()})
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           2: test_async_drop::<Int>::{closure#0}
               at tests/pass/async-drop.rs:24:1: 24:2
           3: main::{closure#0}
               at tests/pass/async-drop.rs:43:33: 43:38
---
error: no output was emitted
Execute `./miri test --bless` to remove `tests/pass/async-drop.tree_implicit_writes.stdout`

full stderr:
error: Undefined Behavior: constructing invalid value of type {async fn body of std::future::async_drop_in_place<{async fn body of std::future::async_drop_in_place<Int>()}>()}: at .<coroutine-state(0)>.<captured-var(0)>, encountered uninitialized memory, but expected a reference
##[error]  --> /checkout/library/core/src/future/async_drop.rs:55:70
   |
LL |   pub async unsafe fn async_drop_in_place<T: ?Sized>(_to_drop: &mut T) {
   |  ______________________________________________________________________^
...  |
LL | | }
   | |_^ Undefined Behavior occurred here
   |
   = 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: stack backtrace:
           0: std::future::async_drop_in_place::<{async fn body of std::future::async_drop_in_place<Int>()}> - shim(Some({async fn body of std::future::async_drop_in_place<Int>()}))
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           1: std::future::async_drop_in_place::<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>::{closure#0} - shim({async fn body of std::future::async_drop_in_place<std::pin::PinMacroHelper<{async fn body of std::future::async_drop_in_place<Int>()}>>()})
               at /checkout/library/core/src/future/async_drop.rs:55:70: 58:2
           2: test_async_drop::<Int>::{closure#0}
               at tests/pass/async-drop.rs:24:1: 24:2
           3: main::{closure#0}
               at tests/pass/async-drop.rs:43:33: 43:38
---

Location:
   /cargo/registry/src/index.crates.io-1949cf8c6b5b557f/ui_test-0.30.7/src/lib.rs:365

Backtrace omitted. Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
error: test failed, to rerun pass `--test ui`

Caused by:
  process didn't exit successfully: `/checkout/obj/build/x86_64-unknown-linux-gnu/stage2-tools/x86_64-unknown-linux-gnu/release/build/miri/54d3518e03e017c2/out/ui-54d3518e03e017c2` (exit status: 1)
Command `/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo test --target x86_64-unknown-linux-gnu -Zbinary-dep-depinfo -j 4 -Zroot-dir=/checkout -Zembed-metadata=no --locked --color=always --profile=release --manifest-path /checkout/src/tools/miri/Cargo.toml -- [workdir=/checkout]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:208:21
Executed at: src/bootstrap/src/core/build_steps/test.rs:790:19

Command has failed. Rerun with -v to see more details.
Bootstrap failed while executing `test --stage 2 miri cargo-miri`
Currently active steps:
test::Miri { target: x86_64-unknown-linux-gnu } at src/bootstrap/src/core/build_steps/test.rs:716
Build completed unsuccessfully in 0:36:42
  local time: Tue Sep  8 10:19:58 UTC 2026

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants