Skip to content

Commit 5525043

Browse files
Rename dump of coroutine by-move-body to be more consistent, adjust test
1 parent a4f2a31 commit 5525043

9 files changed

+26
-24
lines changed

compiler/rustc_mir_transform/src/coroutine/by_move_body.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -207,11 +207,11 @@ pub fn coroutine_by_move_body_def_id<'tcx>(
207207

208208
let mut by_move_body = body.clone();
209209
MakeByMoveBody { tcx, field_remapping, by_move_coroutine_ty }.visit_body(&mut by_move_body);
210-
dump_mir(tcx, false, "coroutine_by_move", &0, &by_move_body, |_, _| Ok(()));
211210

212211
let body_def = tcx.create_def(coroutine_def_id, kw::Empty, DefKind::SyntheticCoroutineBody);
213212
by_move_body.source =
214213
mir::MirSource::from_instance(InstanceKind::Item(body_def.def_id().to_def_id()));
214+
dump_mir(tcx, false, "built", &"after", &by_move_body, |_, _| Ok(()));
215215

216216
// Inherited from the by-ref coroutine.
217217
body_def.codegen_fn_attrs(tcx.codegen_fn_attrs(coroutine_def_id).clone());
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `main::{closure#0}::{closure#0}::{closure#0}` 0 coroutine_by_move
1+
// MIR for `main::{closure#0}::{closure#0}::{closure#0}::{closure#0}` after built
22

3-
fn main::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> ()
3+
fn main::{closure#0}::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:55:53: 58:10}, _2: ResumeTy) -> ()
44
yields ()
55
{
66
debug _task_context => _2;
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
// MIR for `main::{closure#0}::{closure#0}::{closure#0}` 0 coroutine_by_move
1+
// MIR for `main::{closure#0}::{closure#0}::{closure#0}` after built
22

3-
fn main::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10}, _2: ResumeTy) -> ()
3+
fn main::{closure#0}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:55:53: 58:10}, _2: ResumeTy) -> ()
44
yields ()
55
{
66
debug _task_context => _2;
77
debug a => (_1.0: i32);
8-
debug b => (_1.1: i32);
8+
debug b => (*(_1.1: &i32));
99
let mut _0: ();
1010
let _3: i32;
1111
scope 1 {
@@ -28,7 +28,7 @@ yields ()
2828
_4 = &_3;
2929
FakeRead(ForLet(None), _4);
3030
StorageLive(_5);
31-
_5 = &(_1.1: i32);
31+
_5 = &(*(_1.1: &i32));
3232
FakeRead(ForLet(None), _5);
3333
_0 = const ();
3434
StorageDead(_5);
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// MIR for `main::{closure#0}::{closure#0}` 0 coroutine_closure_by_move
22

3-
fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:53:33: 53:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10} {
4-
let mut _0: {async closure body@$DIR/async_closure_shims.rs:53:53: 56:10};
3+
fn main::{closure#0}::{closure#0}(_1: {async closure@$DIR/async_closure_shims.rs:55:33: 55:52}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:55:53: 58:10} {
4+
let mut _0: {async closure body@$DIR/async_closure_shims.rs:55:53: 58:10};
55

66
bb0: {
7-
_0 = {coroutine@$DIR/async_closure_shims.rs:53:53: 56:10 (#0)} { a: move _2, b: move (_1.0: i32) };
7+
_0 = {coroutine@$DIR/async_closure_shims.rs:55:53: 58:10 (#0)} { a: move _2, b: move (_1.0: i32) };
88
return;
99
}
1010
}
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `main::{closure#0}::{closure#1}::{closure#0}` 0 coroutine_by_move
1+
// MIR for `main::{closure#0}::{closure#1}::{closure#0}::{closure#0}` after built
22

3-
fn main::{closure#0}::{closure#1}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> ()
3+
fn main::{closure#0}::{closure#1}::{closure#0}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:64:48: 67:10}, _2: ResumeTy) -> ()
44
yields ()
55
{
66
debug _task_context => _2;
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
// MIR for `main::{closure#0}::{closure#1}::{closure#0}` 0 coroutine_by_move
1+
// MIR for `main::{closure#0}::{closure#1}::{closure#0}` after built
22

3-
fn main::{closure#0}::{closure#1}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10}, _2: ResumeTy) -> ()
3+
fn main::{closure#0}::{closure#1}::{closure#0}(_1: {async closure body@$DIR/async_closure_shims.rs:64:48: 67:10}, _2: ResumeTy) -> ()
44
yields ()
55
{
66
debug _task_context => _2;
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// MIR for `main::{closure#0}::{closure#1}` 0 coroutine_closure_by_move
22

3-
fn main::{closure#0}::{closure#1}(_1: {async closure@$DIR/async_closure_shims.rs:62:33: 62:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10} {
4-
let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10};
3+
fn main::{closure#0}::{closure#1}(_1: {async closure@$DIR/async_closure_shims.rs:64:33: 64:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:64:48: 67:10} {
4+
let mut _0: {async closure body@$DIR/async_closure_shims.rs:64:48: 67:10};
55

66
bb0: {
7-
_0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: move (_1.0: &i32) };
7+
_0 = {coroutine@$DIR/async_closure_shims.rs:64:48: 67:10 (#0)} { a: move _2, b: move (_1.0: &i32) };
88
return;
99
}
1010
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// MIR for `main::{closure#0}::{closure#1}` 0 coroutine_closure_by_ref
22

3-
fn main::{closure#0}::{closure#1}(_1: &{async closure@$DIR/async_closure_shims.rs:62:33: 62:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10} {
4-
let mut _0: {async closure body@$DIR/async_closure_shims.rs:62:48: 65:10};
3+
fn main::{closure#0}::{closure#1}(_1: &{async closure@$DIR/async_closure_shims.rs:64:33: 64:47}, _2: i32) -> {async closure body@$DIR/async_closure_shims.rs:64:48: 67:10} {
4+
let mut _0: {async closure body@$DIR/async_closure_shims.rs:64:48: 67:10};
55

66
bb0: {
7-
_0 = {coroutine@$DIR/async_closure_shims.rs:62:48: 65:10 (#0)} { a: move _2, b: copy ((*_1).0: &i32) };
7+
_0 = {coroutine@$DIR/async_closure_shims.rs:64:48: 67:10 (#0)} { a: move _2, b: copy ((*_1).0: &i32) };
88
return;
99
}
1010
}

tests/mir-opt/async_closure_shims.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub fn block_on<T>(fut: impl Future<Output = T>) -> T {
2222
}
2323
}
2424

25-
async fn call(f: &mut impl AsyncFn(i32)) {
25+
async fn call(f: &impl AsyncFn(i32)) {
2626
f(0).await;
2727
}
2828

@@ -43,18 +43,20 @@ async fn call_normal_mut<F: Future<Output = ()>>(f: &mut impl FnMut(i32) -> F) {
4343
}
4444

4545
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}.coroutine_closure_by_move.0.mir
46-
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.coroutine_by_move.0.mir
46+
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}.built.after.mir
47+
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#0}-{closure#0}-{closure#0}.built.after.mir
4748
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_ref.0.mir
4849
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}.coroutine_closure_by_move.0.mir
49-
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.coroutine_by_move.0.mir
50+
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}.built.after.mir
51+
// EMIT_MIR async_closure_shims.main-{closure#0}-{closure#1}-{closure#0}-{closure#0}.built.after.mir
5052
pub fn main() {
5153
block_on(async {
5254
let b = 2i32;
5355
let mut async_closure = async move |a: i32| {
5456
let a = &a;
5557
let b = &b;
5658
};
57-
call(&mut async_closure).await;
59+
call(&async_closure).await;
5860
call_mut(&mut async_closure).await;
5961
call_once(async_closure).await;
6062

0 commit comments

Comments
 (0)