diff options
| author | Matthew Jasper <mjjasper1@gmail.com> | 2019-05-09 23:01:39 +0100 |
|---|---|---|
| committer | Matthew Jasper <mjjasper1@gmail.com> | 2019-06-13 21:05:21 +0100 |
| commit | da22793a35b725e2fe2f7e2ac1d808404c39c4aa (patch) | |
| tree | c48a0a97a0308968e92ebfcc68b5e314c8d3e758 /src/test | |
| parent | 32c337724dd3a1b651cb7ba9769e60262f9f52f8 (diff) | |
| download | rust-da22793a35b725e2fe2f7e2ac1d808404c39c4aa.tar.gz rust-da22793a35b725e2fe2f7e2ac1d808404c39c4aa.zip | |
Create fewer basic blocks in match MIR lowering
Diffstat (limited to 'src/test')
25 files changed, 287 insertions, 326 deletions
diff --git a/src/test/codegen/match.rs b/src/test/codegen/match.rs index 1b46bb3b25f..145d4ba6b4c 100644 --- a/src/test/codegen/match.rs +++ b/src/test/codegen/match.rs @@ -14,12 +14,12 @@ pub fn exhaustive_match(e: E, unit: ()) { // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[A:[a-zA-Z0-9_]+]] // CHECK-NEXT: i[[TY:[0-9]+]] [[DISCR:[0-9]+]], label %[[B:[a-zA-Z0-9_]+]] // CHECK-NEXT: ] +// CHECK: [[B]]: +// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] // CHECK: [[OTHERWISE]]: // CHECK-NEXT: unreachable // CHECK: [[A]]: // CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] -// CHECK: [[B]]: -// CHECK-NEXT: br label %[[EXIT:[a-zA-Z0-9_]+]] match e { E::A => unit, E::B => unit, diff --git a/src/test/compile-fail/const-fn-error.rs b/src/test/compile-fail/const-fn-error.rs index da6036a04a5..87a9cf9490d 100644 --- a/src/test/compile-fail/const-fn-error.rs +++ b/src/test/compile-fail/const-fn-error.rs @@ -7,6 +7,7 @@ const fn f(x: usize) -> usize { for i in 0..x { //~^ ERROR E0015 //~| ERROR E0019 + //~| ERROR E0019 //~| ERROR E0080 sum += i; } diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/compile-fail/issue-52443.rs index e1f07ff96be..0d6906086e9 100644 --- a/src/test/compile-fail/issue-52443.rs +++ b/src/test/compile-fail/issue-52443.rs @@ -4,5 +4,6 @@ fn main() { [(); {while true {break}; 0}]; //~ ERROR constant contains unimplemented expression type [(); { for _ in 0usize.. {}; 0}]; //~ ERROR calls in constants are limited to constant functions //~^ ERROR constant contains unimplemented expression type + //~| ERROR constant contains unimplemented expression type //~| ERROR evaluation of constant value failed } diff --git a/src/test/mir-opt/const_prop/switch_int.rs b/src/test/mir-opt/const_prop/switch_int.rs index 0df1112ec3e..904d303d87e 100644 --- a/src/test/mir-opt/const_prop/switch_int.rs +++ b/src/test/mir-opt/const_prop/switch_int.rs @@ -13,26 +13,26 @@ fn main() { // bb0: { // ... // _1 = const 1i32; -// switchInt(_1) -> [1i32: bb1, otherwise: bb2]; +// switchInt(_1) -> [1i32: bb2, otherwise: bb1]; // } // END rustc.main.ConstProp.before.mir // START rustc.main.ConstProp.after.mir // bb0: { // ... -// switchInt(const 1i32) -> [1i32: bb1, otherwise: bb2]; +// switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // } // END rustc.main.ConstProp.after.mir // START rustc.main.SimplifyBranches-after-const-prop.before.mir // bb0: { // ... // _1 = const 1i32; -// switchInt(const 1i32) -> [1i32: bb1, otherwise: bb2]; +// switchInt(const 1i32) -> [1i32: bb2, otherwise: bb1]; // } // END rustc.main.SimplifyBranches-after-const-prop.before.mir // START rustc.main.SimplifyBranches-after-const-prop.after.mir // bb0: { // ... // _1 = const 1i32; -// goto -> bb1; +// goto -> bb2; // } // END rustc.main.SimplifyBranches-after-const-prop.after.mir diff --git a/src/test/mir-opt/deaggregator_test_enum_2.rs b/src/test/mir-opt/deaggregator_test_enum_2.rs index 59c75739d81..b39ad1bef8e 100644 --- a/src/test/mir-opt/deaggregator_test_enum_2.rs +++ b/src/test/mir-opt/deaggregator_test_enum_2.rs @@ -21,30 +21,22 @@ fn main() { // END RUST SOURCE // START rustc.test1.Deaggregator.before.mir // bb1: { -// StorageLive(_4); -// _4 = _2; -// _0 = Foo::A(move _4,); -// StorageDead(_4); -// goto -> bb3; -// } -// bb2: { // StorageLive(_5); // _5 = _2; // _0 = Foo::B(move _5,); // StorageDead(_5); // goto -> bb3; // } -// END rustc.test1.Deaggregator.before.mir -// START rustc.test1.Deaggregator.after.mir -// bb1: { +// bb2: { // StorageLive(_4); // _4 = _2; -// ((_0 as A).0: i32) = move _4; -// discriminant(_0) = 0; +// _0 = Foo::A(move _4,); // StorageDead(_4); // goto -> bb3; // } -// bb2: { +// END rustc.test1.Deaggregator.before.mir +// START rustc.test1.Deaggregator.after.mir +// bb1: { // StorageLive(_5); // _5 = _2; // ((_0 as B).0: i32) = move _5; @@ -52,5 +44,13 @@ fn main() { // StorageDead(_5); // goto -> bb3; // } +// bb2: { +// StorageLive(_4); +// _4 = _2; +// ((_0 as A).0: i32) = move _4; +// discriminant(_0) = 0; +// StorageDead(_4); +// goto -> bb3; +// } // END rustc.test1.Deaggregator.after.mir // diff --git a/src/test/mir-opt/issue-38669.rs b/src/test/mir-opt/issue-38669.rs index e8ab690bb46..909f9b7b6b7 100644 --- a/src/test/mir-opt/issue-38669.rs +++ b/src/test/mir-opt/issue-38669.rs @@ -31,17 +31,17 @@ fn main() { // switchInt(_4) -> [false: bb5, otherwise: bb4]; // } // ... -// bb7: { -// _0 = (); -// StorageDead(_4); -// StorageDead(_1); -// return; -// } -// bb8: { +// bb5: { // _3 = (); // StorageDead(_4); // _1 = const true; // _2 = (); // goto -> bb2; // } +// bb6: { +// _0 = (); +// StorageDead(_4); +// StorageDead(_1); +// return; +// } // END rustc.main.SimplifyCfg-initial.after.mir diff --git a/src/test/mir-opt/issue-49232.rs b/src/test/mir-opt/issue-49232.rs index 447f3a07a6a..9dde6d821f2 100644 --- a/src/test/mir-opt/issue-49232.rs +++ b/src/test/mir-opt/issue-49232.rs @@ -32,76 +32,58 @@ fn main() { // falseUnwind -> [real: bb3, cleanup: bb4]; // } // bb2: { -// goto -> bb20; +// goto -> bb14; // } // bb3: { // StorageLive(_2); // StorageLive(_3); // _3 = const true; // FakeRead(ForMatchedPlace, _3); -// switchInt(_3) -> [false: bb9, otherwise: bb8]; +// switchInt(_3) -> [false: bb5, otherwise: bb6]; // } // bb4 (cleanup): { // resume; // } // bb5: { -// falseEdges -> [real: bb11, imaginary: bb6]; +// falseEdges -> [real: bb7, imaginary: bb6]; // } // bb6: { -// falseEdges -> [real: bb13, imaginary: bb7]; +// _0 = (); +// goto -> bb8; // } // bb7: { -// unreachable; -// } -// bb8: { -// goto -> bb6; -// } -// bb9: { -// goto -> bb5; -// } -// bb10: { // _2 = const 4i32; -// goto -> bb18; -// } -// bb11: { -// goto -> bb10; -// } -// bb12: { -// _0 = (); -// goto -> bb14; -// } -// bb13: { // goto -> bb12; // } -// bb14: { +// bb8: { // StorageDead(_3); -// goto -> bb15; +// goto -> bb9; // } -// bb15: { +// bb9: { // StorageDead(_2); // goto -> bb2; // } -// bb16: { +// bb10: { // _4 = (); // unreachable; // } -// bb17: { -// goto -> bb18; +// bb11: { +// goto -> bb12; // } -// bb18: { +// bb12: { // FakeRead(ForLet, _2); // StorageDead(_3); // StorageLive(_6); // _6 = &_2; -// _5 = const std::mem::drop::<&i32>(move _6) -> [return: bb19, unwind: bb4]; +// _5 = const std::mem::drop::<&i32>(move _6) -> [return: bb13, unwind: bb4]; // } -// bb19: { +// bb13: { // StorageDead(_6); // _1 = (); // StorageDead(_2); // goto -> bb1; // } -// bb20: { +// bb14: { // return; // } // } diff --git a/src/test/mir-opt/loop_test.rs b/src/test/mir-opt/loop_test.rs index e75955b9b24..68ea60d9278 100644 --- a/src/test/mir-opt/loop_test.rs +++ b/src/test/mir-opt/loop_test.rs @@ -22,20 +22,21 @@ fn main() { // resume; // } // ... -// bb6: { // Entry into the loop +// bb3: { // Entry into the loop // _1 = (); // StorageDead(_2); -// goto -> bb7; +// goto -> bb5; // } -// bb7: { // The loop_block -// falseUnwind -> [real: bb8, cleanup: bb1]; +// ... +// bb5: { // The loop_block +// falseUnwind -> [real: bb6, cleanup: bb1]; // } -// bb8: { // The loop body (body_block) +// bb6: { // The loop body (body_block) // StorageLive(_6); // _6 = const 1i32; // FakeRead(ForLet, _6); // StorageDead(_6); -// goto -> bb7; +// goto -> bb5; // } // ... // END rustc.main.SimplifyCfg-qualify-consts.after.mir diff --git a/src/test/mir-opt/match-arm-scopes.rs b/src/test/mir-opt/match-arm-scopes.rs index 0f026b8a08d..a2bc238c68a 100644 --- a/src/test/mir-opt/match-arm-scopes.rs +++ b/src/test/mir-opt/match-arm-scopes.rs @@ -42,55 +42,49 @@ fn main() { // let mut _0: i32; // let mut _3: &bool; // Temp for fake borrow of `items.0` // let mut _4: &bool; // Temp for fake borrow of `items.1` -// let _5: bool; // `a` in arm -// let _6: &bool; // `a` in guard -// let _7: std::string::String; // `s` in arm -// let _8: &std::string::String; // `s` in guard +// let _5: bool; // `a` in arm +// let _6: &bool; // `a` in guard +// let _7: std::string::String; // `s` in arm +// let _8: &std::string::String; // `s` in guard // let mut _9: bool; // `if cond { return 3 } else { a }` // let mut _10: bool; // `cond` // let mut _11: !; // `return 3` // let mut _12: bool; // `if cond { return 3 } else { a }` // let mut _13: bool; // `cond` // let mut _14: !; // `return 3` -// let _15: bool; // `b` -// let _16: std::string::String; // `t` +// let _15: bool; // `b` +// let _16: std::string::String; // `t` // scope 1 { // } // scope 2 { // } // bb0: { // FakeRead(ForMatchedPlace, _2); -// switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb7]; +// switchInt((_2.0: bool)) -> [false: bb2, otherwise: bb5]; // } // bb1 (cleanup): { // resume; // } // bb2: { -// falseEdges -> [real: bb10, imaginary: bb3]; +// falseEdges -> [real: bb8, imaginary: bb3]; // } // bb3: { -// falseEdges -> [real: bb21, imaginary: bb4]; +// falseEdges -> [real: bb17, imaginary: bb4]; // } // bb4: { -// falseEdges -> [real: bb31, imaginary: bb5]; +// falseEdges -> [real: bb25, imaginary: bb26]; // } // bb5: { -// falseEdges -> [real: bb32, imaginary: bb6]; +// switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb6]; // } // bb6: { -// unreachable; +// switchInt((_2.0: bool)) -> [false: bb26, otherwise: bb4]; // } -// bb7: { -// switchInt((_2.1: bool)) -> [false: bb3, otherwise: bb8]; -// } -// bb8: { -// switchInt((_2.0: bool)) -> [false: bb5, otherwise: bb4]; -// } -// bb9: { // arm 1 +// bb7: { // arm 1 // _0 = const 1i32; -// drop(_7) -> [return: bb29, unwind: bb16]; +// drop(_7) -> [return: bb23, unwind: bb13]; // } -// bb10: { // guard - first time +// bb8: { // guard - first time // StorageLive(_6); // _6 = &(_2.1: bool); // StorageLive(_8); @@ -101,58 +95,52 @@ fn main() { // StorageLive(_10); // _10 = _1; // FakeRead(ForMatchedPlace, _10); -// switchInt(_10) -> [false: bb12, otherwise: bb11]; +// switchInt(_10) -> [false: bb10, otherwise: bb9]; // } -// bb11: { -// falseEdges -> [real: bb14, imaginary: bb12]; +// bb9: { +// falseEdges -> [real: bb11, imaginary: bb10]; // } -// bb12: { -// falseEdges -> [real: bb18, imaginary: bb13]; -// } -// bb13: { -// unreachable; +// bb10: { // `else` block - first time +// _9 = (*_6); +// StorageDead(_10); +// FakeRead(ForMatchGuard, _3); +// FakeRead(ForMatchGuard, _4); +// FakeRead(ForGuardBinding, _6); +// FakeRead(ForGuardBinding, _8); +// switchInt(move _9) -> [false: bb16, otherwise: bb15]; // } -// bb14: { // `return 3` - first time +// bb11: { // `return 3` - first time // _0 = const 3i32; // StorageDead(_10); // StorageDead(_9); // StorageDead(_8); // StorageDead(_6); -// goto -> bb17; +// goto -> bb14; // } -// bb15: { +// bb12: { // return; // } -// bb16 (cleanup): { +// bb13 (cleanup): { // drop(_2) -> bb1; // } -// bb17: { -// drop(_2) -> [return: bb15, unwind: bb1]; -// } -// bb18: { // `else` block - first time -// _9 = (*_6); -// StorageDead(_10); -// FakeRead(ForMatchGuard, _3); -// FakeRead(ForMatchGuard, _4); -// FakeRead(ForGuardBinding, _6); -// FakeRead(ForGuardBinding, _8); -// switchInt(move _9) -> [false: bb20, otherwise: bb19]; +// bb14: { +// drop(_2) -> [return: bb12, unwind: bb1]; // } -// bb19: { +// bb15: { // StorageDead(_9); // StorageLive(_5); // _5 = (_2.1: bool); // StorageLive(_7); // _7 = move (_2.2: std::string::String); -// goto -> bb9; +// goto -> bb7; // } -// bb20: { // guard otherwise case - first time +// bb16: { // guard otherwise case - first time // StorageDead(_9); // StorageDead(_8); // StorageDead(_6); -// falseEdges -> [real: bb7, imaginary: bb3]; +// falseEdges -> [real: bb5, imaginary: bb3]; // } -// bb21: { // guard - second time +// bb17: { // guard - second time // StorageLive(_6); // _6 = &(_2.0: bool); // StorageLive(_8); @@ -163,80 +151,74 @@ fn main() { // StorageLive(_13); // _13 = _1; // FakeRead(ForMatchedPlace, _13); -// switchInt(_13) -> [false: bb23, otherwise: bb22]; -// } -// bb22: { -// falseEdges -> [real: bb25, imaginary: bb23]; -// } -// bb23: { -// falseEdges -> [real: bb26, imaginary: bb24]; +// switchInt(_13) -> [false: bb19, otherwise: bb18]; // } -// bb24: { -// unreachable; +// bb18: { +// falseEdges -> [real: bb20, imaginary: bb19]; // } -// bb25: { // `return 3` - second time -// _0 = const 3i32; -// StorageDead(_13); -// StorageDead(_12); -// StorageDead(_8); -// StorageDead(_6); -// goto -> bb17; -// } -// bb26: { // `else` block - second time +// bb19: { // `else` block - second time // _12 = (*_6); // StorageDead(_13); // FakeRead(ForMatchGuard, _3); // FakeRead(ForMatchGuard, _4); // FakeRead(ForGuardBinding, _6); // FakeRead(ForGuardBinding, _8); -// switchInt(move _12) -> [false: bb28, otherwise: bb27]; +// switchInt(move _12) -> [false: bb22, otherwise: bb21]; +// } +// bb20: { +// _0 = const 3i32; +// StorageDead(_13); +// StorageDead(_12); +// StorageDead(_8); +// StorageDead(_6); +// goto -> bb14; // } -// bb27: { // Guard otherwise case - second time +// bb21: { // bindings for arm 1 // StorageDead(_12); // StorageLive(_5); // _5 = (_2.0: bool); // StorageLive(_7); // _7 = move (_2.2: std::string::String); -// goto -> bb9; +// goto -> bb7; // } -// bb28: { // rest of arm 1 +// bb22: { // Guard otherwise case - second time // StorageDead(_12); // StorageDead(_8); // StorageDead(_6); -// falseEdges -> [real: bb8, imaginary: bb4]; +// falseEdges -> [real: bb6, imaginary: bb4]; // } -// bb29: { +// bb23: { // rest of arm 1 // StorageDead(_7); // StorageDead(_5); // StorageDead(_8); // StorageDead(_6); -// goto -> bb34; +// goto -> bb28; // } -// bb30: { // arm 2 +// bb24: { // arm 2 // _0 = const 2i32; -// drop(_16) -> [return: bb33, unwind: bb16]; +// drop(_16) -> [return: bb27, unwind: bb13]; // } -// bb31: { // bindings for arm 2 - first pattern +// bb25: { // bindings for arm 2 - first pattern // StorageLive(_15); // _15 = (_2.1: bool); // StorageLive(_16); // _16 = move (_2.2: std::string::String); -// goto -> bb30; +// goto -> bb24; // } -// bb32: { // bindings for arm 2 - first pattern +// bb26: { // bindings for arm 2 - second pattern // StorageLive(_15); // _15 = (_2.1: bool); // StorageLive(_16); // _16 = move (_2.2: std::string::String); -// goto -> bb30; +// goto -> bb24; // } -// bb33: { // rest of arm 2 +// bb27: { // rest of arm 2 // StorageDead(_16); // StorageDead(_15); -// goto -> bb34; +// goto -> bb28; // } -// bb34: { // end of match -// drop(_2) -> [return: bb15, unwind: bb1]; +// bb28: { +// drop(_2) -> [return: bb12, unwind: bb1]; // } // END rustc.complicated_match.SimplifyCfg-initial.after.mir // START rustc.complicated_match.ElaborateDrops.after.mir diff --git a/src/test/mir-opt/match_false_edges.rs b/src/test/mir-opt/match_false_edges.rs index 6979924c8cd..a62e1b21dd1 100644 --- a/src/test/mir-opt/match_false_edges.rs +++ b/src/test/mir-opt/match_false_edges.rs @@ -45,39 +45,37 @@ fn main() { // _2 = std::option::Option::<i32>::Some(const 42i32,); // FakeRead(ForMatchedPlace, _2); // _3 = discriminant(_2); -// switchInt(move _3) -> [0isize: bb4, 1isize: bb2, otherwise: bb6]; +// switchInt(move _3) -> [0isize: bb4, 1isize: bb2, otherwise: bb5]; // } // bb1 (cleanup): { // resume; // } // bb2: { -// falseEdges -> [real: bb7, imaginary: bb3]; //pre_binding1 +// falseEdges -> [real: bb6, imaginary: bb3]; //pre_binding1 // } // bb3: { -// falseEdges -> [real: bb11, imaginary: bb4]; //pre_binding2 +// falseEdges -> [real: bb10, imaginary: bb4]; //pre_binding2 // } -// bb4: { -// falseEdges -> [real: bb12, imaginary: bb5]; //pre_binding3 +// bb4: { //pre_binding3 and arm3 +// _1 = (const 3i32, const 3i32); +// goto -> bb11; // } // bb5: { // unreachable; // } -// bb6: { -// unreachable; -// } -// bb7: { // binding1 and guard +// bb6: { // binding1 and guard // StorageLive(_6); // _6 = &(((promoted[0]: std::option::Option<i32>) as Some).0: i32); // _4 = &shallow _2; // StorageLive(_7); -// _7 = const guard() -> [return: bb8, unwind: bb1]; +// _7 = const guard() -> [return: bb7, unwind: bb1]; // } -// bb8: { // end of guard +// bb7: { // end of guard // FakeRead(ForMatchGuard, _4); // FakeRead(ForGuardBinding, _6); -// switchInt(move _7) -> [false: bb10, otherwise: bb9]; +// switchInt(move _7) -> [false: bb9, otherwise: bb8]; // } -// bb9: { // arm1 +// bb8: { // arm1 // StorageDead(_7); // StorageLive(_5); // _5 = ((_2 as Some).0: i32); @@ -87,14 +85,14 @@ fn main() { // StorageDead(_8); // StorageDead(_5); // StorageDead(_6); -// goto -> bb13; +// goto -> bb11; // } -// bb10: { // to pre_binding2 +// bb9: { // to pre_binding2 // StorageDead(_7); // StorageDead(_6); -// falseEdges -> [real: bb3, imaginary: bb3]; +// goto -> bb3; // } -// bb11: { // arm2 +// bb10: { // arm2 // StorageLive(_9); // _9 = ((_2 as Some).0: i32); // StorageLive(_10); @@ -102,13 +100,9 @@ fn main() { // _1 = (const 2i32, move _10); // StorageDead(_10); // StorageDead(_9); -// goto -> bb13; +// goto -> bb11; // } -// bb12: { // arm3 -// _1 = (const 3i32, const 3i32); -// goto -> bb13; -// } -// bb13: { +// bb11: { // arm3 // StorageDead(_2); // StorageDead(_1); // _0 = (); @@ -122,39 +116,33 @@ fn main() { // _2 = std::option::Option::<i32>::Some(const 42i32,); // FakeRead(ForMatchedPlace, _2); // _3 = discriminant(_2); -// switchInt(move _3) -> [0isize: bb3, 1isize: bb2, otherwise: bb6]; +// switchInt(move _3) -> [0isize: bb3, 1isize: bb2, otherwise: bb4]; // } // bb1 (cleanup): { // resume; // } // bb2: { -// falseEdges -> [real: bb7, imaginary: bb3]; +// falseEdges -> [real: bb5, imaginary: bb3]; // } // bb3: { -// falseEdges -> [real: bb11, imaginary: bb4]; +// falseEdges -> [real: bb9, imaginary: bb10]; // } -// bb4: { -// falseEdges -> [real: bb12, imaginary: bb5]; -// } -// bb5: { +// bb4: { // to arm3 (can skip 2 since this is `Some`) // unreachable; // } -// bb6: { -// unreachable; -// } -// bb7: { // binding1 and guard +// bb5: { // binding1 and guard // StorageLive(_6); // _6 = &((_2 as Some).0: i32); // _4 = &shallow _2; // StorageLive(_7); -// _7 = const guard() -> [return: bb8, unwind: bb1]; +// _7 = const guard() -> [return: bb6, unwind: bb1]; // } -// bb8: { // end of guard +// bb6: { // end of guard // FakeRead(ForMatchGuard, _4); // FakeRead(ForGuardBinding, _6); -// switchInt(move _7) -> [false: bb10, otherwise: bb9]; +// switchInt(move _7) -> [false: bb8, otherwise: bb7]; // } -// bb9: { // arm1 +// bb7: { // StorageDead(_7); // StorageLive(_5); // _5 = ((_2 as Some).0: i32); @@ -164,18 +152,18 @@ fn main() { // StorageDead(_8); // StorageDead(_5); // StorageDead(_6); -// goto -> bb13; +// goto -> bb11; // } -// bb10: { // to pre_binding3 (can skip 2 since this is `Some`) +// bb8: { // to pre_binding3 (can skip 2 since this is `Some`) // StorageDead(_7); // StorageDead(_6); -// falseEdges -> [real: bb4, imaginary: bb3]; +// falseEdges -> [real: bb10, imaginary: bb3]; // } -// bb11: { // arm2 +// bb9: { // arm2 // _1 = (const 3i32, const 3i32); -// goto -> bb13; +// goto -> bb11; // } -// bb12: { // binding3 and arm3 +// bb10: { // binding3 and arm3 // StorageLive(_9); // _9 = ((_2 as Some).0: i32); // StorageLive(_10); @@ -183,9 +171,9 @@ fn main() { // _1 = (const 2i32, move _10); // StorageDead(_10); // StorageDead(_9); -// goto -> bb13; +// goto -> bb11; // } -// bb13: { +// bb11: { // StorageDead(_2); // StorageDead(_1); // _0 = (); @@ -198,97 +186,91 @@ fn main() { // ... // _2 = std::option::Option::<i32>::Some(const 1i32,); // FakeRead(ForMatchedPlace, _2); -// _3 = discriminant(_2); -// switchInt(move _3) -> [1isize: bb2, otherwise: bb3]; +// _4 = discriminant(_2); +// switchInt(move _4) -> [1isize: bb2, otherwise: bb3]; // } // bb1 (cleanup): { // resume; // } // bb2: { -// falseEdges -> [real: bb7, imaginary: bb3]; +// falseEdges -> [real: bb5, imaginary: bb3]; // } // bb3: { -// falseEdges -> [real: bb11, imaginary: bb4]; +// falseEdges -> [real: bb9, imaginary: bb4]; // } // bb4: { -// falseEdges -> [real: bb12, imaginary: bb5]; +// falseEdges -> [real: bb10, imaginary: bb14]; // } // bb5: { -// falseEdges -> [real: bb16, imaginary: bb6]; -// } -// bb6: { -// unreachable; -// } -// bb7: { // binding1: Some(w) if guard() // StorageLive(_7); // _7 = &((_2 as Some).0: i32); // _5 = &shallow _2; // StorageLive(_8); -// _8 = const guard() -> [return: bb8, unwind: bb1]; +// _8 = const guard() -> [return: bb6, unwind: bb1]; // } -// bb8: { //end of guard1 +// bb6: { //end of guard1 // FakeRead(ForMatchGuard, _5); // FakeRead(ForGuardBinding, _7); -// switchInt(move _8) -> [false: bb10, otherwise: bb9]; +// switchInt(move _8) -> [false: bb8, otherwise: bb7]; // } -// bb9: { +// bb7: { // StorageDead(_8); // StorageLive(_6); // _6 = ((_2 as Some).0: i32); // _1 = const 1i32; // StorageDead(_6); // StorageDead(_7); -// goto -> bb17; +// goto -> bb15; // } -// bb10: { +// bb8: { // StorageDead(_8); // StorageDead(_7); // falseEdges -> [real: bb3, imaginary: bb3]; // } -// bb11: { // binding2 & arm2 +// bb9: { // binding2 & arm2 // StorageLive(_9); // _9 = _2; // _1 = const 2i32; // StorageDead(_9); -// goto -> bb17; +// goto -> bb15; // } -// bb12: { // binding3: Some(y) if guard2(y) +// bb10: { // binding3: Some(y) if guard2(y) // StorageLive(_11); // _11 = &((_2 as Some).0: i32); // _5 = &shallow _2; // StorageLive(_12); // StorageLive(_13); // _13 = (*_11); -// _12 = const guard2(move _13) -> [return: bb13, unwind: bb1]; +// _12 = const guard2(move _13) -> [return: bb11, unwind: bb1]; // } -// bb13: { // end of guard2 +// bb11: { // end of guard2 // StorageDead(_13); // FakeRead(ForMatchGuard, _5); // FakeRead(ForGuardBinding, _11); -// switchInt(move _12) -> [false: bb15, otherwise: bb14]; +// switchInt(move _12) -> [false: bb13, otherwise: bb12]; // } -// bb14: { // binding4 & arm4 +// bb12: { // binding4 & arm4 // StorageDead(_12); // StorageLive(_10); // _10 = ((_2 as Some).0: i32); // _1 = const 3i32; // StorageDead(_10); // StorageDead(_11); -// goto -> bb17; +// goto -> bb15; // } -// bb15: { +// bb13: { // StorageDead(_12); // StorageDead(_11); -// falseEdges -> [real: bb5, imaginary: bb5]; +// falseEdges -> [real: bb14, imaginary: bb14]; // } -// bb16: { +// bb14: { // StorageLive(_14); // _14 = _2; // _1 = const 4i32; // StorageDead(_14); -// goto -> bb17; +// goto -> bb15; // } -// bb17: { +// bb15: { // StorageDead(_2); // StorageDead(_1); // _0 = (); diff --git a/src/test/mir-opt/match_test.rs b/src/test/mir-opt/match_test.rs index 2ef9520c12c..ef60a04d1bd 100644 --- a/src/test/mir-opt/match_test.rs +++ b/src/test/mir-opt/match_test.rs @@ -20,67 +20,61 @@ fn main() { // START rustc.main.SimplifyCfg-initial.after.mir // bb0: { // ... -// switchInt(move _4) -> [false: bb6, otherwise: bb7]; +// switchInt(move _6) -> [false: bb6, otherwise: bb5]; // } // bb1: { -// falseEdges -> [real: bb10, imaginary: bb2]; +// falseEdges -> [real: bb9, imaginary: bb2]; // } // bb2: { -// falseEdges -> [real: bb13, imaginary: bb3]; +// falseEdges -> [real: bb12, imaginary: bb3]; // } // bb3: { -// falseEdges -> [real: bb14, imaginary: bb4]; +// falseEdges -> [real: bb13, imaginary: bb4]; // } // bb4: { -// falseEdges -> [real: bb15, imaginary: bb5]; +// _3 = const 3i32; +// goto -> bb14; // } // bb5: { -// unreachable; +// _7 = Lt(_1, const 10i32); +// switchInt(move _7) -> [false: bb6, otherwise: bb1]; // } // bb6: { -// _6 = Le(const 10i32, _1); -// switchInt(move _6) -> [false: bb8, otherwise: bb9]; +// _4 = Le(const 10i32, _1); +// switchInt(move _4) -> [false: bb8, otherwise: bb7]; // } // bb7: { -// _5 = Lt(_1, const 10i32); -// switchInt(move _5) -> [false: bb6, otherwise: bb1]; +// _5 = Le(_1, const 20i32); +// switchInt(move _5) -> [false: bb8, otherwise: bb2]; // } // bb8: { // switchInt(_1) -> [-1i32: bb3, otherwise: bb4]; // } // bb9: { -// _7 = Le(_1, const 20i32); -// switchInt(move _7) -> [false: bb8, otherwise: bb2]; -// } -// bb10: { // _8 = &shallow _1; // StorageLive(_9); // _9 = _2; // FakeRead(ForMatchGuard, _8); -// switchInt(move _9) -> [false: bb12, otherwise: bb11]; +// switchInt(move _9) -> [false: bb11, otherwise: bb10]; // } -// bb11: { +// bb10: { // StorageDead(_9); // _3 = const 0i32; -// goto -> bb16; +// goto -> bb14; // } -// bb12: { +// bb11: { // StorageDead(_9); // falseEdges -> [real: bb4, imaginary: bb2]; // } -// bb13: { +// bb12: { // _3 = const 1i32; -// goto -> bb16; +// goto -> bb14; // } -// bb14: { +// bb13: { // _3 = const 2i32; -// goto -> bb16; +// goto -> bb14; // } -// bb15: { -// _3 = const 3i32; -// goto -> bb16; -// } -// bb16: { +// bb14: { // _0 = (); // StorageDead(_2); // StorageDead(_1); diff --git a/src/test/mir-opt/nll/region-subtyping-basic.rs b/src/test/mir-opt/nll/region-subtyping-basic.rs index 622cc999830..fa0dbe51c5d 100644 --- a/src/test/mir-opt/nll/region-subtyping-basic.rs +++ b/src/test/mir-opt/nll/region-subtyping-basic.rs @@ -22,9 +22,9 @@ fn main() { // END RUST SOURCE // START rustc.main.nll.0.mir -// | '_#2r | U0 | {bb2[0..=8], bb3[0], bb6[0..=1]} -// | '_#3r | U0 | {bb2[1..=8], bb3[0], bb6[0..=1]} -// | '_#4r | U0 | {bb2[4..=8], bb3[0], bb6[0..=1]} +// | '_#2r | U0 | {bb2[0..=8], bb3[0], bb5[0..=1]} +// | '_#3r | U0 | {bb2[1..=8], bb3[0], bb5[0..=1]} +// | '_#4r | U0 | {bb2[4..=8], bb3[0], bb5[0..=1]} // END rustc.main.nll.0.mir // START rustc.main.nll.0.mir // let _2: &'_#3r usize; diff --git a/src/test/mir-opt/remove_fake_borrows.rs b/src/test/mir-opt/remove_fake_borrows.rs index 6ac9cee79f5..0f9c6f62c2b 100644 --- a/src/test/mir-opt/remove_fake_borrows.rs +++ b/src/test/mir-opt/remove_fake_borrows.rs @@ -19,21 +19,19 @@ fn main() { // bb0: { // FakeRead(ForMatchedPlace, _1); // _3 = discriminant(_1); -// switchInt(move _3) -> [1isize: bb4, otherwise: bb2]; +// switchInt(move _3) -> [1isize: bb3, otherwise: bb2]; // } // bb1: { -// goto -> bb5; +// goto -> bb4; // } // bb2: { -// goto -> bb8; +// _0 = const 1i32; +// goto -> bb7; // } // bb3: { -// unreachable; -// } -// bb4: { // switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2]; // } -// bb5: { +// bb4: { // _4 = &shallow _1; // _5 = &shallow ((_1 as Some).0: &'<empty> &'<empty> i32); // _6 = &shallow (*((_1 as Some).0: &'<empty> &'<empty> i32)); @@ -44,25 +42,21 @@ fn main() { // FakeRead(ForMatchGuard, _5); // FakeRead(ForMatchGuard, _6); // FakeRead(ForMatchGuard, _7); -// switchInt(move _8) -> [false: bb7, otherwise: bb6]; +// switchInt(move _8) -> [false: bb6, otherwise: bb5]; // } -// bb6: { +// bb5: { // StorageDead(_8); // _0 = const 0i32; -// goto -> bb9; +// goto -> bb7; // } -// bb7: { +// bb6: { // StorageDead(_8); // goto -> bb2; // } -// bb8: { -// _0 = const 1i32; -// goto -> bb9; -// } -// bb9: { +// bb7: { // return; // } -// bb10 (cleanup): { +// bb8 (cleanup): { // resume; // } // END rustc.match_guard.CleanupNonCodegenStatements.before.mir @@ -71,21 +65,19 @@ fn main() { // bb0: { // nop; // _3 = discriminant(_1); -// switchInt(move _3) -> [1isize: bb4, otherwise: bb2]; +// switchInt(move _3) -> [1isize: bb3, otherwise: bb2]; // } // bb1: { -// goto -> bb5; +// goto -> bb4; // } // bb2: { -// goto -> bb8; +// _0 = const 1i32; +// goto -> bb7; // } // bb3: { -// unreachable; -// } -// bb4: { // switchInt((*(*((_1 as Some).0: &'<empty> &'<empty> i32)))) -> [0i32: bb1, otherwise: bb2]; // } -// bb5: { +// bb4: { // nop; // nop; // nop; @@ -96,25 +88,21 @@ fn main() { // nop; // nop; // nop; -// switchInt(move _8) -> [false: bb7, otherwise: bb6]; +// switchInt(move _8) -> [false: bb6, otherwise: bb5]; // } -// bb6: { +// bb5: { // StorageDead(_8); // _0 = const 0i32; -// goto -> bb9; +// goto -> bb7; // } -// bb7: { +// bb6: { // StorageDead(_8); // goto -> bb2; // } -// bb8: { -// _0 = const 1i32; -// goto -> bb9; -// } -// bb9: { +// bb7: { // return; // } -// bb10 (cleanup): { +// bb8 (cleanup): { // resume; // } // END rustc.match_guard.CleanupNonCodegenStatements.after.mir diff --git a/src/test/mir-opt/simplify_if.rs b/src/test/mir-opt/simplify_if.rs index 35512b94c0c..471c1df3300 100644 --- a/src/test/mir-opt/simplify_if.rs +++ b/src/test/mir-opt/simplify_if.rs @@ -8,12 +8,12 @@ fn main() { // START rustc.main.SimplifyBranches-after-const-prop.before.mir // bb0: { // ... -// switchInt(const false) -> [false: bb3, otherwise: bb1]; +// switchInt(const false) -> [false: bb1, otherwise: bb2]; // } // END rustc.main.SimplifyBranches-after-const-prop.before.mir // START rustc.main.SimplifyBranches-after-const-prop.after.mir // bb0: { // ... -// goto -> bb3; +// goto -> bb1; // } // END rustc.main.SimplifyBranches-after-const-prop.after.mir diff --git a/src/test/mir-opt/simplify_match.rs b/src/test/mir-opt/simplify_match.rs index 0192aa01d01..8624899a0ab 100644 --- a/src/test/mir-opt/simplify_match.rs +++ b/src/test/mir-opt/simplify_match.rs @@ -9,14 +9,14 @@ fn main() { // START rustc.main.SimplifyBranches-after-copy-prop.before.mir // bb0: { // ... -// switchInt(const false) -> [false: bb3, otherwise: bb1]; +// switchInt(const false) -> [false: bb1, otherwise: bb2]; // } // bb1: { // END rustc.main.SimplifyBranches-after-copy-prop.before.mir // START rustc.main.SimplifyBranches-after-copy-prop.after.mir // bb0: { // ... -// goto -> bb3; +// goto -> bb1; // } // bb1: { // END rustc.main.SimplifyBranches-after-copy-prop.after.mir diff --git a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr index a8d00d15234..ca1496a6c8d 100644 --- a/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr +++ b/src/test/ui/borrowck/borrowck-mut-borrow-linear-errors.stderr @@ -2,22 +2,22 @@ error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:10:30 | LL | 1 => { addr.push(&mut x); } - | ---- ^^^^^^ second mutable borrow occurs here - | | - | first borrow later used here + | ^^^^^^ second mutable borrow occurs here LL | 2 => { addr.push(&mut x); } LL | _ => { addr.push(&mut x); } - | ------ first mutable borrow occurs here + | ---- ------ first mutable borrow occurs here + | | + | first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:11:30 | -LL | 1 => { addr.push(&mut x); } - | ---- first borrow later used here LL | 2 => { addr.push(&mut x); } | ^^^^^^ second mutable borrow occurs here LL | _ => { addr.push(&mut x); } - | ------ first mutable borrow occurs here + | ---- ------ first mutable borrow occurs here + | | + | first borrow later used here error[E0499]: cannot borrow `x` as mutable more than once at a time --> $DIR/borrowck-mut-borrow-linear-errors.rs:12:30 diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.rs b/src/test/ui/consts/const-eval/match-test-ptr-null.rs index e0af01aeef4..50757afaf56 100644 --- a/src/test/ui/consts/const-eval/match-test-ptr-null.rs +++ b/src/test/ui/consts/const-eval/match-test-ptr-null.rs @@ -6,6 +6,7 @@ fn main() { match &1 as *const i32 as usize { //~^ ERROR casting pointers to integers in constants //~| NOTE for more information, see + //~| ERROR constant contains unimplemented expression type 0 => 42, //~ ERROR constant contains unimplemented expression type //~^ NOTE "pointer arithmetic or comparison" needs an rfc before being allowed //~| ERROR evaluation of constant value failed diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr index d005e09b28a..167d5ad8d61 100644 --- a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr +++ b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr @@ -8,18 +8,24 @@ LL | match &1 as *const i32 as usize { = help: add #![feature(const_raw_ptr_to_usize_cast)] to the crate attributes to enable error[E0019]: constant contains unimplemented expression type - --> $DIR/match-test-ptr-null.rs:9:13 + --> $DIR/match-test-ptr-null.rs:6:15 + | +LL | match &1 as *const i32 as usize { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0019]: constant contains unimplemented expression type + --> $DIR/match-test-ptr-null.rs:10:13 | LL | 0 => 42, | ^ error[E0080]: evaluation of constant value failed - --> $DIR/match-test-ptr-null.rs:9:13 + --> $DIR/match-test-ptr-null.rs:10:13 | LL | 0 => 42, | ^ "pointer arithmetic or comparison" needs an rfc before being allowed inside constants -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0019, E0080, E0658. For more information about an error, try `rustc --explain E0019`. diff --git a/src/test/ui/consts/const-match-pattern-arm.rs b/src/test/ui/consts/const-match-pattern-arm.rs index 3b985269a56..6ed3ac23562 100644 --- a/src/test/ui/consts/const-match-pattern-arm.rs +++ b/src/test/ui/consts/const-match-pattern-arm.rs @@ -1,6 +1,7 @@ #![allow(warnings)] const x: bool = match Some(true) { + //~^ ERROR: constant contains unimplemented expression type [E0019] Some(value) => true, //~^ ERROR: constant contains unimplemented expression type [E0019] _ => false @@ -8,6 +9,7 @@ const x: bool = match Some(true) { const y: bool = { match Some(true) { + //~^ ERROR: constant contains unimplemented expression type [E0019] Some(value) => true, //~^ ERROR: constant contains unimplemented expression type [E0019] _ => false diff --git a/src/test/ui/consts/const-match-pattern-arm.stderr b/src/test/ui/consts/const-match-pattern-arm.stderr index c793cc0cd78..709b66b7bf0 100644 --- a/src/test/ui/consts/const-match-pattern-arm.stderr +++ b/src/test/ui/consts/const-match-pattern-arm.stderr @@ -1,15 +1,27 @@ error[E0019]: constant contains unimplemented expression type - --> $DIR/const-match-pattern-arm.rs:4:5 + --> $DIR/const-match-pattern-arm.rs:3:23 + | +LL | const x: bool = match Some(true) { + | ^^^^^^^^^^ + +error[E0019]: constant contains unimplemented expression type + --> $DIR/const-match-pattern-arm.rs:5:5 | LL | Some(value) => true, | ^^^^^^^^^^^ error[E0019]: constant contains unimplemented expression type - --> $DIR/const-match-pattern-arm.rs:11:9 + --> $DIR/const-match-pattern-arm.rs:11:11 + | +LL | match Some(true) { + | ^^^^^^^^^^ + +error[E0019]: constant contains unimplemented expression type + --> $DIR/const-match-pattern-arm.rs:13:9 | LL | Some(value) => true, | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0019`. diff --git a/src/test/ui/consts/single_variant_match_ice.rs b/src/test/ui/consts/single_variant_match_ice.rs index 6002506689e..75793c90483 100644 --- a/src/test/ui/consts/single_variant_match_ice.rs +++ b/src/test/ui/consts/single_variant_match_ice.rs @@ -2,12 +2,12 @@ enum Foo { Prob, } -const FOO: u32 = match Foo::Prob { - Foo::Prob => 42, //~ ERROR unimplemented expression type +const FOO: u32 = match Foo::Prob { //~ ERROR unimplemented expression type + Foo::Prob => 42, }; -const BAR: u32 = match Foo::Prob { - x => 42, //~ ERROR unimplemented expression type +const BAR: u32 = match Foo::Prob { //~ ERROR unimplemented expression type + x => 42, }; impl Foo { @@ -15,7 +15,8 @@ impl Foo { use self::Foo::*; match *self { - Prob => 0x1, //~ ERROR loops and conditional expressions are not stable in const fn + //~^ ERROR loops and conditional expressions are not stable in const fn + Prob => 0x1, } } } diff --git a/src/test/ui/consts/single_variant_match_ice.stderr b/src/test/ui/consts/single_variant_match_ice.stderr index 1e092c8af99..851733726ac 100644 --- a/src/test/ui/consts/single_variant_match_ice.stderr +++ b/src/test/ui/consts/single_variant_match_ice.stderr @@ -1,20 +1,20 @@ error[E0019]: constant contains unimplemented expression type - --> $DIR/single_variant_match_ice.rs:6:5 + --> $DIR/single_variant_match_ice.rs:5:24 | -LL | Foo::Prob => 42, - | ^^^^^^^^^ +LL | const FOO: u32 = match Foo::Prob { + | ^^^^^^^^^ error[E0019]: constant contains unimplemented expression type - --> $DIR/single_variant_match_ice.rs:10:5 + --> $DIR/single_variant_match_ice.rs:9:24 | -LL | x => 42, - | ^ +LL | const BAR: u32 = match Foo::Prob { + | ^^^^^^^^^ error[E0723]: loops and conditional expressions are not stable in const fn - --> $DIR/single_variant_match_ice.rs:18:13 + --> $DIR/single_variant_match_ice.rs:17:15 | -LL | Prob => 0x1, - | ^^^^ +LL | match *self { + | ^^^^^ | = note: for more information, see issue https://github.com/rust-lang/rust/issues/57563 = help: add #![feature(const_fn)] to the crate attributes to enable diff --git a/src/test/ui/issues/issue-46843.rs b/src/test/ui/issues/issue-46843.rs index a310de624d2..aa252efea46 100644 --- a/src/test/ui/issues/issue-46843.rs +++ b/src/test/ui/issues/issue-46843.rs @@ -4,7 +4,9 @@ fn non_const() -> Thing { Thing::This } -pub const Q: i32 = match non_const() { //~ ERROR E0015 +pub const Q: i32 = match non_const() { + //~^ ERROR E0015 + //~^^ ERROR unimplemented expression type Thing::This => 1, //~ ERROR unimplemented expression type Thing::That => 0 }; diff --git a/src/test/ui/issues/issue-46843.stderr b/src/test/ui/issues/issue-46843.stderr index b7abf0213b0..92ee154552c 100644 --- a/src/test/ui/issues/issue-46843.stderr +++ b/src/test/ui/issues/issue-46843.stderr @@ -5,12 +5,18 @@ LL | pub const Q: i32 = match non_const() { | ^^^^^^^^^^^ error[E0019]: constant contains unimplemented expression type - --> $DIR/issue-46843.rs:8:5 + --> $DIR/issue-46843.rs:7:26 + | +LL | pub const Q: i32 = match non_const() { + | ^^^^^^^^^^^ + +error[E0019]: constant contains unimplemented expression type + --> $DIR/issue-46843.rs:10:5 | LL | Thing::This => 1, | ^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0015, E0019. For more information about an error, try `rustc --explain E0015`. diff --git a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr index c646912d3b6..13b6a7bbef3 100644 --- a/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr +++ b/src/test/ui/lifetimes/lifetime-errors/liveness-assign-imm-local-notes.stderr @@ -28,6 +28,9 @@ LL | let x; ... LL | x = 1; | ^^^^^ cannot assign twice to immutable variable +LL | } else { +LL | x = 2; + | ----- first assignment to `x` error[E0384]: cannot assign twice to immutable variable `x` --> $DIR/liveness-assign-imm-local-notes.rs:32:13 @@ -35,9 +38,6 @@ error[E0384]: cannot assign twice to immutable variable `x` LL | let x; | - help: make this binding mutable: `mut x` ... -LL | x = 1; - | ----- first assignment to `x` -LL | } else { LL | x = 2; | ^^^^^ cannot assign twice to immutable variable |
