forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
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#123662 - compiler-errors:no-upvars-yet, r=o…
…li-obk Don't rely on upvars being assigned just because coroutine-closure kind is assigned Previously, code relied on the implicit assumption that if a coroutine-closure's kind variable was constrained, then its upvars were also constrained. This is because we assign all of them at once at the end up upvar analysis. However, there's another way that a coroutine-closure's kind can be constrained: from a signature hint in closure signature deduction. After rust-lang#123350, we use these hints, which means the implicit assumption above no longer holds. This PR adds the necessary checks so that we don't ICE. r? oli-obk
- Loading branch information
Showing
6 changed files
with
75 additions
and
36 deletions.
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
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
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
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
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
27 changes: 27 additions & 0 deletions
27
tests/ui/async-await/async-closures/constrained-but-no-upvars-yet.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,27 @@ | ||
//@ edition: 2021 | ||
//@ check-pass | ||
//@ revisions: current next | ||
//@ ignore-compare-mode-next-solver (explicit revisions) | ||
//@[next] compile-flags: -Znext-solver | ||
|
||
#![feature(async_closure)] | ||
|
||
fn constrain<T: async FnOnce()>(t: T) -> T { | ||
t | ||
} | ||
|
||
fn call_once<T>(f: impl FnOnce() -> T) -> T { | ||
f() | ||
} | ||
|
||
async fn async_call_once<T>(f: impl async FnOnce() -> T) -> T { | ||
f().await | ||
} | ||
|
||
fn main() { | ||
let c = constrain(async || {}); | ||
call_once(c); | ||
|
||
let c = constrain(async || {}); | ||
async_call_once(c); | ||
} |