Skip to content

Commit d5a9135

Browse files
authored
Unrolled build for rust-lang#139699
Rollup merge of rust-lang#139699 - compiler-errors:coroutine-drop-phase, r=scottmcm Proactively update coroutine drop shim's phase to account for later passes applied during shim query See comments in the pass and on test. Also see rust-lang#137264 (comment). Fixes rust-lang#137243 Fixes rust-lang#139698 r? scottmcm
2 parents f836ae4 + bc94c38 commit d5a9135

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Diff for: 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

+19
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)