Skip to content
/ rust Public
forked from rust-lang/rust

Commit bc94c38

Browse files
Proactively update coroutine drop shim's phase to account for later passes applied during shim query
1 parent 9ffde4b commit bc94c38

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

compiler/rustc_mir_transform/src/coroutine.rs

+7
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,13 @@ fn create_coroutine_drop_shim<'tcx>(
11691169
dump_mir(tcx, false, "coroutine_drop", &0, &body, |_, _| Ok(()));
11701170
body.source.instance = drop_instance;
11711171

1172+
// Creating a coroutine drop shim happens on `Analysis(PostCleanup) -> Runtime(Initial)`
1173+
// but the pass manager doesn't update the phase of the coroutine drop shim. Update the
1174+
// phase of the drop shim so that later on when we run the pass manager on the shim, in
1175+
// the `mir_shims` query, we don't ICE on the intra-pass validation before we've updated
1176+
// the phase of the body from analysis.
1177+
body.phase = MirPhase::Runtime(RuntimePhase::Initial);
1178+
11721179
body
11731180
}
11741181

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
//@ compile-flags: -Zvalidate-mir
2+
//@ edition: 2024
3+
//@ build-pass
4+
5+
// Regression test that we don't ICE when encountering a transmute in a coroutine's
6+
// drop shim body, which is conceptually in the Runtime phase but wasn't having the
7+
// phase updated b/c the pass manager neither optimizes nor updates the phase for
8+
// drop shim bodies.
9+
10+
struct HasDrop;
11+
impl Drop for HasDrop {
12+
fn drop(&mut self) {}
13+
}
14+
15+
fn main() {
16+
async {
17+
vec![async { HasDrop }.await];
18+
};
19+
}

0 commit comments

Comments
 (0)