Skip to content

Commit 1d7f4eb

Browse files
committed
Simplify assignment.
1 parent 5e529b0 commit 1d7f4eb

11 files changed

+14
-16
lines changed

compiler/rustc_mir_transform/src/coroutine.rs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -512,17 +512,15 @@ fn make_coroutine_state_argument_pinned<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body
512512
SelfArgVisitor::new(tcx, tcx.mk_place_deref(unpinned_local.into())).visit_body(body);
513513

514514
let source_info = SourceInfo::outermost(body.span);
515+
let pin_field = tcx.mk_place_field(SELF_ARG.into(), FieldIdx::ZERO, ref_coroutine_ty);
516+
515517
body.basic_blocks_mut()[START_BLOCK].statements.insert(
516518
0,
517519
Statement::new(
518520
source_info,
519521
StatementKind::Assign(Box::new((
520522
unpinned_local.into(),
521-
Rvalue::CopyForDeref(tcx.mk_place_field(
522-
SELF_ARG.into(),
523-
FieldIdx::ZERO,
524-
ref_coroutine_ty,
525-
)),
523+
Rvalue::Use(Operand::Copy(pin_field)),
526524
))),
527525
),
528526
);

tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-abort.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body of a<T>()}>, _2: &mut Context<'_>)
2727
}
2828

2929
bb0: {
30-
_20 = deref_copy (_1.0: &mut {async fn body of a<T>()});
30+
_20 = copy (_1.0: &mut {async fn body of a<T>()});
3131
_19 = discriminant((*_20));
3232
switchInt(move _19) -> [0: bb9, 3: bb12, 4: bb13, otherwise: bb14];
3333
}

tests/mir-opt/async_drop_live_dead.a-{closure#0}.coroutine_drop_async.0.panic-unwind.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body of a<T>()}>, _2: &mut Context<'_>)
2727
}
2828

2929
bb0: {
30-
_20 = deref_copy (_1.0: &mut {async fn body of a<T>()});
30+
_20 = copy (_1.0: &mut {async fn body of a<T>()});
3131
_19 = discriminant((*_20));
3232
switchInt(move _19) -> [0: bb12, 2: bb18, 3: bb16, 4: bb17, otherwise: bb19];
3333
}

tests/mir-opt/building/async_await.a-{closure#0}.coroutine_resume.0.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ fn a::{closure#0}(_1: Pin<&mut {async fn body of a()}>, _2: &mut Context<'_>) ->
1717
let mut _5: &mut {async fn body of a()};
1818

1919
bb0: {
20-
_5 = deref_copy (_1.0: &mut {async fn body of a()});
20+
_5 = copy (_1.0: &mut {async fn body of a()});
2121
_4 = discriminant((*_5));
2222
switchInt(move _4) -> [0: bb1, 1: bb4, otherwise: bb5];
2323
}

tests/mir-opt/building/async_await.b-{closure#0}.coroutine_resume.0.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ fn b::{closure#0}(_1: Pin<&mut {async fn body of b()}>, _2: &mut Context<'_>) ->
103103
}
104104

105105
bb0: {
106-
_39 = deref_copy (_1.0: &mut {async fn body of b()});
106+
_39 = copy (_1.0: &mut {async fn body of b()});
107107
_38 = discriminant((*_39));
108108
switchInt(move _38) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb8];
109109
}

tests/mir-opt/building/coroutine.main-{closure#0}.StateTransform.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine.rs:18:5: 18:18}>, _2
4343
let mut _18: &mut {coroutine@$DIR/coroutine.rs:18:5: 18:18};
4444

4545
bb0: {
46-
_18 = deref_copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:18:5: 18:18});
46+
_18 = copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:18:5: 18:18});
4747
_17 = discriminant((*_18));
4848
switchInt(move _17) -> [0: bb1, 1: bb19, 3: bb17, 4: bb18, otherwise: bb20];
4949
}

tests/mir-opt/building/coroutine.main-{closure#1}.StateTransform.after.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ fn main::{closure#1}(_1: Pin<&mut {coroutine@$DIR/coroutine.rs:25:5: 25:18}>, _2
4343
let mut _18: &mut {coroutine@$DIR/coroutine.rs:25:5: 25:18};
4444

4545
bb0: {
46-
_18 = deref_copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:25:5: 25:18});
46+
_18 = copy (_1.0: &mut {coroutine@$DIR/coroutine.rs:25:5: 25:18});
4747
_17 = discriminant((*_18));
4848
switchInt(move _17) -> [0: bb1, 1: bb19, 3: bb17, 4: bb18, otherwise: bb20];
4949
}

tests/mir-opt/coroutine_tiny.main-{closure#0}.coroutine_resume.0.mir

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn main::{closure#0}(_1: Pin<&mut {coroutine@$DIR/coroutine_tiny.rs:21:5: 21:13}
3838
}
3939

4040
bb0: {
41-
_11 = deref_copy (_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:21:5: 21:13});
41+
_11 = copy (_1.0: &mut {coroutine@$DIR/coroutine_tiny.rs:21:5: 21:13});
4242
_10 = discriminant((*_11));
4343
switchInt(move _10) -> [0: bb1, 3: bb5, otherwise: bb6];
4444
}

tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-abort.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
+ StorageLive(_30);
126126
+ StorageLive(_31);
127127
+ StorageLive(_32);
128-
+ _32 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()});
128+
+ _32 = copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()});
129129
+ _31 = discriminant((*_32));
130130
+ switchInt(move _31) -> [0: bb3, 1: bb10, 3: bb9, otherwise: bb5];
131131
}

tests/mir-opt/inline_coroutine_body.run2-{closure#0}.Inline.panic-unwind.diff

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125
+ StorageLive(_30);
126126
+ StorageLive(_31);
127127
+ StorageLive(_32);
128-
+ _32 = deref_copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()});
128+
+ _32 = copy (_8.0: &mut {async fn body of ActionPermit<'_, T>::perform()});
129129
+ _31 = discriminant((*_32));
130130
+ switchInt(move _31) -> [0: bb5, 1: bb15, 2: bb14, 3: bb13, otherwise: bb7];
131131
}

0 commit comments

Comments
 (0)