Change type of async context parameter after state transform.#157166
Conversation
|
This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @vakaras Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
|
r? @tiif rustbot has assigned @tiif. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
8447533 to
8c16d8a
Compare
This comment has been minimized.
This comment has been minimized.
8c16d8a to
ab5076b
Compare
This comment has been minimized.
This comment has been minimized.
ab5076b to
769048f
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
769048f to
89aaf42
Compare
This comment has been minimized.
This comment has been minimized.
89aaf42 to
93879f5
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
93879f5 to
323effe
Compare
This comment has been minimized.
This comment has been minimized.
323effe to
b7e26ac
Compare
|
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. |
| /// HIR uses `get_context` to unwrap a `&mut Context<'_>` from a `ResumeTy`. | ||
| /// Both types are just a single pointer, but liveness analysis does not know that and | ||
| /// supposes that the operand and the destination are live at the same time. | ||
| /// Forcibly inline those calls to avoid this. |
There was a problem hiding this comment.
preexisting, but: it feels a bit funny to generate a function call in ast lowering only to desugar it here manually. The function body is effectively dead code.
…li-obk Change type of async context parameter after state transform. `Future::poll` expects a `&mut std::task::Context<'_>`. Meanwhile, async coroutines use `std::future::ResumeTy` as resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implement `for<'a, 'b> CoroutineTrait<&'a mut Context<'b>>`. In the coroutine state transform, we need to change the signature from `ResumeTy` to the proper `&mut Context<'_>`. The current code attempts to find locals that have type `ResumeTy` to change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder. Instead, this PR proposes to replace the `ResumeTy` argument with a new local, with value `ResumeTy(transmute(context))`. Based on rust-lang#156875.
Rollup of 18 pull requests Successful merges: - #152852 (Remove driver_lint_caps) - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
|
⌛ Testing commit b7e26ac with merge 5103141... Workflow: https://github.com/rust-lang/rust/actions/runs/27238086714 |
Change type of async context parameter after state transform. `Future::poll` expects a `&mut std::task::Context<'_>`. Meanwhile, async coroutines use `std::future::ResumeTy` as resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implement `for<'a, 'b> CoroutineTrait<&'a mut Context<'b>>`. In the coroutine state transform, we need to change the signature from `ResumeTy` to the proper `&mut Context<'_>`. The current code attempts to find locals that have type `ResumeTy` to change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder. Instead, this PR proposes to replace the `ResumeTy` argument with a new local, with value `ResumeTy(transmute(context))`. Based on #156875.
|
yielding to a @bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #129543. |
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
|
⌛ Testing commit b7e26ac with merge 39465ed... Workflow: https://github.com/rust-lang/rust/actions/runs/27248950736 |
Change type of async context parameter after state transform. `Future::poll` expects a `&mut std::task::Context<'_>`. Meanwhile, async coroutines use `std::future::ResumeTy` as resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implement `for<'a, 'b> CoroutineTrait<&'a mut Context<'b>>`. In the coroutine state transform, we need to change the signature from `ResumeTy` to the proper `&mut Context<'_>`. The current code attempts to find locals that have type `ResumeTy` to change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder. Instead, this PR proposes to replace the `ResumeTy` argument with a new local, with value `ResumeTy(transmute(context))`. Based on #156875.
|
same thing @bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #157683. |
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
|
⌛ Testing commit b7e26ac with merge e1e4985... Workflow: https://github.com/rust-lang/rust/actions/runs/27249369474 |
Change type of async context parameter after state transform. `Future::poll` expects a `&mut std::task::Context<'_>`. Meanwhile, async coroutines use `std::future::ResumeTy` as resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implement `for<'a, 'b> CoroutineTrait<&'a mut Context<'b>>`. In the coroutine state transform, we need to change the signature from `ResumeTy` to the proper `&mut Context<'_>`. The current code attempts to find locals that have type `ResumeTy` to change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder. Instead, this PR proposes to replace the `ResumeTy` argument with a new local, with value `ResumeTy(transmute(context))`. Based on #156875.
|
repeated network failures; I've closed the tree elsewhere @bors yield |
|
Auto build was cancelled. Cancelled workflows: The next pull request likely to be tested is #157683. |
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
Rollup of 17 pull requests Successful merges: - #157166 (Change type of async context parameter after state transform.) - #157335 (bootstrap: Handle dotted table keys when parsing bootstrap.toml) - #157503 (Disable `tests/debuginfo/pretty-std.rs` `OsString` cdb check) - #157571 (Remove ProcMacro enum from proc macro ABI) - #148183 (rustdoc: Test & document `test_harness` code block attribute) - #153847 (Fix marker trait winnowing depending on impl order) - #156067 (Fix async drop glue for Box<T>) - #156399 (fix improper ctypes in Znext solver) - #157338 (Make `Literal::byte_character_value` work with bytes as well) - #157410 (Implement rustc_public::CrateDef{,Type} for FieldDef) - #157605 (Arg splat experiment - syntax impl) - #157630 (Add multibyte JSON diagnostic regression test) - #157633 (Reorder `impl` restriction rendering and add bottom margin) - #157642 (Report duplicate relaxed bounds during ast lowering) - #157652 (fix doc for unicode normalization faq on `casefold` APIs) - #157661 (Update to ar_archive_writer v0.5.2) - #157668 (Add test for matches in `rustc_must_match_exhaustively`) Failed merges: - #157670 (Rename `errors.rs` file to `diagnostics.rs` (4/N))
Rollup merge of #157166 - cjgillot:retype-context-after, r=oli-obk Change type of async context parameter after state transform. `Future::poll` expects a `&mut std::task::Context<'_>`. Meanwhile, async coroutines use `std::future::ResumeTy` as resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implement `for<'a, 'b> CoroutineTrait<&'a mut Context<'b>>`. In the coroutine state transform, we need to change the signature from `ResumeTy` to the proper `&mut Context<'_>`. The current code attempts to find locals that have type `ResumeTy` to change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder. Instead, this PR proposes to replace the `ResumeTy` argument with a new local, with value `ResumeTy(transmute(context))`. Based on #156875.
View all comments
Future::pollexpects a&mut std::task::Context<'_>. Meanwhile, async coroutines usestd::future::ResumeTyas resume parameter. This is meant to workaround the limitations of borrowck, which cannot prove that coroutines implementfor<'a, 'b> CoroutineTrait<&'a mut Context<'b>>.In the coroutine state transform, we need to change the signature from
ResumeTyto the proper&mut Context<'_>. The current code attempts to find locals that have typeResumeTyto change their type. This is needlessly complex and relies on undocumented behaviour of the MIR builder.Instead, this PR proposes to replace the
ResumeTyargument with a new local, with valueResumeTy(transmute(context)).Based on #156875.