2017-11-19 22:37:59 +00:00
|
|
|
// compile-flags: -Z borrowck=mir
|
2017-10-13 13:36:15 +00:00
|
|
|
|
|
|
|
fn guard() -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
fn guard2(_:i32) -> bool {
|
|
|
|
true
|
|
|
|
}
|
|
|
|
|
2017-11-06 09:35:52 +00:00
|
|
|
// no_mangle to make sure this gets instantiated even in an executable.
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn full_tested_match() {
|
2017-10-13 13:36:15 +00:00
|
|
|
let _ = match Some(42) {
|
2017-11-02 17:25:38 +00:00
|
|
|
Some(x) if guard() => (1, x),
|
|
|
|
Some(y) => (2, y),
|
|
|
|
None => (3, 3),
|
2017-11-01 13:21:30 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2017-11-06 09:35:52 +00:00
|
|
|
// no_mangle to make sure this gets instantiated even in an executable.
|
|
|
|
#[no_mangle]
|
|
|
|
pub fn full_tested_match2() {
|
2017-11-01 13:21:30 +00:00
|
|
|
let _ = match Some(42) {
|
2017-11-02 17:25:38 +00:00
|
|
|
Some(x) if guard() => (1, x),
|
|
|
|
None => (3, 3),
|
|
|
|
Some(y) => (2, y),
|
2017-10-13 13:36:15 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let _ = match Some(1) {
|
|
|
|
Some(_w) if guard() => 1,
|
|
|
|
_x => 2,
|
|
|
|
Some(y) if guard2(y) => 3,
|
|
|
|
_z => 4,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
// END RUST SOURCE
|
|
|
|
//
|
2019-11-06 22:23:35 +00:00
|
|
|
// START rustc.full_tested_match.PromoteTemps.after.mir
|
2017-10-13 13:36:15 +00:00
|
|
|
// bb0: {
|
|
|
|
// ...
|
2018-12-12 13:12:48 +00:00
|
|
|
// _2 = std::option::Option::<i32>::Some(const 42i32,);
|
2018-09-15 10:18:45 +00:00
|
|
|
// FakeRead(ForMatchedPlace, _2);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _3 = discriminant(_2);
|
2019-05-09 22:01:39 +00:00
|
|
|
// switchInt(move _3) -> [0isize: bb4, 1isize: bb2, otherwise: bb5];
|
2017-10-13 13:36:15 +00:00
|
|
|
// }
|
2019-03-03 19:04:26 +00:00
|
|
|
// bb1 (cleanup): {
|
2017-11-27 23:45:16 +00:00
|
|
|
// resume;
|
|
|
|
// }
|
2019-02-02 10:56:55 +00:00
|
|
|
// bb2: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb6, imaginary: bb3]; //pre_binding1
|
2017-10-13 13:36:15 +00:00
|
|
|
// }
|
2019-02-02 10:56:55 +00:00
|
|
|
// bb3: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb10, imaginary: bb4]; //pre_binding2
|
2017-10-31 15:02:14 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb4: { //pre_binding3 and arm3
|
|
|
|
// _1 = (const 3i32, const 3i32);
|
|
|
|
// goto -> bb11;
|
2017-10-31 15:02:14 +00:00
|
|
|
// }
|
|
|
|
// bb5: {
|
2018-05-09 11:16:43 +00:00
|
|
|
// unreachable;
|
2017-10-31 15:02:14 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb6: { // binding1 and guard
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_6);
|
2019-11-22 20:26:09 +00:00
|
|
|
// _11 = const full_tested_match::promoted[0];
|
|
|
|
// _6 = &(((*_11) as Some).0: i32);
|
2019-03-31 14:14:50 +00:00
|
|
|
// _4 = &shallow _2;
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_7);
|
2019-05-09 22:01:39 +00:00
|
|
|
// _7 = const guard() -> [return: bb7, unwind: bb1];
|
2017-10-31 15:02:14 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb7: { // end of guard
|
|
|
|
// switchInt(move _7) -> [false: bb9, otherwise: bb8];
|
2017-10-31 15:02:14 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb8: { // arm1
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_7);
|
2019-06-15 18:55:21 +00:00
|
|
|
// FakeRead(ForMatchGuard, _4);
|
|
|
|
// FakeRead(ForGuardBinding, _6);
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_5);
|
|
|
|
// _5 = ((_2 as Some).0: i32);
|
|
|
|
// StorageLive(_8);
|
|
|
|
// _8 = _5;
|
|
|
|
// _1 = (const 1i32, move _8);
|
|
|
|
// StorageDead(_8);
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_5);
|
|
|
|
// StorageDead(_6);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb11;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb9: { // to pre_binding2
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_7);
|
|
|
|
// StorageDead(_6);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb3;
|
2019-04-03 18:21:51 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb10: { // arm2
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_9);
|
|
|
|
// _9 = ((_2 as Some).0: i32);
|
|
|
|
// StorageLive(_10);
|
|
|
|
// _10 = _9;
|
|
|
|
// _1 = (const 2i32, move _10);
|
|
|
|
// StorageDead(_10);
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_9);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb11;
|
2017-10-13 13:36:15 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb11: { // arm3
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_2);
|
2019-04-03 20:13:51 +00:00
|
|
|
// StorageDead(_1);
|
2019-04-03 18:21:51 +00:00
|
|
|
// _0 = ();
|
2019-02-10 16:49:26 +00:00
|
|
|
// return;
|
2017-10-13 13:36:15 +00:00
|
|
|
// }
|
2019-11-06 22:23:35 +00:00
|
|
|
// END rustc.full_tested_match.PromoteTemps.after.mir
|
2017-10-13 13:36:15 +00:00
|
|
|
//
|
2019-11-06 22:23:35 +00:00
|
|
|
// START rustc.full_tested_match2.PromoteTemps.before.mir
|
2017-11-01 13:21:30 +00:00
|
|
|
// bb0: {
|
|
|
|
// ...
|
2018-12-12 13:12:48 +00:00
|
|
|
// _2 = std::option::Option::<i32>::Some(const 42i32,);
|
2018-09-15 10:18:45 +00:00
|
|
|
// FakeRead(ForMatchedPlace, _2);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _3 = discriminant(_2);
|
2019-05-09 22:01:39 +00:00
|
|
|
// switchInt(move _3) -> [0isize: bb3, 1isize: bb2, otherwise: bb4];
|
2017-11-27 23:45:16 +00:00
|
|
|
// }
|
2019-03-03 19:04:26 +00:00
|
|
|
// bb1 (cleanup): {
|
2017-11-27 23:45:16 +00:00
|
|
|
// resume;
|
2017-11-01 13:21:30 +00:00
|
|
|
// }
|
2019-02-02 10:56:55 +00:00
|
|
|
// bb2: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb5, imaginary: bb3];
|
2017-11-01 13:21:30 +00:00
|
|
|
// }
|
2018-05-09 11:16:43 +00:00
|
|
|
// bb3: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb9, imaginary: bb10];
|
2018-05-09 11:16:43 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb4: { // to arm3 (can skip 2 since this is `Some`)
|
2018-05-09 11:16:43 +00:00
|
|
|
// unreachable;
|
2017-11-01 13:21:30 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb5: { // binding1 and guard
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_6);
|
|
|
|
// _6 = &((_2 as Some).0: i32);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _4 = &shallow _2;
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_7);
|
2019-05-09 22:01:39 +00:00
|
|
|
// _7 = const guard() -> [return: bb6, unwind: bb1];
|
2017-11-01 13:21:30 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb6: { // end of guard
|
|
|
|
// switchInt(move _7) -> [false: bb8, otherwise: bb7];
|
2017-11-01 13:21:30 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb7: {
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_7);
|
2019-06-15 18:55:21 +00:00
|
|
|
// FakeRead(ForMatchGuard, _4);
|
|
|
|
// FakeRead(ForGuardBinding, _6);
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_5);
|
|
|
|
// _5 = ((_2 as Some).0: i32);
|
|
|
|
// StorageLive(_8);
|
|
|
|
// _8 = _5;
|
|
|
|
// _1 = (const 1i32, move _8);
|
|
|
|
// StorageDead(_8);
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_5);
|
|
|
|
// StorageDead(_6);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb11;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb8: { // to pre_binding3 (can skip 2 since this is `Some`)
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_7);
|
|
|
|
// StorageDead(_6);
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb10, imaginary: bb3];
|
2019-04-03 18:21:51 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb9: { // arm2
|
2019-02-02 10:56:55 +00:00
|
|
|
// _1 = (const 3i32, const 3i32);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb11;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb10: { // binding3 and arm3
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_9);
|
|
|
|
// _9 = ((_2 as Some).0: i32);
|
|
|
|
// StorageLive(_10);
|
|
|
|
// _10 = _9;
|
|
|
|
// _1 = (const 2i32, move _10);
|
|
|
|
// StorageDead(_10);
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_9);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb11;
|
2019-02-10 16:49:26 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb11: {
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_2);
|
2019-04-03 20:13:51 +00:00
|
|
|
// StorageDead(_1);
|
2019-04-03 18:21:51 +00:00
|
|
|
// _0 = ();
|
2019-02-10 16:49:26 +00:00
|
|
|
// return;
|
2017-11-01 13:21:30 +00:00
|
|
|
// }
|
2019-11-06 22:23:35 +00:00
|
|
|
// END rustc.full_tested_match2.PromoteTemps.before.mir
|
2017-11-01 13:21:30 +00:00
|
|
|
//
|
2019-11-06 22:23:35 +00:00
|
|
|
// START rustc.main.PromoteTemps.before.mir
|
2019-04-03 18:21:51 +00:00
|
|
|
// bb0: {
|
2017-10-13 13:36:15 +00:00
|
|
|
// ...
|
2018-12-12 13:12:48 +00:00
|
|
|
// _2 = std::option::Option::<i32>::Some(const 1i32,);
|
2019-02-02 10:56:55 +00:00
|
|
|
// FakeRead(ForMatchedPlace, _2);
|
2019-05-09 22:01:39 +00:00
|
|
|
// _4 = discriminant(_2);
|
|
|
|
// switchInt(move _4) -> [1isize: bb2, otherwise: bb3];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-03-03 19:04:26 +00:00
|
|
|
// bb1 (cleanup): {
|
2019-02-02 10:56:55 +00:00
|
|
|
// resume;
|
|
|
|
// }
|
|
|
|
// bb2: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb5, imaginary: bb3];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
|
|
|
// bb3: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb9, imaginary: bb4];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
|
|
|
// bb4: {
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb10, imaginary: bb14];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
|
|
|
// bb5: {
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_7);
|
|
|
|
// _7 = &((_2 as Some).0: i32);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _5 = &shallow _2;
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_8);
|
2019-05-09 22:01:39 +00:00
|
|
|
// _8 = const guard() -> [return: bb6, unwind: bb1];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb6: { //end of guard1
|
|
|
|
// switchInt(move _8) -> [false: bb8, otherwise: bb7];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb7: {
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_8);
|
2019-06-15 18:55:21 +00:00
|
|
|
// FakeRead(ForMatchGuard, _5);
|
|
|
|
// FakeRead(ForGuardBinding, _7);
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_6);
|
|
|
|
// _6 = ((_2 as Some).0: i32);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _1 = const 1i32;
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_6);
|
|
|
|
// StorageDead(_7);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb15;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb8: {
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_8);
|
|
|
|
// StorageDead(_7);
|
|
|
|
// falseEdges -> [real: bb3, imaginary: bb3];
|
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb9: { // binding2 & arm2
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_9);
|
|
|
|
// _9 = _2;
|
2019-02-02 10:56:55 +00:00
|
|
|
// _1 = const 2i32;
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_9);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb15;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb10: { // binding3: Some(y) if guard2(y)
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_11);
|
|
|
|
// _11 = &((_2 as Some).0: i32);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _5 = &shallow _2;
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_12);
|
|
|
|
// StorageLive(_13);
|
|
|
|
// _13 = (*_11);
|
2019-05-09 22:01:39 +00:00
|
|
|
// _12 = const guard2(move _13) -> [return: bb11, unwind: bb1];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb11: { // end of guard2
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageDead(_13);
|
2019-05-09 22:01:39 +00:00
|
|
|
// switchInt(move _12) -> [false: bb13, otherwise: bb12];
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb12: { // binding4 & arm4
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_12);
|
2019-06-15 18:55:21 +00:00
|
|
|
// FakeRead(ForMatchGuard, _5);
|
|
|
|
// FakeRead(ForGuardBinding, _11);
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_10);
|
|
|
|
// _10 = ((_2 as Some).0: i32);
|
2019-02-02 10:56:55 +00:00
|
|
|
// _1 = const 3i32;
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_10);
|
|
|
|
// StorageDead(_11);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb15;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb13: {
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_12);
|
|
|
|
// StorageDead(_11);
|
2019-05-09 22:01:39 +00:00
|
|
|
// falseEdges -> [real: bb14, imaginary: bb14];
|
2019-04-03 18:21:51 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb14: {
|
2019-02-02 16:38:12 +00:00
|
|
|
// StorageLive(_14);
|
|
|
|
// _14 = _2;
|
2019-02-02 10:56:55 +00:00
|
|
|
// _1 = const 4i32;
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_14);
|
2019-05-09 22:01:39 +00:00
|
|
|
// goto -> bb15;
|
2019-02-10 16:49:26 +00:00
|
|
|
// }
|
2019-05-09 22:01:39 +00:00
|
|
|
// bb15: {
|
2019-04-03 18:21:51 +00:00
|
|
|
// StorageDead(_2);
|
2019-04-03 20:13:51 +00:00
|
|
|
// StorageDead(_1);
|
2019-04-03 18:21:51 +00:00
|
|
|
// _0 = ();
|
2019-02-10 16:49:26 +00:00
|
|
|
// return;
|
2019-02-02 10:56:55 +00:00
|
|
|
// }
|
2019-11-06 22:23:35 +00:00
|
|
|
// END rustc.main.PromoteTemps.before.mir
|