summaryrefslogtreecommitdiffstats
path: root/tests/mir-opt/building
diff options
context:
space:
mode:
Diffstat (limited to 'tests/mir-opt/building')
-rw-r--r--tests/mir-opt/building/async_await.b-{closure#0}.generator_resume.0.mir178
-rw-r--r--tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir12
-rw-r--r--tests/mir-opt/building/custom/projections.rs25
-rw-r--r--tests/mir-opt/building/custom/projections.tuples.built.after.mir8
-rw-r--r--tests/mir-opt/building/enum_cast.bar.built.after.mir9
-rw-r--r--tests/mir-opt/building/enum_cast.boo.built.after.mir9
-rw-r--r--tests/mir-opt/building/enum_cast.droppy.built.after.mir9
-rw-r--r--tests/mir-opt/building/enum_cast.far.built.after.mir22
-rw-r--r--tests/mir-opt/building/enum_cast.offsetty.built.after.mir26
-rw-r--r--tests/mir-opt/building/enum_cast.rs42
-rw-r--r--tests/mir-opt/building/enum_cast.signy.built.after.mir26
-rw-r--r--tests/mir-opt/building/enum_cast.unsigny.built.after.mir17
12 files changed, 268 insertions, 115 deletions
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
index 7cce3415f..a9d1477b9 100644
--- 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
@@ -4,7 +4,7 @@
_0: GeneratorSavedTy {
ty: impl std::future::Future<Output = ()>,
source_info: SourceInfo {
- span: $DIR/async_await.rs:15:8: 15:14 (#8),
+ span: $DIR/async_await.rs:15:9: 15:14 (#8),
scope: scope[0],
},
ignore_for_traits: false,
@@ -12,7 +12,7 @@
_1: GeneratorSavedTy {
ty: impl std::future::Future<Output = ()>,
source_info: SourceInfo {
- span: $DIR/async_await.rs:16:8: 16:14 (#11),
+ span: $DIR/async_await.rs:16:9: 16:14 (#10),
scope: scope[0],
},
ignore_for_traits: false,
@@ -35,42 +35,42 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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 _4: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +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 _6: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +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 _8: (); // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _9: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _10: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _11: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _12: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+1:9: +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 _15: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _16: isize; // in scope 0 at $DIR/async_await.rs:+1:9: +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 _19: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _20: (); // in scope 0 at $DIR/async_await.rs:+1:9: +1:14
+ let mut _21: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +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 _23: impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let _24: (); // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let mut _25: std::task::Poll<()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let mut _26: std::pin::Pin<&mut impl std::future::Future<Output = ()>>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let mut _27: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let mut _28: &mut impl std::future::Future<Output = ()>; // in scope 0 at $DIR/async_await.rs:+2:9: +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 _31: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let mut _32: isize; // in scope 0 at $DIR/async_await.rs:+2:9: +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 _35: &mut std::task::Context<'_>; // in scope 0 at $DIR/async_await.rs:+2:9: +2:14
+ let mut _36: (); // in scope 0 at $DIR/async_await.rs:+2:9: +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
+ 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:9: +1:14
let _17: (); // in scope 1 at $DIR/async_await.rs:+1:5: +1:14
scope 2 {
}
@@ -79,7 +79,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
}
}
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
+ 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:9: +2:14
let _33: (); // in scope 4 at $DIR/async_await.rs:+2:5: +2:14
scope 5 {
}
@@ -96,7 +96,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17: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(_4); // scope 0 at $DIR/async_await.rs:+1:9: +1:14
StorageLive(_5); // scope 0 at $DIR/async_await.rs:+1:5: +1:8
_5 = a() -> [return: bb2, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:5: +1:8
// mir::Constant
@@ -105,30 +105,30 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
}
bb2: {
- _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:8: +1:14
+ _4 = <impl Future<Output = ()> as IntoFuture>::into_future(move _5) -> [return: bb3, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+1:9: +1:14
// mir::Constant
- // + span: $DIR/async_await.rs:15:8: 15:14
+ // + span: $DIR/async_await.rs:15:9: 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
+ nop; // scope 0 at $DIR/async_await.rs:+1:9: +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:9: +1:14
+ goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:9: +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) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ StorageLive(_8); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ StorageLive(_9); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ StorageLive(_10); // scope 2 at $DIR/async_await.rs:+1:9: +1:14
+ StorageLive(_11); // scope 2 at $DIR/async_await.rs:+1:9: +1:14
+ StorageLive(_12); // scope 2 at $DIR/async_await.rs:+1:9: +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:9: +1:14
+ _11 = &mut (*_12); // scope 2 at $DIR/async_await.rs:+1:9: +1:14
+ _10 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _11) -> [return: bb5, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:9: +1:14
// mir::Constant
- // + span: $DIR/async_await.rs:15:8: 15:14
+ // + span: $DIR/async_await.rs:15:9: 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>) }
}
@@ -136,8 +136,8 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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
+ StorageLive(_15); // scope 2 at $DIR/async_await.rs:+1:9: +1:14
+ _15 = _38; // scope 2 at $DIR/async_await.rs:+1:9: +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
}
@@ -145,35 +145,35 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:8: +1:14
+ _9 = <impl Future<Output = ()> as Future>::poll(move _10, move _13) -> [return: bb7, unwind unreachable]; // scope 2 at $DIR/async_await.rs:+1:9: +1:14
// mir::Constant
- // + span: $DIR/async_await.rs:15:8: 15:14
+ // + span: $DIR/async_await.rs:15:9: 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
+ _16 = discriminant(_9); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ switchInt(move _16) -> [0: bb10, 1: bb8, otherwise: bb9]; // scope 1 at $DIR/async_await.rs:+1:9: +1:14
}
bb8: {
- _8 = const (); // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ _8 = const (); // scope 1 at $DIR/async_await.rs:+1:9: +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
- _0 = Poll::<()>::Pending; // 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
+ StorageLive(_19); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ StorageLive(_20); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ _20 = (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ _0 = Poll::<()>::Pending; // scope 1 at $DIR/async_await.rs:+1:9: +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:9: +1:14
+ return; // scope 1 at $DIR/async_await.rs:+1:9: +1:14
}
bb9: {
- unreachable; // scope 1 at $DIR/async_await.rs:+1:8: +1:14
+ unreachable; // scope 1 at $DIR/async_await.rs:+1:9: +1:14
}
bb10: {
@@ -190,10 +190,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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
+ _38 = move _19; // scope 1 at $DIR/async_await.rs:+1:9: +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
+ _7 = const (); // scope 1 at $DIR/async_await.rs:+1:9: +1:14
+ goto -> bb4; // scope 1 at $DIR/async_await.rs:+1:9: +1:14
}
bb12: {
@@ -204,7 +204,7 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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(_21); // scope 0 at $DIR/async_await.rs:+2:9: +2:14
StorageLive(_22); // scope 0 at $DIR/async_await.rs:+2:5: +2:8
_22 = a() -> [return: bb14, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:5: +2:8
// mir::Constant
@@ -213,30 +213,30 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
}
bb14: {
- _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:8: +2:14
+ _21 = <impl Future<Output = ()> as IntoFuture>::into_future(move _22) -> [return: bb15, unwind unreachable]; // scope 0 at $DIR/async_await.rs:+2:9: +2:14
// mir::Constant
- // + span: $DIR/async_await.rs:16:8: 16:14
+ // + span: $DIR/async_await.rs:16:9: 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
+ nop; // scope 0 at $DIR/async_await.rs:+2:9: +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:9: +2:14
+ goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:9: +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) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ StorageLive(_24); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ StorageLive(_25); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ StorageLive(_26); // scope 5 at $DIR/async_await.rs:+2:9: +2:14
+ StorageLive(_27); // scope 5 at $DIR/async_await.rs:+2:9: +2:14
+ StorageLive(_28); // scope 5 at $DIR/async_await.rs:+2:9: +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:9: +2:14
+ _27 = &mut (*_28); // scope 5 at $DIR/async_await.rs:+2:9: +2:14
+ _26 = Pin::<&mut impl Future<Output = ()>>::new_unchecked(move _27) -> [return: bb17, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:9: +2:14
// mir::Constant
- // + span: $DIR/async_await.rs:16:8: 16:14
+ // + span: $DIR/async_await.rs:16:9: 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>) }
}
@@ -244,8 +244,8 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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
+ StorageLive(_31); // scope 5 at $DIR/async_await.rs:+2:9: +2:14
+ _31 = _38; // scope 5 at $DIR/async_await.rs:+2:9: +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
}
@@ -253,31 +253,31 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
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) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:8: +2:14
+ _25 = <impl Future<Output = ()> as Future>::poll(move _26, move _29) -> [return: bb19, unwind unreachable]; // scope 5 at $DIR/async_await.rs:+2:9: +2:14
// mir::Constant
- // + span: $DIR/async_await.rs:16:8: 16:14
+ // + span: $DIR/async_await.rs:16:9: 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: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ _32 = discriminant(_25); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ switchInt(move _32) -> [0: bb21, 1: bb20, otherwise: bb9]; // scope 4 at $DIR/async_await.rs:+2:9: +2:14
}
bb20: {
- _24 = const (); // scope 4 at $DIR/async_await.rs:+2:8: +2:14
+ _24 = const (); // scope 4 at $DIR/async_await.rs:+2:9: +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
- _0 = Poll::<()>::Pending; // 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
+ StorageLive(_35); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ StorageLive(_36); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ _36 = (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ _0 = Poll::<()>::Pending; // scope 4 at $DIR/async_await.rs:+2:9: +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:9: +2:14
+ return; // scope 4 at $DIR/async_await.rs:+2:9: +2:14
}
bb21: {
@@ -294,10 +294,10 @@ fn b::{closure#0}(_1: Pin<&mut [async fn body@$DIR/async_await.rs:14:18: 17:2]>,
bb22: {
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
+ _38 = move _35; // scope 4 at $DIR/async_await.rs:+2:9: +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
+ _7 = const (); // scope 4 at $DIR/async_await.rs:+2:9: +2:14
+ goto -> bb16; // scope 4 at $DIR/async_await.rs:+2:9: +2:14
}
bb23: {
diff --git a/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir b/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir
new file mode 100644
index 000000000..5233d0489
--- /dev/null
+++ b/tests/mir-opt/building/custom/projections.copy_for_deref.built.after.mir
@@ -0,0 +1,12 @@
+// MIR for `copy_for_deref` after built
+
+fn copy_for_deref(_1: (&i32, i32)) -> i32 {
+ let mut _0: i32; // return place in scope 0 at $DIR/projections.rs:+0:38: +0:41
+ let mut _2: &i32; // in scope 0 at $SRC_DIR/core/src/intrinsics/mir.rs:LL:COL
+
+ bb0: {
+ _2 = deref_copy (_1.0: &i32); // scope 0 at $DIR/projections.rs:+4:13: +4:37
+ _0 = (*_2); // scope 0 at $DIR/projections.rs:+5:13: +5:24
+ return; // scope 0 at $DIR/projections.rs:+6:13: +6:21
+ }
+}
diff --git a/tests/mir-opt/building/custom/projections.rs b/tests/mir-opt/building/custom/projections.rs
index 5e472e531..3c155deae 100644
--- a/tests/mir-opt/building/custom/projections.rs
+++ b/tests/mir-opt/building/custom/projections.rs
@@ -21,13 +21,10 @@ fn unions(u: U) -> i32 {
#[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);
+ type RET = (u32, i32);
{
- temp.0 = i.0;
- temp.1 = i.1;
-
- RET = temp;
+ RET.0 = i.0;
+ RET.1 = i.1;
Return()
}
)
@@ -71,6 +68,19 @@ fn simple_index(a: [i32; 10], b: &[i32]) -> i32 {
})
}
+// EMIT_MIR projections.copy_for_deref.built.after.mir
+#[custom_mir(dialect = "runtime", phase = "initial")]
+fn copy_for_deref(x: (&i32, i32)) -> i32 {
+ mir!(
+ let temp: &i32;
+ {
+ temp = CopyForDeref(x.0);
+ RET = *temp;
+ Return()
+ }
+ )
+}
+
fn main() {
assert_eq!(unions(U { a: 5 }), 5);
assert_eq!(tuples((5, 6)), (5, 6));
@@ -82,4 +92,7 @@ fn main() {
assert_eq!(o, Some(10));
assert_eq!(simple_index([0; 10], &[0; 10]), 0);
+
+ let one = 1;
+ assert_eq!(copy_for_deref((&one, one)), 1);
}
diff --git a/tests/mir-opt/building/custom/projections.tuples.built.after.mir b/tests/mir-opt/building/custom/projections.tuples.built.after.mir
index 65487d3c9..dec575200 100644
--- a/tests/mir-opt/building/custom/projections.tuples.built.after.mir
+++ b/tests/mir-opt/building/custom/projections.tuples.built.after.mir
@@ -2,12 +2,10 @@
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
+ (_0.0: u32) = (_1.0: u32); // scope 0 at $DIR/projections.rs:+4:13: +4:24
+ (_0.1: i32) = (_1.1: i32); // scope 0 at $DIR/projections.rs:+5:13: +5:24
+ return; // scope 0 at $DIR/projections.rs:+6:13: +6:21
}
}
diff --git a/tests/mir-opt/building/enum_cast.bar.built.after.mir b/tests/mir-opt/building/enum_cast.bar.built.after.mir
index 0746e0b49..9f14c0284 100644
--- a/tests/mir-opt/building/enum_cast.bar.built.after.mir
+++ b/tests/mir-opt/building/enum_cast.bar.built.after.mir
@@ -5,17 +5,16 @@ fn bar(_1: Bar) -> usize {
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 _4: u8; // 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
+ _4 = _3 as u8 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _5 = Le(_4, const 1_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(move _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
index 699c876b0..715dedcf2 100644
--- a/tests/mir-opt/building/enum_cast.boo.built.after.mir
+++ b/tests/mir-opt/building/enum_cast.boo.built.after.mir
@@ -5,17 +5,16 @@ fn boo(_1: Boo) -> usize {
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 _4: u8; // 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
+ _4 = _3 as u8 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _5 = Le(_4, const 1_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(move _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
index 1112177fb..6c177c61e 100644
--- a/tests/mir-opt/building/enum_cast.droppy.built.after.mir
+++ b/tests/mir-opt/building/enum_cast.droppy.built.after.mir
@@ -6,7 +6,7 @@ fn droppy() -> () {
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 _6: u8; // 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 {
@@ -31,10 +31,9 @@ fn droppy() -> () {
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
+ _6 = _5 as u8 (IntToInt); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ _7 = Le(_6, const 2_u8); // scope 3 at $DIR/enum_cast.rs:+5:17: +5:27
+ assume(move _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
}
diff --git a/tests/mir-opt/building/enum_cast.far.built.after.mir b/tests/mir-opt/building/enum_cast.far.built.after.mir
new file mode 100644
index 000000000..ab8129ca0
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.far.built.after.mir
@@ -0,0 +1,22 @@
+// MIR for `far` after built
+
+fn far(_1: Far) -> isize {
+ debug far => _1; // in scope 0 at $DIR/enum_cast.rs:+0:8: +0:11
+ let mut _0: isize; // return place in scope 0 at $DIR/enum_cast.rs:+0:21: +0:26
+ let _2: Far; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _3: i16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:8
+ let mut _4: u16; // 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 = _3 as u16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _5 = Le(_4, const 1_u16); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ assume(move _5); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:17
+ _0 = move _3 as isize (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.offsetty.built.after.mir b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir
new file mode 100644
index 000000000..7b2b583f2
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.offsetty.built.after.mir
@@ -0,0 +1,26 @@
+// MIR for `offsetty` after built
+
+fn offsetty(_1: NotStartingAtZero) -> u32 {
+ debug x => _1; // in scope 0 at $DIR/enum_cast.rs:+0:13: +0:14
+ let mut _0: u32; // return place in scope 0 at $DIR/enum_cast.rs:+0:38: +0:41
+ let _2: NotStartingAtZero; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ let mut _3: isize; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ let mut _4: u8; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _4 = _3 as u8 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _5 = Ge(_4, const 4_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _6 = Le(_4, const 8_u8); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _7 = BitAnd(move _5, move _6); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ assume(move _7); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _0 = move _3 as u32 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:12: +1:13
+ 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
index 98fd5acfb..431b5c708 100644
--- a/tests/mir-opt/building/enum_cast.rs
+++ b/tests/mir-opt/building/enum_cast.rs
@@ -1,6 +1,7 @@
// EMIT_MIR enum_cast.foo.built.after.mir
// EMIT_MIR enum_cast.bar.built.after.mir
// EMIT_MIR enum_cast.boo.built.after.mir
+// EMIT_MIR enum_cast.far.built.after.mir
enum Foo {
A
@@ -15,6 +16,11 @@ enum Boo {
A, B
}
+#[repr(i16)]
+enum Far {
+ A, B
+}
+
fn foo(foo: Foo) -> usize {
foo as usize
}
@@ -27,6 +33,10 @@ fn boo(boo: Boo) -> usize {
boo as usize
}
+fn far(far: Far) -> isize {
+ far as isize
+}
+
// EMIT_MIR enum_cast.droppy.built.after.mir
enum Droppy {
A, B, C
@@ -46,5 +56,37 @@ fn droppy() {
let z = Droppy::B;
}
+#[repr(i16)]
+enum SignedAroundZero {
+ A = -2,
+ B = 0,
+ C = 2,
+}
+
+#[repr(u16)]
+enum UnsignedAroundZero {
+ A = 65535,
+ B = 0,
+ C = 1,
+}
+
+// EMIT_MIR enum_cast.signy.built.after.mir
+fn signy(x: SignedAroundZero) -> i16 {
+ x as i16
+}
+
+// EMIT_MIR enum_cast.unsigny.built.after.mir
+fn unsigny(x: UnsignedAroundZero) -> u16 {
+ // FIXME: This doesn't get an around-the-end range today, sadly.
+ x as u16
+}
+
+enum NotStartingAtZero { A = 4, B = 6, C = 8 }
+
+// EMIT_MIR enum_cast.offsetty.built.after.mir
+fn offsetty(x: NotStartingAtZero) -> u32 {
+ x as u32
+}
+
fn main() {
}
diff --git a/tests/mir-opt/building/enum_cast.signy.built.after.mir b/tests/mir-opt/building/enum_cast.signy.built.after.mir
new file mode 100644
index 000000000..ef4fea604
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.signy.built.after.mir
@@ -0,0 +1,26 @@
+// MIR for `signy` after built
+
+fn signy(_1: SignedAroundZero) -> i16 {
+ debug x => _1; // in scope 0 at $DIR/enum_cast.rs:+0:10: +0:11
+ let mut _0: i16; // return place in scope 0 at $DIR/enum_cast.rs:+0:34: +0:37
+ let _2: SignedAroundZero; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ let mut _3: i16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ let mut _4: u16; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ let mut _5: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ let mut _6: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ let mut _7: bool; // in scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+1:5: +1:6
+ _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _4 = _3 as u16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _5 = Ge(_4, const 65534_u16); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _6 = Le(_4, const 2_u16); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _7 = BitOr(move _5, move _6); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ assume(move _7); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ _0 = move _3 as i16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+1:5: +1:13
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+1:12: +1:13
+ return; // scope 0 at $DIR/enum_cast.rs:+2:2: +2:2
+ }
+}
diff --git a/tests/mir-opt/building/enum_cast.unsigny.built.after.mir b/tests/mir-opt/building/enum_cast.unsigny.built.after.mir
new file mode 100644
index 000000000..7ca147b15
--- /dev/null
+++ b/tests/mir-opt/building/enum_cast.unsigny.built.after.mir
@@ -0,0 +1,17 @@
+// MIR for `unsigny` after built
+
+fn unsigny(_1: UnsignedAroundZero) -> u16 {
+ debug x => _1; // in scope 0 at $DIR/enum_cast.rs:+0:12: +0:13
+ let mut _0: u16; // return place in scope 0 at $DIR/enum_cast.rs:+0:38: +0:41
+ let _2: UnsignedAroundZero; // in scope 0 at $DIR/enum_cast.rs:+2:5: +2:6
+ let mut _3: u16; // in scope 0 at $DIR/enum_cast.rs:+2:5: +2:6
+
+ bb0: {
+ StorageLive(_2); // scope 0 at $DIR/enum_cast.rs:+2:5: +2:6
+ _2 = move _1; // scope 0 at $DIR/enum_cast.rs:+2:5: +2:6
+ _3 = discriminant(_2); // scope 0 at $DIR/enum_cast.rs:+2:5: +2:13
+ _0 = move _3 as u16 (IntToInt); // scope 0 at $DIR/enum_cast.rs:+2:5: +2:13
+ StorageDead(_2); // scope 0 at $DIR/enum_cast.rs:+2:12: +2:13
+ return; // scope 0 at $DIR/enum_cast.rs:+3:2: +3:2
+ }
+}