Skip to content

Commit 3004e8c

Browse files
Remove coroutine info when building coroutine drop body
1 parent cd6d8f2 commit 3004e8c

File tree

3 files changed

+6
-43
lines changed

3 files changed

+6
-43
lines changed

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,12 @@ fn create_coroutine_drop_shim<'tcx>(
12311231
drop_clean: BasicBlock,
12321232
) -> Body<'tcx> {
12331233
let mut body = body.clone();
1234-
body.arg_count = 1; // make sure the resume argument is not included here
1234+
// Take the coroutine info out of the body, since the drop shim is
1235+
// not a coroutine body itself; it just has its drop built out of it.
1236+
let _ = body.coroutine.take();
1237+
// Make sure the resume argument is not included here, since we're
1238+
// building a body for `drop_in_place`.
1239+
body.arg_count = 1;
12351240

12361241
let source_info = SourceInfo::outermost(body.span);
12371242

tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-abort.mir

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
11
// MIR for `main::{closure#0}` 0 coroutine_drop
2-
/* coroutine_layout = CoroutineLayout {
3-
field_tys: {
4-
_0: CoroutineSavedTy {
5-
ty: std::string::String,
6-
source_info: SourceInfo {
7-
span: $DIR/coroutine_drop_cleanup.rs:12:13: 12:15 (#0),
8-
scope: scope[0],
9-
},
10-
ignore_for_traits: false,
11-
},
12-
},
13-
variant_fields: {
14-
Unresumed(0): [],
15-
Returned (1): [],
16-
Panicked (2): [],
17-
Suspend0 (3): [_0],
18-
},
19-
storage_conflicts: BitMatrix(1x1) {
20-
(_0, _0),
21-
},
22-
} */
232

243
fn main::{closure#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:11:15: 11:17}) -> () {
254
let mut _0: ();

tests/mir-opt/coroutine_drop_cleanup.main-{closure#0}.coroutine_drop.0.panic-unwind.mir

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,4 @@
11
// MIR for `main::{closure#0}` 0 coroutine_drop
2-
/* coroutine_layout = CoroutineLayout {
3-
field_tys: {
4-
_0: CoroutineSavedTy {
5-
ty: std::string::String,
6-
source_info: SourceInfo {
7-
span: $DIR/coroutine_drop_cleanup.rs:12:13: 12:15 (#0),
8-
scope: scope[0],
9-
},
10-
ignore_for_traits: false,
11-
},
12-
},
13-
variant_fields: {
14-
Unresumed(0): [],
15-
Returned (1): [],
16-
Panicked (2): [],
17-
Suspend0 (3): [_0],
18-
},
19-
storage_conflicts: BitMatrix(1x1) {
20-
(_0, _0),
21-
},
22-
} */
232

243
fn main::{closure#0}(_1: *mut {coroutine@$DIR/coroutine_drop_cleanup.rs:11:15: 11:17}) -> () {
254
let mut _0: ();

0 commit comments

Comments
 (0)