Closed
Description
This was found during the most recent crater run for #97334. The test case below is reduced from https://github.com/haydnv/tinychain.
pub struct File<B> {
block: B,
}
pub async fn commit<B: Clone>(this: &mut File<B>) {
async {}.await;
async {}.await;
async {}.await;
async {}.await;
let file = async { &this }.await;
*async { &mut this.block }.await = file.block.clone();
}
This ICEs with the following message:
error: internal compiler error: compiler/rustc_mir_transform/src/generator.rs:760:13: Broken MIR: generator contains type B in MIR, but typeck only knows about {ResumeTy, &mut File<B>, impl Future<Output = ()>, (), impl Future<Output = ()>, impl Future<Output = ()>, impl Future<Output = ()>, impl Future<Output = &&mut File<B>>, &&mut File<B>, File<B>, impl Future<Output = &mut B>} and [&mut File<B>]
--> src/lib.rs:5:51
|
5 | pub async fn commit<B: Clone>(this: &mut File<B>) {
| ___________________________________________________^
6 | | async {}.await;
7 | | async {}.await;
8 | | async {}.await;
... |
12 | | *async { &mut this.block }.await = file.block.clone();
13 | | }
| |_^
My guess is that the B
that MIR and typeck disagree on is the one produced by file.block.clone()
.
Weirdly, if any of the async {}.await
lines are removed, the program compiles successfully.
Metadata
Metadata
Assignees
Labels
Area: Async & AwaitAsync-await issues that have been triaged during a working group meeting.Category: This is a bug.Issue: The compiler panicked, giving an Internal Compilation Error (ICE) ❄️Relevant to the compiler team, which will review and decide on the PR/issue.ICE tracked in rust-lang/glacier.