forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rollup merge of rust-lang#129847 - compiler-errors:async-cycle, r=davidtwco Do not call query to compute coroutine layout for synthetic body of async closure There is code in the MIR validator that attempts to prevent query cycles when inlining a coroutine into itself, and will use the coroutine layout directly from the body when it detects that's the same coroutine as the one that's being validated. After rust-lang#128506, this logic didn't take into account the fact that the coroutine def id will differ if it's the "by-move body" of an async closure. This PR implements that. Fixes rust-lang#129811
- Loading branch information
Showing
2 changed files
with
31 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
tests/ui/async-await/async-closures/validate-synthetic-body.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
//@ check-pass | ||
//@ edition: 2021 | ||
|
||
#![feature(async_closure)] | ||
|
||
// Make sure that we don't hit a query cycle when validating | ||
// the by-move coroutine body for an async closure. | ||
|
||
use std::future::Future; | ||
|
||
async fn test<Fut: Future>(operation: impl Fn() -> Fut) { | ||
operation().await; | ||
} | ||
|
||
pub async fn orchestrate_simple_crud() { | ||
test(async || async {}.await).await; | ||
} | ||
|
||
fn main() {} |