summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:03 +0000
commit64d98f8ee037282c35007b64c2649055c56af1db (patch)
tree5492bcf97fce41ee1c0b1cc2add283f3e66cdab0 /tests/mir-opt/building
parentAdding debian version 1.67.1+dfsg1-1. (diff)
downloadrustc-64d98f8ee037282c35007b64c2649055c56af1db.tar.xz
rustc-64d98f8ee037282c35007b64c2649055c56af1db.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/mir-opt/building')
-rw-r--r--tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir41
-rw-r--r--tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir337
-rw-r--r--tests/mir-opt/building/async_await.rs17
-rw-r--r--tests/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir22
-rw-r--r--tests/mir-opt/building/custom/arbitrary_let.rs28
-rw-r--r--tests/mir-opt/building/custom/consts.consts.built.after.mir22
-rw-r--r--tests/mir-opt/building/custom/consts.rs36
-rw-r--r--tests/mir-opt/building/custom/consts.statics.built.after.mir27
-rw-r--r--tests/mir-opt/building/custom/enums.rs120
-rw-r--r--tests/mir-opt/building/custom/enums.set_discr.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/enums.set_discr_repr.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/enums.switch_bool.built.after.mir19
-rw-r--r--tests/mir-opt/building/custom/enums.switch_option.built.after.mir21
-rw-r--r--tests/mir-opt/building/custom/enums.switch_option_repr.built.after.mir21
-rw-r--r--tests/mir-opt/building/custom/projections.rs85
-rw-r--r--tests/mir-opt/building/custom/projections.set.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/projections.simple_index.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/projections.tuples.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/projections.unions.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/projections.unwrap.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/projections.unwrap_deref.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/references.immut_ref.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/references.mut_ref.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/references.raw_pointer.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/references.rs55
-rw-r--r--tests/mir-opt/building/custom/simple_assign.rs39
-rw-r--r--tests/mir-opt/building/custom/simple_assign.simple.built.after.mir20
-rw-r--r--tests/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir10
-rw-r--r--tests/mir-opt/building/custom/terminators.assert_nonzero.built.after.mir17
-rw-r--r--tests/mir-opt/building/custom/terminators.direct_call.built.after.mir16
-rw-r--r--tests/mir-opt/building/custom/terminators.drop_first.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/terminators.drop_second.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir13
-rw-r--r--tests/mir-opt/building/custom/terminators.rs108
-rw-r--r--tests/mir-opt/building/enum_cast.bar.built.after.mir23
-rw-r--r--tests/mir-opt/building/enum_cast.boo.built.after.mir23
-rw-r--r--tests/mir-opt/building/enum_cast.droppy.built.after.mir72
-rw-r--r--tests/mir-opt/building/enum_cast.foo.built.after.mir17
-rw-r--r--tests/mir-opt/building/enum_cast.rs50
-rw-r--r--tests/mir-opt/building/issue_101867.main.built.after.mir75
-rw-r--r--tests/mir-opt/building/issue_101867.rs7
-rw-r--r--tests/mir-opt/building/issue_49232.main.built.after.mir82
-rw-r--r--tests/mir-opt/building/issue_49232.rs15
-rw-r--r--tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir112
-rw-r--r--tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir112
-rw-r--r--tests/mir-opt/building/match_false_edges.main.built.after.mir174
-rw-r--r--tests/mir-opt/building/match_false_edges.rs39
-rw-r--r--tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir96
-rw-r--r--tests/mir-opt/building/receiver_ptr_mutability.rs20
-rw-r--r--tests/mir-opt/building/simple_match.match_bool.built.after.mir29
-rw-r--r--tests/mir-opt/building/simple_match.rs12
-rw-r--r--tests/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir203
-rw-r--r--tests/mir-opt/building/storage_live_dead_in_statics.rs33
-rw-r--r--tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir111
-rw-r--r--tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir111
-rw-r--r--tests/mir-opt/building/uniform_array_move_out.rs18
56 files changed, 2656 insertions, 0 deletions
diff --git a/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir
new file mode 100644
index 000000000..2a7f90fe9
--- /dev/null
+++ b/tests/mir-opt/building/async_await.a-{closure#0}.generator_resume.0.mir
@@ -0,0 +1,41 @@
+// MIR for `a::{closure#0}` 0 generator_resume
+/* generator_layout = GeneratorLayout {
+ field_tys: {},
+ variant_fields: {
+ Unresumed(0): [],
+ Returned (1): [],
+ Panicked (2): [],
+ },
+ storage_conflicts: BitMatrix(0x0) {},
+} */
+
+fn a::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:11:14: 11:16]>, _2: &mut Context<'_>) -> Poll<()> {
+ debug _task_context => _4; // in scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ let mut _0: std::task::Poll<()>; // return place in scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ let mut _3: (); // in scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ let mut _4: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ let mut _5: u32; // in scope 0 at $DIR/async_await.rs:+0:14: +0:16
+
+ bb0: {
+ _5 = discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:11:14: 11:16]))); // scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb3]; // scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ }
+
+ bb1: {
+ _4 = move _2; // scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ _3 = const (); // scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ Deinit(_0); // scope 0 at $DIR/async_await.rs:+0:16: +0:16
+ ((_0 as Ready).0: ()) = move _3; // scope 0 at $DIR/async_await.rs:+0:16: +0:16
+ discriminant(_0) = 0; // scope 0 at $DIR/async_await.rs:+0:16: +0:16
+ discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:11:14: 11:16]))) = 1; // scope 0 at $DIR/async_await.rs:+0:16: +0:16
+ return; // scope 0 at $DIR/async_await.rs:+0:16: +0:16
+ }
+
+ bb2: {
+ assert(const false, "`async fn` resumed after completion") -> bb2; // scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ }
+
+ bb3: {
+ unreachable; // scope 0 at $DIR/async_await.rs:+0:14: +0:16
+ }
+}
diff --git a/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir
new file mode 100644
index 000000000..05edc4797
--- /dev/null
+++ b/tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir
@@ -0,0 +1,337 @@
+// MIR for `b::{closure#0}` 0 generator_resume
+/* generator_layout = GeneratorLayout {
+ field_tys: {
+ _0: impl std::future::Future<Output = ()>,
+ _1: impl std::future::Future<Output = ()>,
+ },
+ variant_fields: {
+ Unresumed(0): [],
+ Returned (1): [],
+ Panicked (2): [],
+ Suspend0 (3): [_0],
+ Suspend1 (4): [_1],
+ },
+ storage_conflicts: BitMatrix(2x2) {
+ (_0, _0),
+ (_1, _1),
+ },
+} */
+
+fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>, _2: &mut Context<'_>) -> Poll<()> {
+ debug _task_context => _38; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ let mut _0: std::task::Poll<()>; // return place in scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ let _3: (); // in scope 0 at $DIR/async_await.rs:+1:5: +1:14
+ let mut _4: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _5: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:8
+ let mut _6: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _7: (); // in scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ let _8: (); // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _9: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _11: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _12: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _13: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14
+ let mut _14: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14
+ let mut _15: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _16: isize; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _18: !; // in scope 0 at $DIR/async_await.rs:+1:5: +1:14
+ let mut _19: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _20: (); // in scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ let mut _21: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _22: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:8
+ let mut _23: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let _24: (); // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _25: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _27: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _28: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _29: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14
+ let mut _30: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14
+ let mut _31: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _32: isize; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _34: !; // in scope 0 at $DIR/async_await.rs:+2:5: +2:14
+ let mut _35: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _36: (); // in scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ let mut _37: (); // in scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ let mut _38: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ let mut _39: u32; // in scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ scope 1 {
+ debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // in scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ let _17: (); // in scope 1 at $DIR/async_await.rs:+1:5: +1:14
+ scope 2 {
+ }
+ scope 3 {
+ debug result => _17; // in scope 3 at $DIR/async_await.rs:+1:5: +1:14
+ }
+ }
+ scope 4 {
+ debug __awaitee => (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // in scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ let _33: (); // in scope 4 at $DIR/async_await.rs:+2:5: +2:14
+ scope 5 {
+ }
+ scope 6 {
+ debug result => _33; // in scope 6 at $DIR/async_await.rs:+2:5: +2:14
+ }
+ }
+
+ bb0: {
+ _39 = discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ switchInt(move _39) -> [0: bb1, 1: bb29, 3: bb27, 4: bb28, otherwise: bb30]; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ }
+
+ bb1: {
+ _38 = move _2; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ StorageLive(_3); // scope 0 at $DIR/async_await.rs:+1:5: +1:14
+ StorageLive(_4); // scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_5); // scope 0 at $DIR/async_await.rs:+1:5: +1:8
+ _5 = a() -> bb2; // scope 0 at $DIR/async_await.rs:+1:5: +1:8
+ // mir::Constant
+ // + span: $DIR/async_await.rs:15:5: 15:6
+ // + literal: Const { ty: fn() -> impl Future<Output = ()> {a}, val: Value(<ZST>) }
+ }
+
+ bb2: {
+ _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> bb3; // scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ // mir::Constant
+ // + span: $DIR/async_await.rs:15:8: 15:14
+ // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) }
+ }
+
+ bb3: {
+ StorageDead(_5); // scope 0 at $DIR/async_await.rs:+1:13: +1:14
+ nop; // scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>) = move _4; // scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ }
+
+ bb4: {
+ StorageLive(_8); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_9); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_10); // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_11); // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ _12 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#3).0: impl std::future::Future<Output = ()>); // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> bb5; // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ // mir::Constant
+ // + span: $DIR/async_await.rs:15:8: 15:14
+ // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) }
+ }
+
+ bb5: {
+ StorageDead(_11); // scope 2 at $DIR/async_await.rs:+1:13: +1:14
+ StorageLive(_13); // scope 2 at $DIR/async_await.rs:+1:5: +1:14
+ StorageLive(_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14
+ StorageLive(_15); // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ _15 = _38; // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ _14 = move _15; // scope 2 at $DIR/async_await.rs:+1:5: +1:14
+ goto -> bb6; // scope 2 at $DIR/async_await.rs:+1:5: +1:14
+ }
+
+ bb6: {
+ _13 = &mut (*_14); // scope 2 at $DIR/async_await.rs:+1:5: +1:14
+ StorageDead(_15); // scope 2 at $DIR/async_await.rs:+1:13: +1:14
+ _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> bb7; // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ // mir::Constant
+ // + span: $DIR/async_await.rs:15:8: 15:14
+ // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) }
+ }
+
+ bb7: {
+ StorageDead(_13); // scope 2 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_10); // scope 2 at $DIR/async_await.rs:+1:13: +1:14
+ _16 = discriminant(_9); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ }
+
+ bb8: {
+ _8 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ StorageDead(_14); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_12); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_9); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_8); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ _20 = (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ Deinit(_0); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ discriminant(_0) = 1; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 3; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ return; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ }
+
+ bb9: {
+ unreachable; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ }
+
+ bb10: {
+ StorageLive(_17); // scope 1 at $DIR/async_await.rs:+1:5: +1:14
+ _17 = ((_9 as Ready).0: ()); // scope 1 at $DIR/async_await.rs:+1:5: +1:14
+ _3 = _17; // scope 3 at $DIR/async_await.rs:+1:5: +1:14
+ StorageDead(_17); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_14); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_12); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_9); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ StorageDead(_8); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ goto -> bb12; // scope 0 at $DIR/async_await.rs:+1:13: +1:14
+ }
+
+ bb11: {
+ StorageDead(_20); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ _38 = move _19; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ StorageDead(_19); // scope 1 at $DIR/async_await.rs:+1:13: +1:14
+ _7 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ }
+
+ bb12: {
+ nop; // scope 0 at $DIR/async_await.rs:+1:13: +1:14
+ goto -> bb13; // scope 0 at $DIR/async_await.rs:+1:14: +1:15
+ }
+
+ bb13: {
+ StorageDead(_4); // scope 0 at $DIR/async_await.rs:+1:14: +1:15
+ StorageDead(_3); // scope 0 at $DIR/async_await.rs:+1:14: +1:15
+ StorageLive(_21); // scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_22); // scope 0 at $DIR/async_await.rs:+2:5: +2:8
+ _22 = a() -> bb14; // scope 0 at $DIR/async_await.rs:+2:5: +2:8
+ // mir::Constant
+ // + span: $DIR/async_await.rs:16:5: 16:6
+ // + literal: Const { ty: fn() -> impl Future<Output = ()> {a}, val: Value(<ZST>) }
+ }
+
+ bb14: {
+ _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> bb15; // scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ // mir::Constant
+ // + span: $DIR/async_await.rs:16:8: 16:14
+ // + literal: Const { ty: fn(impl Future<Output = ()>) -> <impl Future<Output = ()> as IntoFuture>::IntoFuture {<impl Future<Output = ()> as IntoFuture>::into_future}, val: Value(<ZST>) }
+ }
+
+ bb15: {
+ StorageDead(_22); // scope 0 at $DIR/async_await.rs:+2:13: +2:14
+ nop; // scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>) = move _21; // scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ }
+
+ bb16: {
+ StorageLive(_24); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_26); // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_27); // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ _28 = &mut (((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2])) as variant#4).0: impl std::future::Future<Output = ()>); // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> bb17; // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ // mir::Constant
+ // + span: $DIR/async_await.rs:16:8: 16:14
+ // + literal: Const { ty: unsafe fn(&mut impl Future<Output = ()>) -> Pin<&mut impl Future<Output = ()>> {Pin::<&mut impl Future<Output = ()>>::new_unchecked}, val: Value(<ZST>) }
+ }
+
+ bb17: {
+ StorageDead(_27); // scope 5 at $DIR/async_await.rs:+2:13: +2:14
+ StorageLive(_29); // scope 5 at $DIR/async_await.rs:+2:5: +2:14
+ StorageLive(_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14
+ StorageLive(_31); // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ _31 = _38; // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ _30 = move _31; // scope 5 at $DIR/async_await.rs:+2:5: +2:14
+ goto -> bb18; // scope 5 at $DIR/async_await.rs:+2:5: +2:14
+ }
+
+ bb18: {
+ _29 = &mut (*_30); // scope 5 at $DIR/async_await.rs:+2:5: +2:14
+ StorageDead(_31); // scope 5 at $DIR/async_await.rs:+2:13: +2:14
+ _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> bb19; // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ // mir::Constant
+ // + span: $DIR/async_await.rs:16:8: 16:14
+ // + literal: Const { ty: for<'a, 'b, 'c> fn(Pin<&'a mut impl Future<Output = ()>>, &'b mut Context<'c>) -> Poll<<impl Future<Output = ()> as Future>::Output> {<impl Future<Output = ()> as Future>::poll}, val: Value(<ZST>) }
+ }
+
+ bb19: {
+ StorageDead(_29); // scope 5 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_26); // scope 5 at $DIR/async_await.rs:+2:13: +2:14
+ _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ switchInt(move _32) -> [0: bb22, 1: bb20, otherwise: bb21]; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ }
+
+ bb20: {
+ _24 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ StorageDead(_30); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_28); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_25); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_24); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ _36 = (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ Deinit(_0); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ discriminant(_0) = 1; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 4; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ return; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ }
+
+ bb21: {
+ unreachable; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ }
+
+ bb22: {
+ StorageLive(_33); // scope 4 at $DIR/async_await.rs:+2:5: +2:14
+ _33 = ((_25 as Ready).0: ()); // scope 4 at $DIR/async_await.rs:+2:5: +2:14
+ _37 = _33; // scope 6 at $DIR/async_await.rs:+2:5: +2:14
+ StorageDead(_33); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_30); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_28); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_25); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ StorageDead(_24); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ goto -> bb24; // scope 0 at $DIR/async_await.rs:+2:13: +2:14
+ }
+
+ bb23: {
+ StorageDead(_36); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ StorageDead(_35); // scope 4 at $DIR/async_await.rs:+2:13: +2:14
+ _7 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ }
+
+ bb24: {
+ nop; // scope 0 at $DIR/async_await.rs:+2:13: +2:14
+ goto -> bb25; // scope 0 at $DIR/async_await.rs:+3:1: +3:2
+ }
+
+ bb25: {
+ StorageDead(_21); // scope 0 at $DIR/async_await.rs:+3:1: +3:2
+ goto -> bb26; // scope 0 at $DIR/async_await.rs:+3:1: +3:2
+ }
+
+ bb26: {
+ Deinit(_0); // scope 0 at $DIR/async_await.rs:+3:2: +3:2
+ ((_0 as Ready).0: ()) = move _37; // scope 0 at $DIR/async_await.rs:+3:2: +3:2
+ discriminant(_0) = 0; // scope 0 at $DIR/async_await.rs:+3:2: +3:2
+ discriminant((*(_1.0: &mut [async fn body@$DIR/async_await.rs:14:18: 17:2]))) = 1; // scope 0 at $DIR/async_await.rs:+3:2: +3:2
+ return; // scope 0 at $DIR/async_await.rs:+3:2: +3:2
+ }
+
+ bb27: {
+ StorageLive(_3); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ StorageLive(_4); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ StorageLive(_19); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ StorageLive(_20); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ _19 = move _2; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ goto -> bb11; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ }
+
+ bb28: {
+ StorageLive(_21); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ StorageLive(_35); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ StorageLive(_36); // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ _35 = move _2; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ goto -> bb23; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ }
+
+ bb29: {
+ assert(const false, "`async fn` resumed after completion") -> bb29; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ }
+
+ bb30: {
+ unreachable; // scope 0 at $DIR/async_await.rs:+0:18: +3:2
+ }
+}
diff --git a/tests/mir-opt/building/async_await.rs b/tests/mir-opt/building/async_await.rs
new file mode 100644
index 000000000..0b991e3b8
--- /dev/null
+++ b/tests/mir-opt/building/async_await.rs
@@ -0,0 +1,17 @@
+// This test makes sure that the generator MIR pass eliminates all calls to
+// `get_context`, and that the MIR argument type for an async fn and all locals
+// related to `yield` are `&mut Context`, and its return type is `Poll`.
+
+// edition:2018
+// compile-flags: -C panic=abort
+
+#![crate_type = "lib"]
+
+// EMIT_MIR async_await.a-{closure#0}.generator_resume.0.mir
+async fn a() {}
+
+// EMIT_MIR async_await.b-{closure#0}.generator_resume.0.mir
+pub async fn b() {
+ a().await;
+ a().await
+}
diff --git a/tests/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir b/tests/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir
new file mode 100644
index 000000000..20dd251e7
--- /dev/null
+++ b/tests/mir-opt/building/custom/arbitrary_let.arbitrary_let.built.after.mir
@@ -0,0 +1,22 @@
+// MIR for `arbitrary_let` after built
+
+fn arbitrary_let(_1: i32) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/arbitrary_let.rs:+0:29: +0:32
+ let mut _2: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = _1; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ goto -> bb2; // scope 0 at $DIR/arbitrary_let.rs:+4:13: +4:25
+ }
+
+ bb1: {
+ _0 = _3; // scope 0 at $DIR/arbitrary_let.rs:+7:13: +7:20
+ return; // scope 0 at $DIR/arbitrary_let.rs:+8:13: +8:21
+ }
+
+ bb2: {
+ _3 = _2; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ goto -> bb1; // scope 0 at $DIR/arbitrary_let.rs:+12:13: +12:24
+ }
+}
diff --git a/tests/mir-opt/building/custom/arbitrary_let.rs b/tests/mir-opt/building/custom/arbitrary_let.rs
new file mode 100644
index 000000000..776df3151
--- /dev/null
+++ b/tests/mir-opt/building/custom/arbitrary_let.rs
@@ -0,0 +1,28 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+use core::ptr::{addr_of, addr_of_mut};
+
+// EMIT_MIR arbitrary_let.arbitrary_let.built.after.mir
+#[custom_mir(dialect = "built")]
+fn arbitrary_let(x: i32) -> i32 {
+ mir!(
+ {
+ let y = x;
+ Goto(second)
+ }
+ third = {
+ RET = z;
+ Return()
+ }
+ second = {
+ let z = y;
+ Goto(third)
+ }
+ )
+}
+
+fn main() {
+ assert_eq!(arbitrary_let(5), 5);
+}
diff --git a/tests/mir-opt/building/custom/consts.consts.built.after.mir b/tests/mir-opt/building/custom/consts.consts.built.after.mir
new file mode 100644
index 000000000..ba753cfc2
--- /dev/null
+++ b/tests/mir-opt/building/custom/consts.consts.built.after.mir
@@ -0,0 +1,22 @@
+// MIR for `consts` after built
+
+fn consts() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/consts.rs:+0:27: +0:27
+ let mut _1: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _2: i8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _3: u32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _4: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _5: fn() {consts::<10>}; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _1 = const 5_u8; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ _2 = const _; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ _3 = const C; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ _4 = const _; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ _5 = consts::<10>; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ // mir::Constant
+ // + span: $DIR/consts.rs:16:18: 16:30
+ // + literal: Const { ty: fn() {consts::<10>}, val: Value(<ZST>) }
+ return; // scope 0 at $DIR/consts.rs:+7:9: +7:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/consts.rs b/tests/mir-opt/building/custom/consts.rs
new file mode 100644
index 000000000..16d10eb59
--- /dev/null
+++ b/tests/mir-opt/building/custom/consts.rs
@@ -0,0 +1,36 @@
+#![feature(custom_mir, core_intrinsics, inline_const)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+
+const D: i32 = 5;
+
+// EMIT_MIR consts.consts.built.after.mir
+#[custom_mir(dialect = "built")]
+fn consts<const C: u32>() {
+ mir!({
+ let _a = 5_u8;
+ let _b = const { 5_i8 };
+ let _c = C;
+ let _d = D;
+ let _e = consts::<10>;
+ Return()
+ })
+}
+
+static S: i32 = 0x05050505;
+static mut T: i32 = 0x0a0a0a0a;
+// EMIT_MIR consts.statics.built.after.mir
+#[custom_mir(dialect = "built")]
+fn statics() {
+ mir!({
+ let _a: &i32 = Static(S);
+ let _b: *mut i32 = StaticMut(T);
+ Return()
+ })
+}
+
+fn main() {
+ consts::<5>();
+ statics();
+}
diff --git a/tests/mir-opt/building/custom/consts.statics.built.after.mir b/tests/mir-opt/building/custom/consts.statics.built.after.mir
new file mode 100644
index 000000000..bfef976aa
--- /dev/null
+++ b/tests/mir-opt/building/custom/consts.statics.built.after.mir
@@ -0,0 +1,27 @@
+// MIR for `statics` after built
+
+fn statics() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/consts.rs:+0:14: +0:14
+ let mut _1: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _2: *mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _1 = const {alloc1: &i32}; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ // mir::Constant
+ // + span: $DIR/consts.rs:27:31: 27:32
+ // + literal: Const { ty: &i32, val: Value(Scalar(alloc1)) }
+ _2 = const {alloc2: *mut i32}; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ // mir::Constant
+ // + span: $DIR/consts.rs:28:38: 28:39
+ // + literal: Const { ty: *mut i32, val: Value(Scalar(alloc2)) }
+ return; // scope 0 at $DIR/consts.rs:+4:9: +4:17
+ }
+}
+
+alloc2 (static: T, size: 4, align: 4) {
+ 0a 0a 0a 0a │ ....
+}
+
+alloc1 (static: S, size: 4, align: 4) {
+ 05 05 05 05 │ ....
+}
diff --git a/tests/mir-opt/building/custom/enums.rs b/tests/mir-opt/building/custom/enums.rs
new file mode 100644
index 000000000..e5cd45637
--- /dev/null
+++ b/tests/mir-opt/building/custom/enums.rs
@@ -0,0 +1,120 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+
+// EMIT_MIR enums.switch_bool.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn switch_bool(b: bool) -> u32 {
+ mir!(
+ {
+ match b {
+ true => t,
+ false => f,
+ _ => f,
+ }
+ }
+
+ t = {
+ RET = 5;
+ Return()
+ }
+
+ f = {
+ RET = 10;
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR enums.switch_option.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn switch_option(option: Option<()>) -> bool {
+ mir!(
+ {
+ let discr = Discriminant(option);
+ match discr {
+ 0 => n,
+ 1 => s,
+ _ => s,
+ }
+ }
+
+ n = {
+ RET = false;
+ Return()
+ }
+
+ s = {
+ RET = true;
+ Return()
+ }
+ )
+}
+
+#[repr(u8)]
+enum Bool {
+ False = 0,
+ True = 1,
+}
+
+// EMIT_MIR enums.switch_option_repr.built.after.mir
+#[custom_mir(dialect = "built")]
+fn switch_option_repr(option: Bool) -> bool {
+ mir!(
+ {
+ let discr = Discriminant(option);
+ match discr {
+ 0 => f,
+ _ => t,
+ }
+ }
+
+ t = {
+ RET = true;
+ Return()
+ }
+
+ f = {
+ RET = false;
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR enums.set_discr.built.after.mir
+#[custom_mir(dialect = "runtime", phase = "initial")]
+fn set_discr(option: &mut Option<()>) {
+ mir!({
+ SetDiscriminant(*option, 0);
+ Return()
+ })
+}
+
+// EMIT_MIR enums.set_discr_repr.built.after.mir
+#[custom_mir(dialect = "runtime", phase = "initial")]
+fn set_discr_repr(b: &mut Bool) {
+ mir!({
+ SetDiscriminant(*b, 0);
+ Return()
+ })
+}
+
+fn main() {
+ assert_eq!(switch_bool(true), 5);
+ assert_eq!(switch_bool(false), 10);
+
+ assert_eq!(switch_option(Some(())), true);
+ assert_eq!(switch_option(None), false);
+
+ assert_eq!(switch_option_repr(Bool::True), true);
+ assert_eq!(switch_option_repr(Bool::False), false);
+
+ let mut opt = Some(());
+ set_discr(&mut opt);
+ assert_eq!(opt, None);
+
+ let mut b = Bool::True;
+ set_discr_repr(&mut b);
+ assert!(matches!(b, Bool::False));
+}
diff --git a/tests/mir-opt/building/custom/enums.set_discr.built.after.mir b/tests/mir-opt/building/custom/enums.set_discr.built.after.mir
new file mode 100644
index 000000000..7de9ed098
--- /dev/null
+++ b/tests/mir-opt/building/custom/enums.set_discr.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `set_discr` after built
+
+fn set_discr(_1: &mut Option<()>) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/enums.rs:+0:39: +0:39
+
+ bb0: {
+ discriminant((*_1)) = 0; // scope 0 at $DIR/enums.rs:+2:9: +2:36
+ return; // scope 0 at $DIR/enums.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/enums.set_discr_repr.built.after.mir b/tests/mir-opt/building/custom/enums.set_discr_repr.built.after.mir
new file mode 100644
index 000000000..6fdc3d0f4
--- /dev/null
+++ b/tests/mir-opt/building/custom/enums.set_discr_repr.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `set_discr_repr` after built
+
+fn set_discr_repr(_1: &mut Bool) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/enums.rs:+0:33: +0:33
+
+ bb0: {
+ discriminant((*_1)) = 0; // scope 0 at $DIR/enums.rs:+2:9: +2:31
+ return; // scope 0 at $DIR/enums.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/enums.switch_bool.built.after.mir b/tests/mir-opt/building/custom/enums.switch_bool.built.after.mir
new file mode 100644
index 000000000..95c57d2dc
--- /dev/null
+++ b/tests/mir-opt/building/custom/enums.switch_bool.built.after.mir
@@ -0,0 +1,19 @@
+// MIR for `switch_bool` after built
+
+fn switch_bool(_1: bool) -> u32 {
+ let mut _0: u32; // return place in scope 0 at $DIR/enums.rs:+0:32: +0:35
+
+ bb0: {
+ switchInt(_1) -> [1: bb1, 0: bb2, otherwise: bb2]; // scope 0 at $DIR/enums.rs:+3:13: +7:14
+ }
+
+ bb1: {
+ _0 = const 5_u32; // scope 0 at $DIR/enums.rs:+11:13: +11:20
+ return; // scope 0 at $DIR/enums.rs:+12:13: +12:21
+ }
+
+ bb2: {
+ _0 = const 10_u32; // scope 0 at $DIR/enums.rs:+16:13: +16:21
+ return; // scope 0 at $DIR/enums.rs:+17:13: +17:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/enums.switch_option.built.after.mir b/tests/mir-opt/building/custom/enums.switch_option.built.after.mir
new file mode 100644
index 000000000..a659ba7c1
--- /dev/null
+++ b/tests/mir-opt/building/custom/enums.switch_option.built.after.mir
@@ -0,0 +1,21 @@
+// MIR for `switch_option` after built
+
+fn switch_option(_1: Option<()>) -> bool {
+ let mut _0: bool; // return place in scope 0 at $DIR/enums.rs:+0:45: +0:49
+ let mut _2: isize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = discriminant(_1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ switchInt(_2) -> [0: bb1, 1: bb2, otherwise: bb2]; // scope 0 at $DIR/enums.rs:+4:13: +8:14
+ }
+
+ bb1: {
+ _0 = const false; // scope 0 at $DIR/enums.rs:+12:13: +12:24
+ return; // scope 0 at $DIR/enums.rs:+13:13: +13:21
+ }
+
+ bb2: {
+ _0 = const true; // scope 0 at $DIR/enums.rs:+17:13: +17:23
+ return; // scope 0 at $DIR/enums.rs:+18:13: +18:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/enums.switch_option_repr.built.after.mir b/tests/mir-opt/building/custom/enums.switch_option_repr.built.after.mir
new file mode 100644
index 000000000..d60e4b1b7
--- /dev/null
+++ b/tests/mir-opt/building/custom/enums.switch_option_repr.built.after.mir
@@ -0,0 +1,21 @@
+// MIR for `switch_option_repr` after built
+
+fn switch_option_repr(_1: Bool) -> bool {
+ let mut _0: bool; // return place in scope 0 at $DIR/enums.rs:+0:40: +0:44
+ let mut _2: u8; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = discriminant(_1); // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ switchInt(_2) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/enums.rs:+4:13: +7:14
+ }
+
+ bb1: {
+ _0 = const true; // scope 0 at $DIR/enums.rs:+11:13: +11:23
+ return; // scope 0 at $DIR/enums.rs:+12:13: +12:21
+ }
+
+ bb2: {
+ _0 = const false; // scope 0 at $DIR/enums.rs:+16:13: +16:24
+ return; // scope 0 at $DIR/enums.rs:+17:13: +17:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.rs b/tests/mir-opt/building/custom/projections.rs
new file mode 100644
index 000000000..5e472e531
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.rs
@@ -0,0 +1,85 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+
+union U {
+ a: i32,
+ b: u32,
+}
+
+// EMIT_MIR projections.unions.built.after.mir
+#[custom_mir(dialect = "built")]
+fn unions(u: U) -> i32 {
+ mir!({
+ RET = u.a;
+ Return()
+ })
+}
+
+// EMIT_MIR projections.tuples.built.after.mir
+#[custom_mir(dialect = "analysis", phase = "post-cleanup")]
+fn tuples(i: (u32, i32)) -> (u32, i32) {
+ mir!(
+ // FIXME(JakobDegen): This is necessary because we can't give type hints for `RET`
+ let temp: (u32, i32);
+ {
+ temp.0 = i.0;
+ temp.1 = i.1;
+
+ RET = temp;
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR projections.unwrap.built.after.mir
+#[custom_mir(dialect = "built")]
+fn unwrap(opt: Option<i32>) -> i32 {
+ mir!({
+ RET = Field(Variant(opt, 1), 0);
+ Return()
+ })
+}
+
+// EMIT_MIR projections.unwrap_deref.built.after.mir
+#[custom_mir(dialect = "built")]
+fn unwrap_deref(opt: Option<&i32>) -> i32 {
+ mir!({
+ RET = *Field::<&i32>(Variant(opt, 1), 0);
+ Return()
+ })
+}
+
+// EMIT_MIR projections.set.built.after.mir
+#[custom_mir(dialect = "built")]
+fn set(opt: &mut Option<i32>) {
+ mir!({
+ place!(Field(Variant(*opt, 1), 0)) = 10;
+ Return()
+ })
+}
+
+// EMIT_MIR projections.simple_index.built.after.mir
+#[custom_mir(dialect = "built")]
+fn simple_index(a: [i32; 10], b: &[i32]) -> i32 {
+ mir!({
+ let temp = 3;
+ RET = a[temp];
+ RET = (*b)[temp];
+ Return()
+ })
+}
+
+fn main() {
+ assert_eq!(unions(U { a: 5 }), 5);
+ assert_eq!(tuples((5, 6)), (5, 6));
+
+ assert_eq!(unwrap(Some(5)), 5);
+ assert_eq!(unwrap_deref(Some(&5)), 5);
+ let mut o = Some(5);
+ set(&mut o);
+ assert_eq!(o, Some(10));
+
+ assert_eq!(simple_index([0; 10], &[0; 10]), 0);
+}
diff --git a/tests/mir-opt/building/custom/projections.set.built.after.mir b/tests/mir-opt/building/custom/projections.set.built.after.mir
new file mode 100644
index 000000000..2f15176a6
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.set.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `set` after built
+
+fn set(_1: &mut Option<i32>) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/projections.rs:+0:31: +0:31
+
+ bb0: {
+ (((*_1) as variant#1).0: i32) = const 10_i32; // scope 0 at $DIR/projections.rs:+2:9: +2:48
+ return; // scope 0 at $DIR/projections.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.simple_index.built.after.mir b/tests/mir-opt/building/custom/projections.simple_index.built.after.mir
new file mode 100644
index 000000000..fc422e4b3
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.simple_index.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `simple_index` after built
+
+fn simple_index(_1: [i32; 10], _2: &[i32]) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:45: +0:48
+ let mut _3: usize; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _3 = const 3_usize; // scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ _0 = _1[_3]; // scope 0 at $DIR/projections.rs:+3:9: +3:22
+ _0 = (*_2)[_3]; // scope 0 at $DIR/projections.rs:+4:9: +4:25
+ return; // scope 0 at $DIR/projections.rs:+5:9: +5:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.tuples.built.after.mir b/tests/mir-opt/building/custom/projections.tuples.built.after.mir
new file mode 100644
index 000000000..65487d3c9
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.tuples.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `tuples` after built
+
+fn tuples(_1: (u32, i32)) -> (u32, i32) {
+ let mut _0: (u32, i32); // return place in scope 0 at $DIR/projections.rs:+0:29: +0:39
+ let mut _2: (u32, i32); // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ (_2.0: u32) = (_1.0: u32); // scope 0 at $DIR/projections.rs:+5:13: +5:25
+ (_2.1: i32) = (_1.1: i32); // scope 0 at $DIR/projections.rs:+6:13: +6:25
+ _0 = _2; // scope 0 at $DIR/projections.rs:+8:13: +8:23
+ return; // scope 0 at $DIR/projections.rs:+9:13: +9:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.unions.built.after.mir b/tests/mir-opt/building/custom/projections.unions.built.after.mir
new file mode 100644
index 000000000..922538a5f
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.unions.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `unions` after built
+
+fn unions(_1: U) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:20: +0:23
+
+ bb0: {
+ _0 = (_1.0: i32); // scope 0 at $DIR/projections.rs:+2:9: +2:18
+ return; // scope 0 at $DIR/projections.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.unwrap.built.after.mir b/tests/mir-opt/building/custom/projections.unwrap.built.after.mir
new file mode 100644
index 000000000..75b03a3c3
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.unwrap.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `unwrap` after built
+
+fn unwrap(_1: Option<i32>) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:32: +0:35
+
+ bb0: {
+ _0 = ((_1 as variant#1).0: i32); // scope 0 at $DIR/projections.rs:+2:9: +2:40
+ return; // scope 0 at $DIR/projections.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.unwrap_deref.built.after.mir b/tests/mir-opt/building/custom/projections.unwrap_deref.built.after.mir
new file mode 100644
index 000000000..c6b0f7efa
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.unwrap_deref.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `unwrap_deref` after built
+
+fn unwrap_deref(_1: Option<&i32>) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:39: +0:42
+
+ bb0: {
+ _0 = (*((_1 as variant#1).0: &i32)); // scope 0 at $DIR/projections.rs:+2:9: +2:49
+ return; // scope 0 at $DIR/projections.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/references.immut_ref.built.after.mir b/tests/mir-opt/building/custom/references.immut_ref.built.after.mir
new file mode 100644
index 000000000..f5ee11262
--- /dev/null
+++ b/tests/mir-opt/building/custom/references.immut_ref.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `immut_ref` after built
+
+fn immut_ref(_1: &i32) -> &i32 {
+ let mut _0: &i32; // return place in scope 0 at $DIR/references.rs:+0:30: +0:34
+ let mut _2: *const i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = &raw const (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:29
+ _0 = &(*_2); // scope 0 at $DIR/references.rs:+6:13: +6:23
+ Retag(_0); // scope 0 at $DIR/references.rs:+7:13: +7:23
+ return; // scope 0 at $DIR/references.rs:+8:13: +8:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/references.mut_ref.built.after.mir b/tests/mir-opt/building/custom/references.mut_ref.built.after.mir
new file mode 100644
index 000000000..8e2ffc33b
--- /dev/null
+++ b/tests/mir-opt/building/custom/references.mut_ref.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `mut_ref` after built
+
+fn mut_ref(_1: &mut i32) -> &mut i32 {
+ let mut _0: &mut i32; // return place in scope 0 at $DIR/references.rs:+0:32: +0:40
+ let mut _2: *mut i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = &raw mut (*_1); // scope 0 at $DIR/references.rs:+5:13: +5:33
+ _0 = &mut (*_2); // scope 0 at $DIR/references.rs:+6:13: +6:26
+ Retag(_0); // scope 0 at $DIR/references.rs:+7:13: +7:23
+ return; // scope 0 at $DIR/references.rs:+8:13: +8:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/references.raw_pointer.built.after.mir b/tests/mir-opt/building/custom/references.raw_pointer.built.after.mir
new file mode 100644
index 000000000..775e5e3ad
--- /dev/null
+++ b/tests/mir-opt/building/custom/references.raw_pointer.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `raw_pointer` after built
+
+fn raw_pointer(_1: *const i32) -> *const i32 {
+ let mut _0: *const i32; // return place in scope 0 at $DIR/references.rs:+0:38: +0:48
+
+ bb0: {
+ _0 = &raw const (*_1); // scope 0 at $DIR/references.rs:+4:9: +4:27
+ return; // scope 0 at $DIR/references.rs:+5:9: +5:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/references.rs b/tests/mir-opt/building/custom/references.rs
new file mode 100644
index 000000000..a1c896de0
--- /dev/null
+++ b/tests/mir-opt/building/custom/references.rs
@@ -0,0 +1,55 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+use core::ptr::{addr_of, addr_of_mut};
+
+// EMIT_MIR references.mut_ref.built.after.mir
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn mut_ref(x: &mut i32) -> &mut i32 {
+ mir!(
+ let t: *mut i32;
+
+ {
+ t = addr_of_mut!(*x);
+ RET = &mut *t;
+ Retag(RET);
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR references.immut_ref.built.after.mir
+#[custom_mir(dialect = "runtime", phase = "optimized")]
+pub fn immut_ref(x: &i32) -> &i32 {
+ mir!(
+ let t: *const i32;
+
+ {
+ t = addr_of!(*x);
+ RET = & *t;
+ Retag(RET);
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR references.raw_pointer.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn raw_pointer(x: *const i32) -> *const i32 {
+ // Regression test for a bug in which unsafetyck was not correctly turned off for
+ // `dialect = "built"`
+ mir!({
+ RET = addr_of!(*x);
+ Return()
+ })
+}
+
+fn main() {
+ let mut x = 5;
+ assert_eq!(*mut_ref(&mut x), 5);
+ assert_eq!(*immut_ref(&x), 5);
+ unsafe {
+ assert_eq!(*raw_pointer(addr_of!(x)), 5);
+ }
+}
diff --git a/tests/mir-opt/building/custom/simple_assign.rs b/tests/mir-opt/building/custom/simple_assign.rs
new file mode 100644
index 000000000..db041aab2
--- /dev/null
+++ b/tests/mir-opt/building/custom/simple_assign.rs
@@ -0,0 +1,39 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+
+// EMIT_MIR simple_assign.simple.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn simple(x: i32) -> i32 {
+ mir!(
+ let temp1: i32;
+ let temp2: _;
+
+ {
+ StorageLive(temp1);
+ temp1 = x;
+ Goto(exit)
+ }
+
+ exit = {
+ temp2 = Move(temp1);
+ StorageDead(temp1);
+ RET = temp2;
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR simple_assign.simple_ref.built.after.mir
+#[custom_mir(dialect = "built")]
+pub fn simple_ref(x: &mut i32) -> &mut i32 {
+ mir!({
+ RET = Move(x);
+ Return()
+ })
+}
+
+fn main() {
+ assert_eq!(5, simple(5));
+}
diff --git a/tests/mir-opt/building/custom/simple_assign.simple.built.after.mir b/tests/mir-opt/building/custom/simple_assign.simple.built.after.mir
new file mode 100644
index 000000000..743016708
--- /dev/null
+++ b/tests/mir-opt/building/custom/simple_assign.simple.built.after.mir
@@ -0,0 +1,20 @@
+// MIR for `simple` after built
+
+fn simple(_1: i32) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/simple_assign.rs:+0:26: +0:29
+ let mut _2: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+ let mut _3: i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/simple_assign.rs:+6:13: +6:31
+ _2 = _1; // scope 0 at $DIR/simple_assign.rs:+7:13: +7:22
+ goto -> bb1; // scope 0 at $DIR/simple_assign.rs:+8:13: +8:23
+ }
+
+ bb1: {
+ _3 = move _2; // scope 0 at $DIR/simple_assign.rs:+12:13: +12:32
+ StorageDead(_2); // scope 0 at $DIR/simple_assign.rs:+13:13: +13:31
+ _0 = _3; // scope 0 at $DIR/simple_assign.rs:+14:13: +14:24
+ return; // scope 0 at $DIR/simple_assign.rs:+15:13: +15:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir b/tests/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir
new file mode 100644
index 000000000..2b0e8f104
--- /dev/null
+++ b/tests/mir-opt/building/custom/simple_assign.simple_ref.built.after.mir
@@ -0,0 +1,10 @@
+// MIR for `simple_ref` after built
+
+fn simple_ref(_1: &mut i32) -> &mut i32 {
+ let mut _0: &mut i32; // return place in scope 0 at $DIR/simple_assign.rs:+0:35: +0:43
+
+ bb0: {
+ _0 = move _1; // scope 0 at $DIR/simple_assign.rs:+2:9: +2:22
+ return; // scope 0 at $DIR/simple_assign.rs:+3:9: +3:17
+ }
+}
diff --git a/tests/mir-opt/building/custom/terminators.assert_nonzero.built.after.mir b/tests/mir-opt/building/custom/terminators.assert_nonzero.built.after.mir
new file mode 100644
index 000000000..a1a27226b
--- /dev/null
+++ b/tests/mir-opt/building/custom/terminators.assert_nonzero.built.after.mir
@@ -0,0 +1,17 @@
+// MIR for `assert_nonzero` after built
+
+fn assert_nonzero(_1: i32) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/terminators.rs:+0:27: +0:27
+
+ bb0: {
+ switchInt(_1) -> [0: bb1, otherwise: bb2]; // scope 0 at $DIR/terminators.rs:+3:13: +6:14
+ }
+
+ bb1: {
+ unreachable; // scope 0 at $DIR/terminators.rs:+10:13: +10:26
+ }
+
+ bb2: {
+ return; // scope 0 at $DIR/terminators.rs:+14:13: +14:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir b/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir
new file mode 100644
index 000000000..1b2345a96
--- /dev/null
+++ b/tests/mir-opt/building/custom/terminators.direct_call.built.after.mir
@@ -0,0 +1,16 @@
+// MIR for `direct_call` after built
+
+fn direct_call(_1: i32) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/terminators.rs:+0:27: +0:30
+
+ bb0: {
+ _0 = ident::<i32>(_1) -> bb1; // scope 0 at $DIR/terminators.rs:+3:13: +3:42
+ // mir::Constant
+ // + span: $DIR/terminators.rs:15:33: 15:38
+ // + literal: Const { ty: fn(i32) -> i32 {ident::<i32>}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+ return; // scope 0 at $DIR/terminators.rs:+7:13: +7:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir b/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir
new file mode 100644
index 000000000..c903e5946
--- /dev/null
+++ b/tests/mir-opt/building/custom/terminators.drop_first.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `drop_first` after built
+
+fn drop_first(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/terminators.rs:+0:59: +0:59
+
+ bb0: {
+ replace(_1 <- move _2) -> bb1; // scope 0 at $DIR/terminators.rs:+3:13: +3:49
+ }
+
+ bb1: {
+ return; // scope 0 at $DIR/terminators.rs:+7:13: +7:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir b/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir
new file mode 100644
index 000000000..f14246f2d
--- /dev/null
+++ b/tests/mir-opt/building/custom/terminators.drop_second.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `drop_second` after built
+
+fn drop_second(_1: WriteOnDrop<'_>, _2: WriteOnDrop<'_>) -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/terminators.rs:+0:60: +0:60
+
+ bb0: {
+ drop(_2) -> bb1; // scope 0 at $DIR/terminators.rs:+3:13: +3:30
+ }
+
+ bb1: {
+ return; // scope 0 at $DIR/terminators.rs:+7:13: +7:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir b/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir
new file mode 100644
index 000000000..2f1b14069
--- /dev/null
+++ b/tests/mir-opt/building/custom/terminators.indirect_call.built.after.mir
@@ -0,0 +1,13 @@
+// MIR for `indirect_call` after built
+
+fn indirect_call(_1: i32, _2: fn(i32) -> i32) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/terminators.rs:+0:48: +0:51
+
+ bb0: {
+ _0 = _2(_1) -> bb1; // scope 0 at $DIR/terminators.rs:+3:13: +3:38
+ }
+
+ bb1: {
+ return; // scope 0 at $DIR/terminators.rs:+7:13: +7:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/terminators.rs b/tests/mir-opt/building/custom/terminators.rs
new file mode 100644
index 000000000..c23233fcf
--- /dev/null
+++ b/tests/mir-opt/building/custom/terminators.rs
@@ -0,0 +1,108 @@
+#![feature(custom_mir, core_intrinsics)]
+
+extern crate core;
+use core::intrinsics::mir::*;
+
+fn ident<T>(t: T) -> T {
+ t
+}
+
+// EMIT_MIR terminators.direct_call.built.after.mir
+#[custom_mir(dialect = "built")]
+fn direct_call(x: i32) -> i32 {
+ mir!(
+ {
+ Call(RET, retblock, ident(x))
+ }
+
+ retblock = {
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR terminators.indirect_call.built.after.mir
+#[custom_mir(dialect = "built")]
+fn indirect_call(x: i32, f: fn(i32) -> i32) -> i32 {
+ mir!(
+ {
+ Call(RET, retblock, f(x))
+ }
+
+ retblock = {
+ Return()
+ }
+ )
+}
+
+struct WriteOnDrop<'a>(&'a mut i32, i32);
+
+impl<'a> Drop for WriteOnDrop<'a> {
+ fn drop(&mut self) {
+ *self.0 = self.1;
+ }
+}
+
+// EMIT_MIR terminators.drop_first.built.after.mir
+#[custom_mir(dialect = "built")]
+fn drop_first<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
+ mir!(
+ {
+ DropAndReplace(a, Move(b), retblock)
+ }
+
+ retblock = {
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR terminators.drop_second.built.after.mir
+#[custom_mir(dialect = "built")]
+fn drop_second<'a>(a: WriteOnDrop<'a>, b: WriteOnDrop<'a>) {
+ mir!(
+ {
+ Drop(b, retblock)
+ }
+
+ retblock = {
+ Return()
+ }
+ )
+}
+
+// EMIT_MIR terminators.assert_nonzero.built.after.mir
+#[custom_mir(dialect = "built")]
+fn assert_nonzero(a: i32) {
+ mir!(
+ {
+ match a {
+ 0 => unreachable,
+ _ => retblock
+ }
+ }
+
+ unreachable = {
+ Unreachable()
+ }
+
+ retblock = {
+ Return()
+ }
+ )
+}
+
+fn main() {
+ assert_eq!(direct_call(5), 5);
+ assert_eq!(indirect_call(5, ident), 5);
+
+ let mut a = 0;
+ let mut b = 0;
+ drop_first(WriteOnDrop(&mut a, 1), WriteOnDrop(&mut b, 1));
+ assert_eq!((a, b), (1, 0));
+
+ let mut a = 0;
+ let mut b = 0;
+ drop_second(WriteOnDrop(&mut a, 1), WriteOnDrop(&mut b, 1));
+ assert_eq!((a, b), (0, 1));
+}
diff --git a/tests/mir-opt/building/enum_cast.bar.built.after.mir b/tests/mir-opt/building/enum_cast.bar.built.after.mir
new file mode 100644
index 000000000..0746e0b49
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.bar.built.after.mir
@@ -0,0 +1,23 @@
+// MIR for `bar` after built
+
+fn bar(_1: Bar) -> usize {
+ debug bar => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
+ let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26
+ let _2: Bar; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _4: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _4 = Ge(const 1_isize, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(_4); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _5 = Le(const 0_isize, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(_5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17
+ return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2
+ }
+}
diff --git a/tests/mir-opt/building/enum_cast.boo.built.after.mir b/tests/mir-opt/building/enum_cast.boo.built.after.mir
new file mode 100644
index 000000000..699c876b0
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.boo.built.after.mir
@@ -0,0 +1,23 @@
+// MIR for `boo` after built
+
+fn boo(_1: Boo) -> usize {
+ debug boo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
+ let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26
+ let _2: Boo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _3: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _4: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _4 = Ge(const 1_u8, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(_4); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _5 = Le(const 0_u8, _3); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(_5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17
+ return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2
+ }
+}
diff --git a/tests/mir-opt/building/enum_cast.droppy.built.after.mir b/tests/mir-opt/building/enum_cast.droppy.built.after.mir
new file mode 100644
index 000000000..5231c2eab
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.droppy.built.after.mir
@@ -0,0 +1,72 @@
+// MIR for `droppy` after built
+
+fn droppy() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/enum_cast.rs:+0:13: +0:13
+ let _1: (); // in scope 0 at $DIR/enum_cast.rs:+1:5: +6:6
+ let _2: Droppy; // in scope 0 at $DIR/enum_cast.rs:+2:13: +2:14
+ let _4: Droppy; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18
+ let mut _5: isize; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:18
+ let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27
+ let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+5:17: +5:27
+ let _8: Droppy; // in scope 0 at $DIR/enum_cast.rs:+7:9: +7:10
+ scope 1 {
+ debug x => _2; // in scope 1 at $DIR/enum_cast.rs:+2:13: +2:14
+ scope 2 {
+ debug y => _3; // in scope 2 at $DIR/enum_cast.rs:+5:13: +5:14
+ }
+ scope 3 {
+ let _3: usize; // in scope 3 at $DIR/enum_cast.rs:+5:13: +5:14
+ }
+ }
+ scope 4 {
+ debug z => _8; // in scope 4 at $DIR/enum_cast.rs:+7:9: +7:10
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/enum_cast.rs:+1:5: +6:6
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+2:13: +2:14
+ _2 = Droppy::C; // scope 0 at $DIR/enum_cast.rs:+2:17: +2:26
+ FakeRead(ForLet(None), _2); // scope 0 at $DIR/enum_cast.rs:+2:13: +2:14
+ StorageLive(_3); // scope 3 at $DIR/enum_cast.rs:+5:13: +5:14
+ StorageLive(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18
+ _4 = move _2; // scope 3 at $DIR/enum_cast.rs:+5:17: +5:18
+ _5 = discriminant(_4); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ _6 = Ge(const 2_isize, _5); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ assume(_6); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ _7 = Le(const 0_isize, _5); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ assume(_7); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ _3 = move _5 as usize (IntToInt); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ drop(_4) -> [return: bb1, unwind: bb4]; // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27
+ }
+
+ bb1: {
+ StorageDead(_4); // scope 3 at $DIR/enum_cast.rs:+5:26: +5:27
+ FakeRead(ForLet(None), _3); // scope 3 at $DIR/enum_cast.rs:+5:13: +5:14
+ _1 = const (); // scope 0 at $DIR/enum_cast.rs:+1:5: +6:6
+ StorageDead(_3); // scope 1 at $DIR/enum_cast.rs:+6:5: +6:6
+ drop(_2) -> [return: bb2, unwind: bb5]; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6
+ }
+
+ bb2: {
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6
+ StorageDead(_1); // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6
+ StorageLive(_8); // scope 0 at $DIR/enum_cast.rs:+7:9: +7:10
+ _8 = Droppy::B; // scope 0 at $DIR/enum_cast.rs:+7:13: +7:22
+ FakeRead(ForLet(None), _8); // scope 0 at $DIR/enum_cast.rs:+7:9: +7:10
+ _0 = const (); // scope 0 at $DIR/enum_cast.rs:+0:13: +8:2
+ drop(_8) -> [return: bb3, unwind: bb5]; // scope 0 at $DIR/enum_cast.rs:+8:1: +8:2
+ }
+
+ bb3: {
+ StorageDead(_8); // scope 0 at $DIR/enum_cast.rs:+8:1: +8:2
+ return; // scope 0 at $DIR/enum_cast.rs:+8:2: +8:2
+ }
+
+ bb4 (cleanup): {
+ drop(_2) -> bb5; // scope 0 at $DIR/enum_cast.rs:+6:5: +6:6
+ }
+
+ bb5 (cleanup): {
+ resume; // scope 0 at $DIR/enum_cast.rs:+0:1: +8:2
+ }
+}
diff --git a/tests/mir-opt/building/enum_cast.foo.built.after.mir b/tests/mir-opt/building/enum_cast.foo.built.after.mir
new file mode 100644
index 000000000..17e0abf2e
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.foo.built.after.mir
@@ -0,0 +1,17 @@
+// MIR for `foo` after built
+
+fn foo(_1: Foo) -> usize {
+ debug foo => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
+ let mut _0: usize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26
+ let _2: Foo; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _0 = move _3 as usize (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:16: +1:17
+ return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2
+ }
+}
diff --git a/tests/mir-opt/building/enum_cast.rs b/tests/mir-opt/building/enum_cast.rs
new file mode 100644
index 000000000..98fd5acfb
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.rs
@@ -0,0 +1,50 @@
+// EMIT_MIR enum_cast.foo.built.after.mir
+// EMIT_MIR enum_cast.bar.built.after.mir
+// EMIT_MIR enum_cast.boo.built.after.mir
+
+enum Foo {
+ A
+}
+
+enum Bar {
+ A, B
+}
+
+#[repr(u8)]
+enum Boo {
+ A, B
+}
+
+fn foo(foo: Foo) -> usize {
+ foo as usize
+}
+
+fn bar(bar: Bar) -> usize {
+ bar as usize
+}
+
+fn boo(boo: Boo) -> usize {
+ boo as usize
+}
+
+// EMIT_MIR enum_cast.droppy.built.after.mir
+enum Droppy {
+ A, B, C
+}
+
+impl Drop for Droppy {
+ fn drop(&mut self) {}
+}
+
+fn droppy() {
+ {
+ let x = Droppy::C;
+ // remove this entire test once `cenum_impl_drop_cast` becomes a hard error
+ #[allow(cenum_impl_drop_cast)]
+ let y = x as usize;
+ }
+ let z = Droppy::B;
+}
+
+fn main() {
+}
diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir
new file mode 100644
index 000000000..628a33f10
--- /dev/null
+++ b/tests/mir-opt/building/issue_101867.main.built.after.mir
@@ -0,0 +1,75 @@
+// MIR for `main` after built
+
+| User Type Annotations
+| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8>
+| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(std::option::Option<u8>) }, span: $DIR/issue_101867.rs:3:12: 3:22, inferred_ty: std::option::Option<u8>
+|
+fn main() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/issue_101867.rs:+0:11: +0:11
+ let _1: std::option::Option<u8> as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/issue_101867.rs:+1:9: +1:10
+ let mut _2: !; // in scope 0 at $DIR/issue_101867.rs:+2:26: +4:6
+ let _3: (); // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
+ let mut _4: !; // in scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL
+ let mut _6: isize; // in scope 0 at $DIR/issue_101867.rs:+2:9: +2:16
+ scope 1 {
+ debug x => _1; // in scope 1 at $DIR/issue_101867.rs:+1:9: +1:10
+ let _5: u8; // in scope 1 at $DIR/issue_101867.rs:+2:14: +2:15
+ scope 2 {
+ debug y => _5; // in scope 2 at $DIR/issue_101867.rs:+2:14: +2:15
+ }
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/issue_101867.rs:+1:9: +1:10
+ _1 = Option::<u8>::Some(const 1_u8); // scope 0 at $DIR/issue_101867.rs:+1:25: +1:32
+ FakeRead(ForLet(None), _1); // scope 0 at $DIR/issue_101867.rs:+1:9: +1:10
+ AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/issue_101867.rs:+1:12: +1:22
+ StorageLive(_5); // scope 1 at $DIR/issue_101867.rs:+2:14: +2:15
+ FakeRead(ForMatchedPlace(None), _1); // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20
+ _6 = discriminant(_1); // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20
+ switchInt(move _6) -> [1: bb4, otherwise: bb3]; // scope 1 at $DIR/issue_101867.rs:+2:9: +2:16
+ }
+
+ bb1: {
+ StorageLive(_3); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
+ StorageLive(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
+ _4 = begin_panic::<&str>(const "explicit panic") -> bb7; // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
+ // mir::Constant
+ // + span: $SRC_DIR/std/src/panic.rs:LL:COL
+ // + literal: Const { ty: fn(&str) -> ! {begin_panic::<&str>}, val: Value(<ZST>) }
+ // mir::Constant
+ // + span: $SRC_DIR/std/src/panic.rs:LL:COL
+ // + literal: Const { ty: &str, val: Value(Slice(..)) }
+ }
+
+ bb2: {
+ StorageDead(_4); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL
+ StorageDead(_3); // scope 1 at $DIR/issue_101867.rs:+3:16: +3:17
+ unreachable; // scope 1 at $DIR/issue_101867.rs:+2:26: +4:6
+ }
+
+ bb3: {
+ goto -> bb6; // scope 1 at $DIR/issue_101867.rs:+2:19: +2:20
+ }
+
+ bb4: {
+ falseEdge -> [real: bb5, imaginary: bb3]; // scope 1 at $DIR/issue_101867.rs:+2:9: +2:16
+ }
+
+ bb5: {
+ _5 = ((_1 as Some).0: u8); // scope 1 at $DIR/issue_101867.rs:+2:14: +2:15
+ _0 = const (); // scope 0 at $DIR/issue_101867.rs:+0:11: +5:2
+ StorageDead(_5); // scope 1 at $DIR/issue_101867.rs:+5:1: +5:2
+ StorageDead(_1); // scope 0 at $DIR/issue_101867.rs:+5:1: +5:2
+ return; // scope 0 at $DIR/issue_101867.rs:+5:2: +5:2
+ }
+
+ bb6: {
+ StorageDead(_5); // scope 1 at $DIR/issue_101867.rs:+5:1: +5:2
+ goto -> bb1; // scope 0 at $DIR/issue_101867.rs:+0:11: +5:2
+ }
+
+ bb7 (cleanup): {
+ resume; // scope 0 at $DIR/issue_101867.rs:+0:1: +5:2
+ }
+}
diff --git a/tests/mir-opt/building/issue_101867.rs b/tests/mir-opt/building/issue_101867.rs
new file mode 100644
index 000000000..a32d8cb37
--- /dev/null
+++ b/tests/mir-opt/building/issue_101867.rs
@@ -0,0 +1,7 @@
+// EMIT_MIR issue_101867.main.built.after.mir
+fn main() {
+ let x: Option<u8> = Some(1);
+ let Some(y) = x else {
+ panic!();
+ };
+}
diff --git a/tests/mir-opt/building/issue_49232.main.built.after.mir b/tests/mir-opt/building/issue_49232.main.built.after.mir
new file mode 100644
index 000000000..de5e4c0f6
--- /dev/null
+++ b/tests/mir-opt/building/issue_49232.main.built.after.mir
@@ -0,0 +1,82 @@
+// MIR for `main` after built
+
+fn main() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/issue_49232.rs:+0:11: +0:11
+ let mut _1: (); // in scope 0 at $DIR/issue_49232.rs:+0:1: +10:2
+ let _2: i32; // in scope 0 at $DIR/issue_49232.rs:+2:13: +2:19
+ let mut _3: bool; // in scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+ let mut _4: !; // in scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
+ let _5: (); // in scope 0 at $DIR/issue_49232.rs:+8:9: +8:22
+ let mut _6: &i32; // in scope 0 at $DIR/issue_49232.rs:+8:14: +8:21
+ scope 1 {
+ debug beacon => _2; // in scope 1 at $DIR/issue_49232.rs:+2:13: +2:19
+ }
+
+ bb0: {
+ goto -> bb1; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6
+ }
+
+ bb1: {
+ falseUnwind -> [real: bb2, cleanup: bb11]; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6
+ }
+
+ bb2: {
+ StorageLive(_2); // scope 0 at $DIR/issue_49232.rs:+2:13: +2:19
+ StorageLive(_3); // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+ _3 = const true; // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+ FakeRead(ForMatchedPlace(None), _3); // scope 0 at $DIR/issue_49232.rs:+3:19: +3:23
+ switchInt(_3) -> [0: bb3, otherwise: bb4]; // scope 0 at $DIR/issue_49232.rs:+3:13: +3:23
+ }
+
+ bb3: {
+ falseEdge -> [real: bb5, imaginary: bb4]; // scope 0 at $DIR/issue_49232.rs:+4:17: +4:22
+ }
+
+ bb4: {
+ _0 = const (); // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
+ goto -> bb10; // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
+ }
+
+ bb5: {
+ _2 = const 4_i32; // scope 0 at $DIR/issue_49232.rs:+4:26: +4:27
+ goto -> bb8; // scope 0 at $DIR/issue_49232.rs:+4:26: +4:27
+ }
+
+ bb6: {
+ unreachable; // scope 0 at $DIR/issue_49232.rs:+5:25: +5:30
+ }
+
+ bb7: {
+ goto -> bb8; // scope 0 at $DIR/issue_49232.rs:+6:13: +6:14
+ }
+
+ bb8: {
+ FakeRead(ForLet(None), _2); // scope 0 at $DIR/issue_49232.rs:+2:13: +2:19
+ StorageDead(_3); // scope 0 at $DIR/issue_49232.rs:+7:10: +7:11
+ StorageLive(_5); // scope 1 at $DIR/issue_49232.rs:+8:9: +8:22
+ StorageLive(_6); // scope 1 at $DIR/issue_49232.rs:+8:14: +8:21
+ _6 = &_2; // scope 1 at $DIR/issue_49232.rs:+8:14: +8:21
+ _5 = std::mem::drop::<&i32>(move _6) -> [return: bb9, unwind: bb11]; // scope 1 at $DIR/issue_49232.rs:+8:9: +8:22
+ // mir::Constant
+ // + span: $DIR/issue_49232.rs:13:9: 13:13
+ // + literal: Const { ty: fn(&i32) {std::mem::drop::<&i32>}, val: Value(<ZST>) }
+ }
+
+ bb9: {
+ StorageDead(_6); // scope 1 at $DIR/issue_49232.rs:+8:21: +8:22
+ StorageDead(_5); // scope 1 at $DIR/issue_49232.rs:+8:22: +8:23
+ _1 = const (); // scope 0 at $DIR/issue_49232.rs:+1:10: +9:6
+ StorageDead(_2); // scope 0 at $DIR/issue_49232.rs:+9:5: +9:6
+ goto -> bb1; // scope 0 at $DIR/issue_49232.rs:+1:5: +9:6
+ }
+
+ bb10: {
+ StorageDead(_3); // scope 0 at $DIR/issue_49232.rs:+7:10: +7:11
+ StorageDead(_2); // scope 0 at $DIR/issue_49232.rs:+9:5: +9:6
+ return; // scope 0 at $DIR/issue_49232.rs:+10:2: +10:2
+ }
+
+ bb11 (cleanup): {
+ resume; // scope 0 at $DIR/issue_49232.rs:+0:1: +10:2
+ }
+}
diff --git a/tests/mir-opt/building/issue_49232.rs b/tests/mir-opt/building/issue_49232.rs
new file mode 100644
index 000000000..7e9f0de81
--- /dev/null
+++ b/tests/mir-opt/building/issue_49232.rs
@@ -0,0 +1,15 @@
+// We must mark a variable whose initialization fails due to an
+// abort statement as StorageDead.
+
+// EMIT_MIR issue_49232.main.built.after.mir
+fn main() {
+ loop {
+ let beacon = {
+ match true {
+ false => 4,
+ true => break,
+ }
+ };
+ drop(&beacon);
+ }
+}
diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
new file mode 100644
index 000000000..cb36bc64d
--- /dev/null
+++ b/tests/mir-opt/building/match_false_edges.full_tested_match.built.after.mir
@@ -0,0 +1,112 @@
+// MIR for `full_tested_match` after built
+
+fn full_tested_match() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:28: +0:28
+ let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
+ let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16
+ let mut _4: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36
+ let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
+ let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+3:24: +3:25
+ scope 1 {
+ }
+ scope 2 {
+ debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15
+ debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15
+ }
+ scope 3 {
+ debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:+3:14: +3:15
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
+ StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ _2 = Option::<i32>::Some(const 42_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ switchInt(move _3) -> [0: bb1, 1: bb2, otherwise: bb4]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:27
+ }
+
+ bb1: {
+ _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
+ goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:17: +4:23
+ }
+
+ bb2: {
+ falseEdge -> [real: bb5, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16
+ }
+
+ bb3: {
+ falseEdge -> [real: bb10, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:16
+ }
+
+ bb4: {
+ unreachable; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ }
+
+ bb5: {
+ StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ _7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ // mir::Constant
+ // + span: $DIR/match_false_edges.rs:14:20: 14:25
+ // + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
+ }
+
+ bb6: {
+ switchInt(move _7) -> [0: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ }
+
+ bb7: {
+ StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ _5 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ StorageLive(_8); // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36
+ _8 = _5; // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36
+ _1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:+2:31: +2:37
+ StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37
+ StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ }
+
+ bb8: {
+ goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ }
+
+ bb9: {
+ StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ goto -> bb3; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ }
+
+ bb10: {
+ StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
+ _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+3:14: +3:15
+ StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25
+ _10 = _9; // scope 3 at $DIR/match_false_edges.rs:+3:24: +3:25
+ _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+3:20: +3:26
+ StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+3:25: +3:26
+ StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
+ goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:25: +3:26
+ }
+
+ bb11: {
+ StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
+ StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
+ _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:28: +6:2
+ return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2
+ }
+
+ bb12 (cleanup): {
+ resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2
+ }
+}
diff --git a/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
new file mode 100644
index 000000000..7f8755faa
--- /dev/null
+++ b/tests/mir-opt/building/match_false_edges.full_tested_match2.built.after.mir
@@ -0,0 +1,112 @@
+// MIR for `full_tested_match2` after built
+
+fn full_tested_match2() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:29: +0:29
+ let mut _1: (i32, i32); // in scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
+ let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16
+ let mut _4: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ let _5: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ let _6: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ let mut _7: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ let mut _8: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:35: +2:36
+ let _9: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ let mut _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:24: +4:25
+ scope 1 {
+ }
+ scope 2 {
+ debug x => _5; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15
+ debug x => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:15
+ }
+ scope 3 {
+ debug y => _9; // in scope 3 at $DIR/match_false_edges.rs:+4:14: +4:15
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +5:6
+ StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ _2 = Option::<i32>::Some(const 42_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ switchInt(move _3) -> [0: bb1, 1: bb2, otherwise: bb4]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:27
+ }
+
+ bb1: {
+ falseEdge -> [real: bb10, imaginary: bb3]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:13
+ }
+
+ bb2: {
+ falseEdge -> [real: bb5, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:16
+ }
+
+ bb3: {
+ StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ _9 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ StorageLive(_10); // scope 3 at $DIR/match_false_edges.rs:+4:24: +4:25
+ _10 = _9; // scope 3 at $DIR/match_false_edges.rs:+4:24: +4:25
+ _1 = (const 2_i32, move _10); // scope 3 at $DIR/match_false_edges.rs:+4:20: +4:26
+ StorageDead(_10); // scope 3 at $DIR/match_false_edges.rs:+4:25: +4:26
+ StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
+ goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+4:25: +4:26
+ }
+
+ bb4: {
+ unreachable; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ }
+
+ bb5: {
+ StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ _6 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ _4 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:27
+ StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ _7 = guard() -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ // mir::Constant
+ // + span: $DIR/match_false_edges.rs:25:20: 25:25
+ // + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
+ }
+
+ bb6: {
+ switchInt(move _7) -> [0: bb8, otherwise: bb7]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ }
+
+ bb7: {
+ StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ FakeRead(ForMatchGuard, _4); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ FakeRead(ForGuardBinding, _6); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ StorageLive(_5); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ _5 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:15
+ StorageLive(_8); // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36
+ _8 = _5; // scope 2 at $DIR/match_false_edges.rs:+2:35: +2:36
+ _1 = (const 1_i32, move _8); // scope 2 at $DIR/match_false_edges.rs:+2:31: +2:37
+ StorageDead(_8); // scope 2 at $DIR/match_false_edges.rs:+2:36: +2:37
+ StorageDead(_5); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ }
+
+ bb8: {
+ goto -> bb9; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ }
+
+ bb9: {
+ StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:26: +2:27
+ StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:36: +2:37
+ falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:20: +2:27
+ }
+
+ bb10: {
+ _1 = (const 3_i32, const 3_i32); // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
+ goto -> bb11; // scope 0 at $DIR/match_false_edges.rs:+3:17: +3:23
+ }
+
+ bb11: {
+ StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
+ StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+5:6: +5:7
+ _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:29: +6:2
+ return; // scope 0 at $DIR/match_false_edges.rs:+6:2: +6:2
+ }
+
+ bb12 (cleanup): {
+ resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +6:2
+ }
+}
diff --git a/tests/mir-opt/building/match_false_edges.main.built.after.mir b/tests/mir-opt/building/match_false_edges.main.built.after.mir
new file mode 100644
index 000000000..e8b93f437
--- /dev/null
+++ b/tests/mir-opt/building/match_false_edges.main.built.after.mir
@@ -0,0 +1,174 @@
+// MIR for `main` after built
+
+fn main() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/match_false_edges.rs:+0:11: +0:11
+ let mut _1: i32; // in scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6
+ let mut _2: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ let mut _3: isize; // in scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16
+ let mut _4: isize; // in scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17
+ let mut _5: &std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ let _6: i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
+ let _7: &i32; // in scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
+ let mut _8: bool; // in scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
+ let _9: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
+ let _10: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ let _11: &i32; // in scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ let mut _12: bool; // in scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
+ let mut _13: i32; // in scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28
+ let _14: std::option::Option<i32>; // in scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11
+ scope 1 {
+ }
+ scope 2 {
+ debug _w => _6; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:16
+ debug _w => _7; // in scope 2 at $DIR/match_false_edges.rs:+2:14: +2:16
+ }
+ scope 3 {
+ debug _x => _9; // in scope 3 at $DIR/match_false_edges.rs:+3:9: +3:11
+ }
+ scope 4 {
+ debug y => _10; // in scope 4 at $DIR/match_false_edges.rs:+4:14: +4:15
+ debug y => _11; // in scope 4 at $DIR/match_false_edges.rs:+4:14: +4:15
+ }
+ scope 5 {
+ debug _z => _14; // in scope 5 at $DIR/match_false_edges.rs:+5:9: +5:11
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/match_false_edges.rs:+1:13: +6:6
+ StorageLive(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ _2 = Option::<i32>::Some(const 1_i32); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ FakeRead(ForMatchedPlace(None), _2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ _4 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ switchInt(move _4) -> [1: bb2, otherwise: bb1]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
+ }
+
+ bb1: {
+ falseEdge -> [real: bb13, imaginary: bb6]; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
+ }
+
+ bb2: {
+ falseEdge -> [real: bb8, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:9: +2:17
+ }
+
+ bb3: {
+ goto -> bb1; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
+ }
+
+ bb4: {
+ _3 = discriminant(_2); // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ switchInt(move _3) -> [1: bb6, otherwise: bb5]; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
+ }
+
+ bb5: {
+ StorageLive(_14); // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11
+ _14 = _2; // scope 0 at $DIR/match_false_edges.rs:+5:9: +5:11
+ _1 = const 4_i32; // scope 5 at $DIR/match_false_edges.rs:+5:15: +5:16
+ StorageDead(_14); // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16
+ goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+5:15: +5:16
+ }
+
+ bb6: {
+ falseEdge -> [real: bb14, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:9: +4:16
+ }
+
+ bb7: {
+ goto -> bb5; // scope 0 at $DIR/match_false_edges.rs:+1:13: +1:26
+ }
+
+ bb8: {
+ StorageLive(_7); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
+ _7 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
+ _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ StorageLive(_8); // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
+ _8 = guard() -> [return: bb9, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
+ // mir::Constant
+ // + span: $DIR/match_false_edges.rs:34:21: 34:26
+ // + literal: Const { ty: fn() -> bool {guard}, val: Value(<ZST>) }
+ }
+
+ bb9: {
+ switchInt(move _8) -> [0: bb11, otherwise: bb10]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
+ }
+
+ bb10: {
+ StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
+ FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
+ FakeRead(ForGuardBinding, _7); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
+ StorageLive(_6); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
+ _6 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+2:14: +2:16
+ _1 = const 1_i32; // scope 2 at $DIR/match_false_edges.rs:+2:32: +2:33
+ StorageDead(_6); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
+ StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
+ goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
+ }
+
+ bb11: {
+ goto -> bb12; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
+ }
+
+ bb12: {
+ StorageDead(_8); // scope 0 at $DIR/match_false_edges.rs:+2:27: +2:28
+ StorageDead(_7); // scope 0 at $DIR/match_false_edges.rs:+2:32: +2:33
+ falseEdge -> [real: bb3, imaginary: bb1]; // scope 0 at $DIR/match_false_edges.rs:+2:21: +2:28
+ }
+
+ bb13: {
+ StorageLive(_9); // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
+ _9 = _2; // scope 0 at $DIR/match_false_edges.rs:+3:9: +3:11
+ _1 = const 2_i32; // scope 3 at $DIR/match_false_edges.rs:+3:15: +3:16
+ StorageDead(_9); // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16
+ goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+3:15: +3:16
+ }
+
+ bb14: {
+ StorageLive(_11); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ _11 = &((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ _5 = &shallow _2; // scope 0 at $DIR/match_false_edges.rs:+1:19: +1:26
+ StorageLive(_12); // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
+ StorageLive(_13); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28
+ _13 = (*_11); // scope 0 at $DIR/match_false_edges.rs:+4:27: +4:28
+ _12 = guard2(move _13) -> [return: bb15, unwind: bb20]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
+ // mir::Constant
+ // + span: $DIR/match_false_edges.rs:36:20: 36:26
+ // + literal: Const { ty: fn(i32) -> bool {guard2}, val: Value(<ZST>) }
+ }
+
+ bb15: {
+ switchInt(move _12) -> [0: bb17, otherwise: bb16]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
+ }
+
+ bb16: {
+ StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
+ StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
+ FakeRead(ForMatchGuard, _5); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
+ FakeRead(ForGuardBinding, _11); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
+ StorageLive(_10); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ _10 = ((_2 as Some).0: i32); // scope 0 at $DIR/match_false_edges.rs:+4:14: +4:15
+ _1 = const 3_i32; // scope 4 at $DIR/match_false_edges.rs:+4:33: +4:34
+ StorageDead(_10); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
+ StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
+ goto -> bb19; // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
+ }
+
+ bb17: {
+ goto -> bb18; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
+ }
+
+ bb18: {
+ StorageDead(_13); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
+ StorageDead(_12); // scope 0 at $DIR/match_false_edges.rs:+4:28: +4:29
+ StorageDead(_11); // scope 0 at $DIR/match_false_edges.rs:+4:33: +4:34
+ falseEdge -> [real: bb7, imaginary: bb5]; // scope 0 at $DIR/match_false_edges.rs:+4:20: +4:29
+ }
+
+ bb19: {
+ StorageDead(_2); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
+ StorageDead(_1); // scope 0 at $DIR/match_false_edges.rs:+6:6: +6:7
+ _0 = const (); // scope 0 at $DIR/match_false_edges.rs:+0:11: +7:2
+ return; // scope 0 at $DIR/match_false_edges.rs:+7:2: +7:2
+ }
+
+ bb20 (cleanup): {
+ resume; // scope 0 at $DIR/match_false_edges.rs:+0:1: +7:2
+ }
+}
diff --git a/tests/mir-opt/building/match_false_edges.rs b/tests/mir-opt/building/match_false_edges.rs
new file mode 100644
index 000000000..ddfcc1493
--- /dev/null
+++ b/tests/mir-opt/building/match_false_edges.rs
@@ -0,0 +1,39 @@
+fn guard() -> bool {
+ false
+}
+
+fn guard2(_: i32) -> bool {
+ true
+}
+
+// no_mangle to make sure this gets instantiated even in an executable.
+#[no_mangle]
+// EMIT_MIR match_false_edges.full_tested_match.built.after.mir
+pub fn full_tested_match() {
+ let _ = match Some(42) {
+ Some(x) if guard() => (1, x),
+ Some(y) => (2, y),
+ None => (3, 3),
+ };
+}
+
+// no_mangle to make sure this gets instantiated even in an executable.
+#[no_mangle]
+// EMIT_MIR match_false_edges.full_tested_match2.built.after.mir
+pub fn full_tested_match2() {
+ let _ = match Some(42) {
+ Some(x) if guard() => (1, x),
+ None => (3, 3),
+ Some(y) => (2, y),
+ };
+}
+
+// EMIT_MIR match_false_edges.main.built.after.mir
+fn main() {
+ let _ = match Some(1) {
+ Some(_w) if guard() => 1,
+ _x => 2,
+ Some(y) if guard2(y) => 3,
+ _z => 4,
+ };
+}
diff --git a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir
new file mode 100644
index 000000000..41eb00363
--- /dev/null
+++ b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir
@@ -0,0 +1,96 @@
+// MIR for `main` after built
+
+| User Type Annotations
+| 0: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test
+| 1: user_ty: Canonical { max_universe: U0, variables: [], value: Ty(*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:14:14: 14:23, inferred_ty: *mut Test
+| 2: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test
+| 3: user_ty: Canonical { max_universe: U0, variables: [CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }, CanonicalVarInfo { kind: Region(U0) }], value: Ty(&&&&*mut Test) }, span: $DIR/receiver_ptr_mutability.rs:18:18: 18:31, inferred_ty: &&&&*mut Test
+|
+fn main() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +0:11
+ let _1: *mut Test as UserTypeProjection { base: UserType(0), projs: [] }; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+ let _2: (); // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+ let mut _3: *const Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+ let mut _4: *mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8
+ let _6: &&&&*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+ let _7: &&&*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41
+ let _8: &&*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41
+ let _9: &*mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41
+ let _10: (); // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ let mut _11: *const Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ let mut _12: *mut Test; // in scope 0 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ scope 1 {
+ debug ptr => _1; // in scope 1 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+ let _5: &&&&*mut Test as UserTypeProjection { base: UserType(2), projs: [] }; // in scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
+ scope 2 {
+ debug ptr_ref => _5; // in scope 2 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
+ }
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+ _1 = null_mut::<Test>() -> [return: bb1, unwind: bb4]; // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:26: +1:46
+ // mir::Constant
+ // + span: $DIR/receiver_ptr_mutability.rs:14:26: 14:44
+ // + literal: Const { ty: fn() -> *mut Test {null_mut::<Test>}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+ FakeRead(ForLet(None), _1); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:9: +1:12
+ AscribeUserType(_1, o, UserTypeProjection { base: UserType(1), projs: [] }); // scope 0 at $DIR/receiver_ptr_mutability.rs:+1:14: +1:23
+ StorageLive(_2); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+ StorageLive(_3); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+ StorageLive(_4); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8
+ _4 = _1; // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:8
+ _3 = move _4 as *const Test (Pointer(MutToConstPointer)); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+ StorageDead(_4); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:7: +2:8
+ _2 = Test::x(move _3) -> [return: bb2, unwind: bb4]; // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:5: +2:12
+ // mir::Constant
+ // + span: $DIR/receiver_ptr_mutability.rs:15:9: 15:10
+ // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value(<ZST>) }
+ }
+
+ bb2: {
+ StorageDead(_3); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:11: +2:12
+ StorageDead(_2); // scope 1 at $DIR/receiver_ptr_mutability.rs:+2:12: +2:13
+ StorageLive(_5); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
+ StorageLive(_6); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+ StorageLive(_7); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41
+ StorageLive(_8); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41
+ StorageLive(_9); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41
+ _9 = &_1; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:37: +5:41
+ _8 = &_9; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:36: +5:41
+ _7 = &_8; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:35: +5:41
+ _6 = &_7; // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+ _5 = &(*_6); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:34: +5:41
+ FakeRead(ForLet(None), _5); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:9: +5:16
+ AscribeUserType(_5, o, UserTypeProjection { base: UserType(3), projs: [] }); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:18: +5:31
+ StorageDead(_6); // scope 1 at $DIR/receiver_ptr_mutability.rs:+5:41: +5:42
+ StorageLive(_10); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ StorageLive(_11); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ StorageLive(_12); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ _12 = (*(*(*(*_5)))); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ _11 = move _12 as *const Test (Pointer(MutToConstPointer)); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ StorageDead(_12); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:11: +6:12
+ _10 = Test::x(move _11) -> [return: bb3, unwind: bb4]; // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:5: +6:16
+ // mir::Constant
+ // + span: $DIR/receiver_ptr_mutability.rs:19:13: 19:14
+ // + literal: Const { ty: fn(*const Test) {Test::x}, val: Value(<ZST>) }
+ }
+
+ bb3: {
+ StorageDead(_11); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:15: +6:16
+ StorageDead(_10); // scope 2 at $DIR/receiver_ptr_mutability.rs:+6:16: +6:17
+ _0 = const (); // scope 0 at $DIR/receiver_ptr_mutability.rs:+0:11: +7:2
+ StorageDead(_9); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+ StorageDead(_8); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+ StorageDead(_7); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+ StorageDead(_5); // scope 1 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+ StorageDead(_1); // scope 0 at $DIR/receiver_ptr_mutability.rs:+7:1: +7:2
+ return; // scope 0 at $DIR/receiver_ptr_mutability.rs:+7:2: +7:2
+ }
+
+ bb4 (cleanup): {
+ resume; // scope 0 at $DIR/receiver_ptr_mutability.rs:+0:1: +7:2
+ }
+}
diff --git a/tests/mir-opt/building/receiver_ptr_mutability.rs b/tests/mir-opt/building/receiver_ptr_mutability.rs
new file mode 100644
index 000000000..668530968
--- /dev/null
+++ b/tests/mir-opt/building/receiver_ptr_mutability.rs
@@ -0,0 +1,20 @@
+// EMIT_MIR receiver_ptr_mutability.main.built.after.mir
+
+#![feature(arbitrary_self_types)]
+
+struct Test {}
+
+impl Test {
+ fn x(self: *const Self) {
+ println!("x called");
+ }
+}
+
+fn main() {
+ let ptr: *mut Test = std::ptr::null_mut();
+ ptr.x();
+
+ // Test autoderefs
+ let ptr_ref: &&&&*mut Test = &&&&ptr;
+ ptr_ref.x();
+}
diff --git a/tests/mir-opt/building/simple_match.match_bool.built.after.mir b/tests/mir-opt/building/simple_match.match_bool.built.after.mir
new file mode 100644
index 000000000..aa2fd4632
--- /dev/null
+++ b/tests/mir-opt/building/simple_match.match_bool.built.after.mir
@@ -0,0 +1,29 @@
+// MIR for `match_bool` after built
+
+fn match_bool(_1: bool) -> usize {
+ debug x => _1; // in scope 0 at $DIR/simple_match.rs:+0:15: +0:16
+ let mut _0: usize; // return place in scope 0 at $DIR/simple_match.rs:+0:27: +0:32
+
+ bb0: {
+ FakeRead(ForMatchedPlace(None), _1); // scope 0 at $DIR/simple_match.rs:+1:11: +1:12
+ switchInt(_1) -> [0: bb2, otherwise: bb1]; // scope 0 at $DIR/simple_match.rs:+1:5: +1:12
+ }
+
+ bb1: {
+ falseEdge -> [real: bb3, imaginary: bb2]; // scope 0 at $DIR/simple_match.rs:+2:9: +2:13
+ }
+
+ bb2: {
+ _0 = const 20_usize; // scope 0 at $DIR/simple_match.rs:+3:14: +3:16
+ goto -> bb4; // scope 0 at $DIR/simple_match.rs:+3:14: +3:16
+ }
+
+ bb3: {
+ _0 = const 10_usize; // scope 0 at $DIR/simple_match.rs:+2:17: +2:19
+ goto -> bb4; // scope 0 at $DIR/simple_match.rs:+2:17: +2:19
+ }
+
+ bb4: {
+ return; // scope 0 at $DIR/simple_match.rs:+5:2: +5:2
+ }
+}
diff --git a/tests/mir-opt/building/simple_match.rs b/tests/mir-opt/building/simple_match.rs
new file mode 100644
index 000000000..0ef97dde6
--- /dev/null
+++ b/tests/mir-opt/building/simple_match.rs
@@ -0,0 +1,12 @@
+// Test that we don't generate unnecessarily large MIR for very simple matches
+
+
+// EMIT_MIR simple_match.match_bool.built.after.mir
+fn match_bool(x: bool) -> usize {
+ match x {
+ true => 10,
+ _ => 20,
+ }
+}
+
+fn main() {}
diff --git a/tests/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir b/tests/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir
new file mode 100644
index 000000000..1d3f77e07
--- /dev/null
+++ b/tests/mir-opt/building/storage_live_dead_in_statics.XXX.built.after.mir
@@ -0,0 +1,203 @@
+// MIR for `XXX` after built
+
+static XXX: &Foo = {
+ let mut _0: &Foo; // return place in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:13: +0:25
+ let _1: &Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2
+ let _2: Foo; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2
+ let mut _3: &[(u32, u32)]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ let mut _4: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ let _5: &[(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ let _6: [(u32, u32); 42]; // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6
+ let mut _7: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15
+ let mut _8: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23
+ let mut _9: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31
+ let mut _10: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15
+ let mut _11: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23
+ let mut _12: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31
+ let mut _13: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15
+ let mut _14: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23
+ let mut _15: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31
+ let mut _16: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15
+ let mut _17: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23
+ let mut _18: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31
+ let mut _19: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15
+ let mut _20: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23
+ let mut _21: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31
+ let mut _22: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15
+ let mut _23: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23
+ let mut _24: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31
+ let mut _25: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15
+ let mut _26: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23
+ let mut _27: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31
+ let mut _28: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15
+ let mut _29: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23
+ let mut _30: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31
+ let mut _31: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15
+ let mut _32: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23
+ let mut _33: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31
+ let mut _34: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15
+ let mut _35: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23
+ let mut _36: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31
+ let mut _37: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15
+ let mut _38: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23
+ let mut _39: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31
+ let mut _40: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15
+ let mut _41: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23
+ let mut _42: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31
+ let mut _43: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15
+ let mut _44: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23
+ let mut _45: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31
+ let mut _46: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15
+ let mut _47: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23
+ let mut _48: (u32, u32); // in scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2
+ StorageLive(_2); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2
+ StorageLive(_3); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ StorageLive(_4); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ StorageLive(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ StorageLive(_6); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6
+ StorageLive(_7); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15
+ _7 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:9: +3:15
+ StorageLive(_8); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23
+ _8 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:17: +3:23
+ StorageLive(_9); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31
+ _9 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+3:25: +3:31
+ StorageLive(_10); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15
+ _10 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:9: +4:15
+ StorageLive(_11); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23
+ _11 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:17: +4:23
+ StorageLive(_12); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31
+ _12 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+4:25: +4:31
+ StorageLive(_13); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15
+ _13 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:9: +5:15
+ StorageLive(_14); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23
+ _14 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:17: +5:23
+ StorageLive(_15); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31
+ _15 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+5:25: +5:31
+ StorageLive(_16); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15
+ _16 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:9: +6:15
+ StorageLive(_17); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23
+ _17 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:17: +6:23
+ StorageLive(_18); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31
+ _18 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+6:25: +6:31
+ StorageLive(_19); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15
+ _19 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:9: +7:15
+ StorageLive(_20); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23
+ _20 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:17: +7:23
+ StorageLive(_21); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31
+ _21 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+7:25: +7:31
+ StorageLive(_22); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15
+ _22 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:9: +8:15
+ StorageLive(_23); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23
+ _23 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:17: +8:23
+ StorageLive(_24); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31
+ _24 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+8:25: +8:31
+ StorageLive(_25); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15
+ _25 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:9: +9:15
+ StorageLive(_26); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23
+ _26 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:17: +9:23
+ StorageLive(_27); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31
+ _27 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+9:25: +9:31
+ StorageLive(_28); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15
+ _28 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:9: +10:15
+ StorageLive(_29); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23
+ _29 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:17: +10:23
+ StorageLive(_30); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31
+ _30 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+10:25: +10:31
+ StorageLive(_31); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15
+ _31 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:9: +11:15
+ StorageLive(_32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23
+ _32 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:17: +11:23
+ StorageLive(_33); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31
+ _33 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+11:25: +11:31
+ StorageLive(_34); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15
+ _34 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:9: +12:15
+ StorageLive(_35); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23
+ _35 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:17: +12:23
+ StorageLive(_36); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31
+ _36 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+12:25: +12:31
+ StorageLive(_37); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15
+ _37 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:9: +13:15
+ StorageLive(_38); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23
+ _38 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:17: +13:23
+ StorageLive(_39); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31
+ _39 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+13:25: +13:31
+ StorageLive(_40); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15
+ _40 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:9: +14:15
+ StorageLive(_41); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23
+ _41 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:17: +14:23
+ StorageLive(_42); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31
+ _42 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+14:25: +14:31
+ StorageLive(_43); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15
+ _43 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:9: +15:15
+ StorageLive(_44); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23
+ _44 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:17: +15:23
+ StorageLive(_45); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31
+ _45 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+15:25: +15:31
+ StorageLive(_46); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15
+ _46 = (const 0_u32, const 1_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:9: +16:15
+ StorageLive(_47); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23
+ _47 = (const 0_u32, const 2_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:17: +16:23
+ StorageLive(_48); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31
+ _48 = (const 0_u32, const 3_u32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+16:25: +16:31
+ _6 = [move _7, move _8, move _9, move _10, move _11, move _12, move _13, move _14, move _15, move _16, move _17, move _18, move _19, move _20, move _21, move _22, move _23, move _24, move _25, move _26, move _27, move _28, move _29, move _30, move _31, move _32, move _33, move _34, move _35, move _36, move _37, move _38, move _39, move _40, move _41, move _42, move _43, move _44, move _45, move _46, move _47, move _48]; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:12: +17:6
+ StorageDead(_48); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_47); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_46); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_45); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_44); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_43); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_42); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_41); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_40); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_39); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_38); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_37); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_36); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_35); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_34); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_33); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_32); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_31); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_30); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_29); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_28); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_27); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_26); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_25); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_24); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_23); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_22); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_21); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_20); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_19); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_18); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_17); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_16); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_15); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_14); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_13); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_12); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_11); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_10); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_9); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_8); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ StorageDead(_7); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ _5 = &_6; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ _4 = &(*_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ _3 = move _4 as &[(u32, u32)] (Pointer(Unsize)); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+2:11: +17:6
+ StorageDead(_4); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+17:5: +17:6
+ _2 = Foo { tup: const "hi", data: move _3 }; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:29: +18:2
+ // mir::Constant
+ // + span: $DIR/storage_live_dead_in_statics.rs:6:10: 6:14
+ // + literal: Const { ty: &str, val: Value(Slice(..)) }
+ StorageDead(_3); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2
+ _1 = &_2; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2
+ _0 = &(*_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:28: +18:2
+ StorageDead(_5); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2
+ StorageDead(_1); // scope 0 at $DIR/storage_live_dead_in_statics.rs:+18:1: +18:2
+ return; // scope 0 at $DIR/storage_live_dead_in_statics.rs:+0:1: +18:3
+ }
+}
diff --git a/tests/mir-opt/building/storage_live_dead_in_statics.rs b/tests/mir-opt/building/storage_live_dead_in_statics.rs
new file mode 100644
index 000000000..79f709148
--- /dev/null
+++ b/tests/mir-opt/building/storage_live_dead_in_statics.rs
@@ -0,0 +1,33 @@
+// Check that when we compile the static `XXX` into MIR, we do not
+// generate `StorageStart` or `StorageEnd` statements.
+
+// EMIT_MIR storage_live_dead_in_statics.XXX.built.after.mir
+static XXX: &'static Foo = &Foo {
+ tup: "hi",
+ data: &[
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ (0, 1), (0, 2), (0, 3),
+ ]
+};
+
+#[derive(Debug)]
+struct Foo {
+ tup: &'static str,
+ data: &'static [(u32, u32)]
+}
+
+fn main() {
+ println!("{:?}", XXX);
+}
diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir
new file mode 100644
index 000000000..234cd0839
--- /dev/null
+++ b/tests/mir-opt/building/uniform_array_move_out.move_out_by_subslice.built.after.mir
@@ -0,0 +1,111 @@
+// MIR for `move_out_by_subslice` after built
+
+fn move_out_by_subslice() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +0:27
+ let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ scope 1 {
+ debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ let _12: [std::boxed::Box<i32>; 2]; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
+ scope 4 {
+ debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
+ }
+ }
+ scope 2 {
+ }
+ scope 3 {
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ // mir::Constant
+ // + span: $DIR/uniform_array_move_out.rs:11:14: 11:19
+ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+ StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
+ _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
+ }
+
+ bb2: {
+ StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
+ StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ // mir::Constant
+ // + span: $DIR/uniform_array_move_out.rs:11:21: 11:26
+ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
+ }
+
+ bb3: {
+ StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
+ _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
+ }
+
+ bb4: {
+ StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
+ _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27
+ drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb5: {
+ StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb6: {
+ StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
+ _12 = move _1[0..2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:10: +2:12
+ _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:27: +3:2
+ drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ }
+
+ bb7: {
+ StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ }
+
+ bb8: {
+ StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2
+ }
+
+ bb9 (cleanup): {
+ drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ }
+
+ bb10 (cleanup): {
+ drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb11 (cleanup): {
+ drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb12 (cleanup): {
+ resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2
+ }
+}
diff --git a/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir
new file mode 100644
index 000000000..24a189498
--- /dev/null
+++ b/tests/mir-opt/building/uniform_array_move_out.move_out_from_end.built.after.mir
@@ -0,0 +1,111 @@
+// MIR for `move_out_from_end` after built
+
+fn move_out_from_end() -> () {
+ let mut _0: (); // return place in scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +0:24
+ let _1: [std::boxed::Box<i32>; 2]; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ let mut _2: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _3: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _4: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _5: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _6: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ let mut _7: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _8: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _9: usize; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _10: *mut u8; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ let mut _11: std::boxed::Box<i32>; // in scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ scope 1 {
+ debug a => _1; // in scope 1 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ let _12: std::boxed::Box<i32>; // in scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
+ scope 4 {
+ debug _y => _12; // in scope 4 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
+ }
+ }
+ scope 2 {
+ }
+ scope 3 {
+ }
+
+ bb0: {
+ StorageLive(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ StorageLive(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _3 = SizeOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _4 = AlignOf(i32); // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _5 = alloc::alloc::exchange_malloc(move _3, move _4) -> [return: bb1, unwind: bb12]; // scope 2 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ // mir::Constant
+ // + span: $DIR/uniform_array_move_out.rs:5:14: 5:19
+ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
+ }
+
+ bb1: {
+ StorageLive(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ _6 = ShallowInitBox(move _5, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ (*_6) = const 1_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
+ _2 = move _6; // scope 0 at $DIR/uniform_array_move_out.rs:+1:14: +1:19
+ drop(_6) -> [return: bb2, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
+ }
+
+ bb2: {
+ StorageDead(_6); // scope 0 at $DIR/uniform_array_move_out.rs:+1:18: +1:19
+ StorageLive(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _8 = SizeOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _9 = AlignOf(i32); // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _10 = alloc::alloc::exchange_malloc(move _8, move _9) -> [return: bb3, unwind: bb11]; // scope 3 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ // mir::Constant
+ // + span: $DIR/uniform_array_move_out.rs:5:21: 5:26
+ // + literal: Const { ty: unsafe fn(usize, usize) -> *mut u8 {alloc::alloc::exchange_malloc}, val: Value(<ZST>) }
+ }
+
+ bb3: {
+ StorageLive(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ _11 = ShallowInitBox(move _10, i32); // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ (*_11) = const 2_i32; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
+ _7 = move _11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:21: +1:26
+ drop(_11) -> [return: bb4, unwind: bb10]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
+ }
+
+ bb4: {
+ StorageDead(_11); // scope 0 at $DIR/uniform_array_move_out.rs:+1:25: +1:26
+ _1 = [move _2, move _7]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:13: +1:27
+ drop(_7) -> [return: bb5, unwind: bb11]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb5: {
+ StorageDead(_7); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ drop(_2) -> [return: bb6, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb6: {
+ StorageDead(_2); // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ FakeRead(ForLet(None), _1); // scope 0 at $DIR/uniform_array_move_out.rs:+1:9: +1:10
+ StorageLive(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
+ _12 = move _1[1 of 2]; // scope 1 at $DIR/uniform_array_move_out.rs:+2:14: +2:16
+ _0 = const (); // scope 0 at $DIR/uniform_array_move_out.rs:+0:24: +3:2
+ drop(_12) -> [return: bb7, unwind: bb9]; // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ }
+
+ bb7: {
+ StorageDead(_12); // scope 1 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ drop(_1) -> [return: bb8, unwind: bb12]; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ }
+
+ bb8: {
+ StorageDead(_1); // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ return; // scope 0 at $DIR/uniform_array_move_out.rs:+3:2: +3:2
+ }
+
+ bb9 (cleanup): {
+ drop(_1) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+3:1: +3:2
+ }
+
+ bb10 (cleanup): {
+ drop(_7) -> bb11; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb11 (cleanup): {
+ drop(_2) -> bb12; // scope 0 at $DIR/uniform_array_move_out.rs:+1:26: +1:27
+ }
+
+ bb12 (cleanup): {
+ resume; // scope 0 at $DIR/uniform_array_move_out.rs:+0:1: +3:2
+ }
+}
diff --git a/tests/mir-opt/building/uniform_array_move_out.rs b/tests/mir-opt/building/uniform_array_move_out.rs
new file mode 100644
index 000000000..e925036ec
--- /dev/null
+++ b/tests/mir-opt/building/uniform_array_move_out.rs
@@ -0,0 +1,18 @@
+#![feature(box_syntax)]
+
+// EMIT_MIR uniform_array_move_out.move_out_from_end.built.after.mir
+fn move_out_from_end() {
+ let a = [box 1, box 2];
+ let [.., _y] = a;
+}
+
+// EMIT_MIR uniform_array_move_out.move_out_by_subslice.built.after.mir
+fn move_out_by_subslice() {
+ let a = [box 1, box 2];
+ let [_y @ ..] = a;
+}
+
+fn main() {
+ move_out_by_subslice();
+ move_out_from_end();
+}