Skip to content

Ensure StorageDead is created even if variable initialization fails #52046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 13, 2018

Conversation

cramertj
Copy link
Member

@cramertj cramertj commented Jul 4, 2018

Rebase and slight cleanup of #51109
Fixes #49232

r? @eddyb

@cramertj cramertj requested a review from eddyb July 4, 2018 01:20
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 4, 2018
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
travis_time:start:test_mir-opt
Check compiletest suite=mir-opt mode=mir-opt (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:56:36] 
[00:56:36] running 51 tests
[00:56:37] ERROR 2018-07-04T02:19:07Z: compiletest::runtest: Some("    bb6: {")
[00:56:37] ERROR 2018-07-04T02:19:08Z: compiletest::runtest: Some("    bb4: {")
[00:56:41] ERROR 2018-07-04T02:19:11Z: compiletest::runtest: Some("    bb4: {")
[00:56:41] ERROR 2018-07-04T02:19:11Z: compiletest::runtest: Some("    bb4: {")
[00:56:41] ERROR 2018-07-04T02:19:11Z: compiletest::runtest: Some("    bb4: {")
[00:56:41] ERROR 2018-07-04T02:19:11Z: compiletest::runtest: Some("    bb4: {")
[00:56:43] ERROR 2018-07-04T02:19:13Z: compiletest::runtest: Some("   bb4: {")
[00:56:43] ERROR 2018-07-04T02:19:14Z: compiletest::runtest: Some("    bb2: {")
[00:56:44] ERROR 2018-07-04T02:19:14Z: compiletest::runtest: None
[00:56:51] ERROR 2018-07-04T02:19:21Z: compiletest::runtest: Some("    bb2: {")
[00:56:54] ERROR 2018-07-04T02:19:24Z: compiletest::runtest: None
[00:56:58] .FF.........FFFF..F..F..F.............F.....F......
[00:56:58] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:56:58] 
[00:56:58] ---- [mir-opt] mir-opt/basic_assignment.rs stdout ----
[00:56:58] ---- [mir-opt] mir-opt/basic_assignment.rs stdout ----
[00:56:58] thread '[mir-opt] mir-opt/basic_assignment.rs' panicked at 'Did not find expected line, error: Mismatch in lines
[00:56:58] Current block:     bb6: {
[00:56:58] Actual Line: "        StorageDead(_6);"
[00:56:58] Expected Line: "        _0 = ();"
[00:56:58] Test Name: rustc.main.SimplifyCfg-initial.after.mir
[00:56:58] Expected:
[00:56:58] ... (elided)
[00:56:58]     bb0: {
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = const false;
[00:56:58]         StorageLive(_2);
[00:56:58]         StorageLive(_3);
[00:56:58]         _3 = _1;
[00:56:58]         _2 = move _3;
[00:56:58]         StorageDead(_3);
[00:56:58]         StorageLive(_4);
[00:56:58]         UserAssertTy(Canonical { variables: [], value: std::option::Option<std::boxed::Box<u32>> }, _4);
[00:56:58]         _4 = std::option::Option<std::boxed::Box<u32>>::None;
[00:56:58]         StorageLive(_5);
[00:56:58]         StorageLive(_6);
[00:56:58]         _6 = move _4;
[00:56:58]         replace(_5 <-move _6) -> [return: bb2, unwind: bb5];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     bb2: {
[00:56:58]     bb2: {
[00:56:58]         drop(_6) -> [return: bb6, unwind: bb4];
[00:56:58]     bb3: {
[00:56:58]         drop(_4) -> bb1;
[00:56:58]     }
[00:56:58]     bb4: {
[00:56:58]     bb4: {
[00:56:58]         drop(_5) -> bb3;
[00:56:58]     }
[00:56:58]     bb5: {
[00:56:58]         drop(_6) -> bb4;
[00:56:58]     }
[00:56:58]     bb6: {
[00:56:58]         StorageDead(_6);
[00:56:58]         _0 = ();
[00:56:58]         drop(_5) -> [return: bb7, unwind: bb3];
[00:56:58]     bb7: {
[00:56:58]     bb7: {
[00:56:58]         StorageDead(_5);
[00:56:58]         drop(_4) -> [return: bb8, unwind: bb1];
[00:56:58]     bb8: {
[00:56:58]     bb8: {
[00:56:58]         StorageDead(_4);
[00:56:58]         StorageDead(_2);
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] Actual:
[00:56:58] fn main() -> (){
[00:56:58] fn main() -> (){
[00:56:58]     let mut _0: ();
[00:56:58]     scope 1 {
[00:56:58]         scope 3 {
[00:56:58]             scope 5 {
[00:56:58]                 scope 7 {
[00:56:58]                 scope 8 {
[00:56:58]                 scope 8 {
[00:56:58]                     let _5: std::option::Option<std::boxed::Box<u32>>;
[00:56:58]             }
[00:56:58]             scope 6 {
[00:56:58]             scope 6 {
[00:56:58]                 let _4: std::option::Option<std::boxed::Box<u32>>;
[00:56:58]         }
[00:56:58]         scope 4 {
[00:56:58]         scope 4 {
[00:56:58]             let _2: bool;
[00:56:58]     }
[00:56:58]     scope 2 {
[00:56:58]     scope 2 {
[00:56:58]         let _1: bool;
[00:56:58]     }
[00:56:58]     let mut _3: bool;
[00:56:58]     let mut _6: std::option::Option<std::boxed::Box<u32>>;
[00:56:58]     bb0: {                              
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = const false;
[00:56:58]         StorageLive(_2);
[00:56:58]         StorageLive(_3);
[00:56:58]         _3 = _1;
[00:56:58]         _2 = move _3;
[00:56:58]         StorageDead(_3);
[00:56:58]         StorageLive(_4);
[00:56:58]         UserAssertTy(Canonical { variables: [], value: std::option::Option<std::boxed::Box<u32>> }, _4);
[00:56:58]         _4 = std::option::Option<std::boxed::Box<u32>>::None;
[00:56:58]         StorageLive(_5);
[00:56:58]         StorageLive(_6);
[00:56:58]         _6 = move _4;
[00:56:58]         replace(_5 <- move _6) -> [return: bb2, unwind: bb5];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb2: {                              
[00:56:58]         drop(_6) -> [return: bb6, unwind: bb4];
[00:56:58]     bb3: {
[00:56:58]         drop(_4) -> bb1;
[00:56:58]     }
[00:56:58]     bb4: {
[00:56:58]     bb4: {
[00:56:58]         drop(_5) -> bb3;
[00:56:58]     }
[00:56:58]     bb5: {
[00:56:58]         drop(_6) -> bb4;
[00:56:58]     }
[00:56:58]     bb6: {                              
[00:56:58]         StorageDead(_6);
[00:56:58]         StorageDead(_6);
[00:56:58]                resume;
[00:56:58]     bb2: {
[00:56:58]         _1 = move _2;
[00:56:58]         drop(_2) -> bb4;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb3: {
[00:56:58]         drop(_2) -> bb1;
[00:56:58]     }
[00:56:58]     bb4: {
[00:56:58]         StorageDead(_2);
[00:56:58]         StorageLive(_4);
[00:56:58]         _4 = move _1;
[00:56:58]         _3 = const std::mem::drop(move _4) -> [return: bb5, unwind: bb7];
[00:56:58]     bb5: {
[00:56:58]     bb5: {
[00:56:58]         drop(_4) -> [return: bb8, unwind: bb6];
[00:56:58]     bb6: {
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     }
[00:56:58]     bb7: {
[00:56:58]     bb7: {
[00:56:58]         drop(_4) -> bb6;
[00:56:58]     }
[00:56:58]     bb8: {
[00:56:58]         StorageDead(_4);
[00:56:58]         _0 = ();
[00:56:58]         drop(_1) -> bb9;
[00:56:58]     bb9: {
[00:56:58]     bb9: {
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] }
[00:56:58] Actual:
[00:56:58] fn main() -> (){
[00:56:58] fn main() -> (){
[00:56:58]     let mut _0: ();
[00:56:58]     scope 1 {
[00:56:58]     scope 2 {
[00:56:58]     scope 2 {
[00:56:58]         let _1: std::boxed::Box<S>;
[00:56:58]     }
[00:56:58]     let mut _2: std::boxed::Box<S>;
[00:56:58]     let mut _3: ();
[00:56:58]     let mut _4: std::boxed::Box<S>;
[00:56:58]     bb0: {                              
[00:56:58]         StorageLive(_1);
[00:56:58]         StorageLive(_2);
[00:56:58]         _2 = Box(S);
[00:56:58]         (*_2) = const S::new() -> [return: bb2, unwind: bb3];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb2: {                              
[00:56:58]         _1 = move _2;
[00:56:58]         drop(_2) -> bb4;
[00:56:58]     bb3: {
[00:56:58]         drop(_2) -> bb1;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb4: {                              
[00:56:58]         StorageDead(_2);
[00:56:58]         StorageDead(_2);
[00:56:58]         StorageLive(_4);
[00:56:58]         _4 = move _1;
[00:56:58]         _3 = const std::mem::drop(move _4) -> [return: bb5, unwind: bb7];
[00:56:58]     }
[00:56:58]     bb5: {                              
[00:56:58]         drop(_4) -> [return: bb8, unwind: bb6];
[00:56:58]     bb6: {
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     }
[00:56:58]     bb7: {
[00:56:58]     bb7: {
[00:56:58]         drop(_4) -> bb6;
[00:56:58]     }
[00:56:58]     bb8: {                              
[00:56:58]         StorageDead(_4);
[00:56:58]         StorageDead(_4);
[00:56:58]         _0 = ();
[00:56:58]         drop(_1) -> bb9;
[00:56:58]     }
[00:56:58]     bb9: {                              
[00:56:58]         StorageDead(_1);
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] }', tools/compiletest/src/runtest.rs:2816:13
[00:56:58] 
[00:56:58] ---- [mir-opt] mir-opt/end_region_4.rs stdout ----
[00:56:58] ---- [mir-opt] mir-opt/end_region_4.rs stdout ----
[00:56:58] thread '[mir-opt] mir-opt/end_region_4.rs' panicked at 'Did not find expected line, error: Mismatch in lines
[00:56:58] Current block:     bb4: {
[00:56:58] Actual Line: "        StorageDead(_1);"
[00:56:58] Expected Line: "        return;"
[00:56:58] Test Name: rustc.main.SimplifyCfg-qualify-consts.after.mir
[00:56:58] Expected:
[00:56:58] ... (elided)
[00:56:58]     let mut _0: ();
[00:56:58] ... (elided)
[00:56:58]     let _6: &'26_4rs i32;
[00:56:58] ... (elided)
[00:56:58]     let _3: &'26_2rs i32;
[00:56:58] ... (elided)
[00:56:58]     let _2: i32;
[00:56:58] ... (elided)
[00:56:58]     let _1: D;
[00:56:58] ... (elided)
[00:56:58]     let mut _4: ();
[00:56:58]     let mut _5: i32;
[00:56:58]     bb0: {
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = D::{{constructor}}(const 0i32,);
[00:56:58]         StorageLive(_2);
[00:56:58]         _2 = const 0i32;
[00:56:58]         StorageLive(_3);
[00:56:58]         _3 = &'26_2rs _2;
[00:56:58]         StorageLive(_5);
[00:56:58]         _5 = (*_3);
[00:56:58]         _4 = const foo(move _5) -> [return: bb2, unwind: bb3];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     bb2: {
[00:56:58]     bb2: {
[00:56:58]         StorageDead(_5);
[00:56:58]         StorageLive(_6);
[00:56:58]         _6 = &'26_4rs _2;
[00:56:58]         _0 = ();
[00:56:58]         EndRegion('26_4rs);
[00:56:58]         StorageDead(_6);
[00:56:58]         EndRegion('26_2rs);
[00:56:58]         StorageDead(_3);
[00:56:58]         StorageDead(_2);
[00:56:58]         drop(_1) -> [return: bb4, unwind: bb1];
[00:56:58]     bb3: {
[00:56:58]     bb3: {
[00:56:58]         EndRegion('26_2rs);
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     bb4: {
[00:56:58]     bb4: {
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] Actual:
[00:56:58] fn main() -> (){
[00:56:58] fn main() -> (){
[00:56:58]     let mut _0: ();
[00:56:58]     scope 1 {
[00:56:58]         scope 3 {
[00:56:58]             scope 5 {
[00:56:58]                 scope 7 {
[00:56:58]                 scope 8 {
[00:56:58]                 scope 8 {
[00:56:58]                     let _6: &'26_4rs i32;
[00:56:58]             }
[00:56:58]             scope 6 {
[00:56:58]             scope 6 {
[00:56:58]                 let _3: &'26_2rs i32;
[00:56:58]         }
[00:56:58]         scope 4 {
[00:56:58]             let _2: i32;
[00:56:58]         }
[00:56:58]         }
[00:56:58]     }
[00:56:58]     scope 2 {
[00:56:58]         let _1: D;
[00:56:58]     }
[00:56:58]     let mut _4: ();
[00:56:58]     let mut _5: i32;
[00:56:58]     bb0: {                              
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = D::{{constructor}}(const 0i32,);
[00:56:58]         StorageLive(_2);
[00:56:58]         _2 = const 0i32;
[00:56:58]         StorageLive(_3);
[00:56:58]         _3 = &'26_2rs _2;
[00:56:58]         StorageLive(_5);
[00:56:58]         _5 = (*_3);
[00:56:58]         _4 = const foo(move _5) -> [return: bb2, unwind: bb3];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb2: {                              
[00:56:58]         StorageDead(_5);
[00:56:58]         StorageLive(_6);
[00:56:58]         _6 = &'26_4rs _2;
[00:56:58]         _0 = ();
[00:56:58]         EndRegion('26_4rs);
[00:56:58]         StorageDead(_6);
[00:56:58]         EndRegion('26_2rs);
[00:56:58]         StorageDead(_3);
[00:56:58]         StorageDead(_2);
[00:56:58]         drop(_1) -> [return: bb4, unwind: bb1];
[00:56:58]     }       StorageDead(_3);
[00:56:58]         _0 = ();
[00:56:58]         drop(_1) -> [return: bb4, unwind: bb1];
[00:56:58]     bb3: {
[00:56:58]     bb3: {
[00:56:58]         EndRegion('14s);
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     bb4: {
[00:56:58]     bb4: {
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] }
[00:56:58] Actual:
[00:56:58] fn main() -> (){
[00:56:58] fn main() -> (){
[00:56:58]     let mut _0: ();
[00:56:58]     scope 1 {
[00:56:58]     scope 2 {
[00:56:58]         let _1: D;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     let mut _2: ();
[00:56:58]     let mut _3: [closure@NodeId(18) d:&'14s D];
[00:56:58]     let mut _4: &'14s D;
[00:56:58]     bb0: {                              
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = D::{{constructor}}(const 0i32,);
[00:56:58]         StorageLive(_3);
[00:56:58]         StorageLive(_4);
[00:56:58]         _4 = &'14s _1;
[00:56:58]         _3 = [closure@NodeId(18)] { d: move _4 };
[00:56:58]         StorageDead(_4);
[00:56:58]         _2 = const foo(move _3) -> [return: bb2, unwind: bb3];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb2: {                              
[00:56:58]         EndRegion('14s);
[00:56:58]         StorageDead(_3);
[00:56:58]         _0 = ();
[00:56:58]         drop(_1) -> [return: bb4, unwind: bb1];
[00:56:58]     bb3: {
[00:56:58]     bb3: {
[00:56:58]         EndRegion('14s);
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     }
[00:56:58]     bb4: {                              
[00:56:58]         StorageDead(_1);
[00:56:58]     bb4: {
[00:56:58]     bb4: {
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] Actual:
[00:56:58] fn main() -> (){
[00:56:58] fn main() -> (){
[00:56:58]     let mut _0: ();
[00:56:58]     scope 1 {
[00:56:58]     scope 2 {
[00:56:58]         let _1: D;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     let mut _2: ();
[00:56:58]     let mut _3: [closure@NodeId(22) d:&'19s D];
[00:56:58]     let mut _4: &'19s D;
[00:56:58]     bb0: {                              
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = D::{{constructor}}(const 0i32,);
[00:56:58]         StorageLive(_3);
[00:56:58]         StorageLive(_4);
[00:56:58]         _4 = &'19s _1;
[00:56:58]         _3 = [closure@NodeId(22)] { d: move _4 };
[00:56:58]         StorageDead(_4);
[00:56:58]         _2 = const foo(move _3) -> [return: bb2, unwind: bb3];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     }
[00:56:58]     bb2: {                              
[00:56:58]         EndRegion('19s);
[00:56:58]         StorageDead(_3);
[00:56:58]         _0 = ();
[00:56:58]         drop(_1) -> [return: bb4, unwind: bb1];
[00:56:58]     bb3: {
[00:56:58]     bb3: {
[00:56:58]         EndRegion('19s);
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     }
[00:56:58]     bb4: {                              
[00:56:58]         StorageDead(_1);
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] }', tools/compiletest/src/runtest.rs:2816:13
[00:56:58] 
[00:56:58] ---- [mir-opt] mir-opt/end_region_7.rs stdout ----
[00:56:58] ---- [mir-opt] mir-opt/end_region_7.rs stdout ----
[00:56:58] thread '[mir-opt] mir-opt/end_region_7.rs' panicked at 'Did not find expected line, error: Mismatch in lines
[00:56:58] Current block:     bb4: {
[00:56:58] Actual Line: "        StorageDead(_4);"
[00:56:58] Expected Line: "        _2 = const foo(move _3) -> [return: bb5, unwind: bb3];"
[00:56:58] Test Name: rustc.main.SimplifyCfg-qualify-consts.after.mir
[00:56:58] Expected:
[00:56:58] ... (elided)
[00:56:58] fn main() -> () {
[00:56:58]     let mut _0: ();
[00:56:58] ... (elided)
[00:56:58]     let _1: D;
[00:56:58] ... (elided)
[00:56:58]     let mut _2: ();
[00:56:58]     let mut _3: [closure@NodeId(22) d:D];
[00:56:58]     let mut _4: D;
[00:56:58]     bb0: {
[00:56:58]         StorageLive(_1);
[00:56:58]         _1 = D::{{constructor}}(const 0i32,);
[00:56:58]         StorageLive(_3);
[00:56:58]         StorageLive(_4);
[00:56:58]         _4 = move _1;
[00:56:58]         _3 = [closure@NodeId(22)] { d: move _4 };
[00:56:58]         drop(_4) -> [return: bb4, unwind: bb3];
[00:56:58]     bb1: {
[00:56:58]         resume;
[00:56:58]     }
[00:56:58]     bb2: {
[00:56:58]     bb2: {
[00:56:58]         drop(_1) -> bb1;
[00:56:58]     }
[00:56:58]     bb3: {
[00:56:58]         drop(_3) -> bb2;
[00:56:58]     }
[00:56:58]     bb4: {
[00:56:58]         StorageDead(_4);
[00:56:58]         _2 = const foo(move _3) -> [return: bb5, unwind: bb3];
[00:56:58]     bb5: {
[00:56:58]     bb5: {
[00:56:58]         drop(_3) -> [return: bb6, unwind: bb2];
[00:56:58]     bb6: {
[00:56:58]     bb6: {
[00:56:58]         StorageDead(_3);
[00:56:58]         _0 = ();
[00:56:58]         drop(_1) -> [return: bb7, unwind: bb1];
[00:56:58]     58]     bb7: {                              
[00:56:58]         StorageDead(_1);
[00:56:58]         StorageDead(_1);
[00:56:58]         return;
[00:56:58] }', tools/compiletest/src/runtest.rs:2816:13
[00:56:58] 
[00:56:58] ---- [mir-opt] mir-opt/end_region_8.rs stdout ----
[00:56:58] ---- [mir-opt] mir-opt/end_region_8.rs stdout ----
[00:56:58] thread '[mir-opt] mir-opt/end_region_8.rs' panicked at 'Did not find expected line, error: Mismatch in lines
[00:56:58] Current block:    bb4: {
[00:56:58] Actual Line: "        StorageDead(_1);"
[00:56:58] Expected Line: "       return;"
[00:56:58] Test Name: rustc.main.SimplifyCfg-qualify-consts.after.mir
[00:56:58] Expected:
[00:56:58] ... (elided)
[00:56:58] fn main() -> () {
[00:56:58]    let mut _0: ();
[00:56:58] ... (elided)
[00:56:58]    let _2: &'21_1rs D;
[00:56:58] ... (elided)
[00:56:58]    let _1: D;
[00:56:58] ... (elided)
[00:56:58]    let mut _3: ();
[00:56:58]    let mut _4: [closure@NodeId(22) r:&'19s D];
[00:56:58]    let mut _5: &'21_1rs D;
[00:56:58]    bb0: {
[00:56:58]        StorageLive(_1);
[00:56:58]        _1 = D::{{constructor}}(const 0i32,);
[00:56:58]        StorageLive(_2);
[00:56:58]        _2 = &'21_1rs _1;
[00:56:58]        StorageLive(_4);
[00:56:58]        StorageLive(_5);
[00:56:58]        _5 = _2;
[00:56:58]        _4 = [closure@NodeId(22)] { r: move _5 };
---
[00:56:58] test result: FAILED. 40 passed; 11 failed; 0 ignored; 0 measured; 0 filtered out
[00:56:58] 
[00:56:58] 
[00:56:58] 
[00:56:58] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/mir-opt" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/mir-opt" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "mir-opt" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-3.9/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "3.9.1\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:56:58] 
[00:56:58] 
[00:56:58] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:56:58] Build completed unsuccessfully in 0:15:01
[00:56:58] Build completed unsuccessfully in 0:15:01
[00:56:58] make: *** [check] Error 1
[00:56:58] Makefile:58: recipe for target 'check' failed
107692 ./obj/build/x86_64-unknown-linux-gnu/stage1-std/x86_64-unknown-linux-gnu/release
103928 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu
103924 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release
100572 ./obj/build/x86_64-unknown-linux-gnu/stage0-tools/x86_64-unknown-linux-gnu/release/deps

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@pietroalbini
Copy link
Member

Ping from triage @eddyb! This PR needs your review.

DropKind::Value { .. } => if !needs_drop { return },
DropKind::Storage => {
match *place {
Place::Local(index) if index.index() > self.arg_count => (),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this be replaced with an assert, that the place is a local, and that the index is larger than arg_count? Given the changes in args_and_body, I expect this to work.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@cramertj cramertj force-pushed the fix-generator-mir branch from 477f3b1 to 162cba7 Compare July 9, 2018 22:05
@cramertj
Copy link
Member Author

cramertj commented Jul 9, 2018

@eddyb A bunch of other mir-opt tests fail as a result of this PR due to it introducing duplicate StorageDead statements. Is that something I should attempt to fix, or just blindly copy the current output into the expected? Also, is there a better way for me to update those, or just copy-paste from the test output into my editor (a la --bless)?

@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-3.9 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/e7/d9/f7e8d725a8f19dddfb4807753ad70d2935e1b8a425f4e9d5c87e06e83931/awscli-1.15.54-py2.py3-none-any.whl (1.3MB)
    0% |▎                               | 10kB 17.5MB/s eta 0:00:01
    1% |▌                               | 20kB 1.9MB/s eta 0:00:01
    2% |▊                               | 30kB 2.1MB/s eta 0:00:01
    3% |█                               | 40kB 1.9MB/s eta 0:00:01
---

[00:03:56] travis_fold:start:tidy
travis_time:start:tidy
tidy check
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:44: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:47: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:50: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:58: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:69: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:75: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:79: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:82: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:85: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:88: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:91: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:94: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:97: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:100: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:114: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:118: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:122: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:126: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:130: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:134: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:139: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:143: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:147: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:151: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:155: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:159: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:163: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:169: trailing whitespace
[00:03:57] tidy error: /checkout/src/test/mir-opt/issue-49232.rs:181: trailing whitespace
[00:03:58] some tidy checks failed
[00:03:58] 
[00:03:58] 
[00:03:58] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/tidy" "/checkout/src" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "--no-vendor" "--quiet"
[00:03:58] 
[00:03:58] 
[00:03:58] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test src/tools/tidy
[00:03:58] Build completed unsuccessfully in 0:00:50
[00:03:58] Build completed unsuccessfully in 0:00:50
[00:03:58] Makefile:79: recipe for target 'tidy' failed
[00:03:58] make: *** [tidy] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:2ddd9c84
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)
---
travis_time:end:10237be2:start=1531174307364301347,finish=1531174307373984434,duration=9683087
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:00e5b5a0
$ head -30 ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
head: cannot open ‘./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers’ for reading: No such file or directory
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:1ad76094
$ dmesg | grep -i kill

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

index.index(),
self.arg_count)
},
_ => panic!("`schedule_drop` called with non-`Local` place {:?}", place),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're not using assert_eq etc, you can use bug! instead of panic!.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Switched to span_bug.

@cramertj cramertj force-pushed the fix-generator-mir branch from b6242d3 to 1e5c6a7 Compare July 11, 2018 19:40
@cramertj cramertj changed the title [WIP] Ensure StorageDead is created even if variable initialization fails Ensure StorageDead is created even if variable initialization fails Jul 11, 2018
@cramertj cramertj force-pushed the fix-generator-mir branch from 1e5c6a7 to 97903bf Compare July 11, 2018 19:51
@rust-highfive
Copy link
Contributor

The job x86_64-gnu-llvm-5.0 of your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.
  InsecurePlatformWarning
  Downloading https://files.pythonhosted.org/packages/2d/99/b2c4e9d5a30f6471e410a146232b4118e697fa3ffc06d6a65efde84debd0/futures-3.2.0-py2-none-any.whl
Requirement already satisfied: six>=1.5 in /usr/lib/python2.7/dist-packages (from python-dateutil<3.0.0,>=2.1; python_version >= "2.7"->botocore==1.10.55->awscli)
Building wheels for collected packages: awscli
  Running setup.py bdist_wheel for awscli ... - \ | / - \ done
Successfully built awscli
Installing collected packages: docutils, jmespath, python-dateutil, botocore, colorama, pyasn1, rsa, futures, s3transfer, awscli
Successfully installed awscli-1.15.56 botocore-1.10.55 colorama-0.3.9 docutils-0.14 futures-3.2.0 jmespath-0.9.3 pyasn1-0.4.3 python-dateutil-2.7.3 rsa-3.4.2 s3transfer-0.1.13
/usr/local/lib/python2.7/dist-packages/pip/_vendor/requests/packages/urllib3/util/ssl_.py:122: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. You can upgrade to a newer version of Python to solve this. For more information, see https://urllib3.readthedocs.io/en/latest/security.html#insecureplatformwarning.
---
travis_time:start:test_codegen
Check compiletest suite=codegen mode=codegen (x86_64-unknown-linux-gnu -> x86_64-unknown-linux-gnu)
[00:54:58] 
[00:54:58] running 97 tests
[00:55:01] thread 'main' panicked at 'Some tests failed', tools/compiletest/src/main.rs:498:22
[00:55:01] i..ii..iii....i...i...........ii.....F.....i........ii...i.i.ii..............i...ii...i..iii.....
[00:55:01] 
[00:55:01] ---- [codegen] codegen/lifetime_start_end.rs stdout ----
[00:55:01] 
[00:55:01] 
[00:55:01] error: verification with 'FileCheck' failed
[00:55:01] status: exit code: 1
[00:55:01] command: "/usr/lib/llvm-5.0/bin/FileCheck" "--input-file" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/lifetime_start_end/lifetime_start_end.ll" "/checkout/src/test/codegen/lifetime_start_end.rs"
[00:55:01] ------------------------------------------
[00:55:01] 
[00:55:01] ------------------------------------------
[00:55:01] stderr:
[00:55:01] stderr:
[00:55:01] ------------------------------------------
[00:55:01] /checkout/src/test/codegen/lifetime_start_end.rs:37:11: error: expected string not found in input
[00:55:01] // CHECK: [[E__4:%[0-9]+]] = bitcast { i32, i32 }* %_4 to i8*
[00:55:01]           ^
[00:55:01] /checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen/lifetime_start_end/lifetime_start_end.ll:33:2: note: scanning from here
[00:55:01]  %9 = bitcast i32* %c to i8*
[00:55:01]  ^
[00:55:01] ------------------------------------------
[00:55:01] 
[00:55:01] thread '[codegen] codegen/lifetime_start_end.rs' panicked at 'explicit panic', tools/compiletest/src/runtest.rs:3140:9
[00:55:01] note: Run with `RUST_BACKTRACE=1` for a backtrace.
---
[00:55:01] test result: FAILED. 72 passed; 1 failed; 24 ignored; 0 measured; 0 filtered out
[00:55:01] 
[00:55:01] 
[00:55:01] 
[00:55:01] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0-tools-bin/compiletest" "--compile-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib" "--run-lib-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/lib/rustlib/x86_64-unknown-linux-gnu/lib" "--rustc-path" "/checkout/obj/build/x86_64-unknown-linux-gnu/stage2/bin/rustc" "--src-base" "/checkout/src/test/codegen" "--build-base" "/checkout/obj/build/x86_64-unknown-linux-gnu/test/codegen" "--stage-id" "stage2-x86_64-unknown-linux-gnu" "--mode" "codegen" "--target" "x86_64-unknown-linux-gnu" "--host" "x86_64-unknown-linux-gnu" "--llvm-filecheck" "/usr/lib/llvm-5.0/bin/FileCheck" "--host-rustcflags" "-Crpath -O -Zunstable-options " "--target-rustcflags" "-Crpath -O -Zunstable-options  -Lnative=/checkout/obj/build/x86_64-unknown-linux-gnu/native/rust-test-helpers" "--docck-python" "/usr/bin/python2.7" "--lldb-python" "/usr/bin/python2.7" "--gdb" "/usr/bin/gdb" "--quiet" "--llvm-version" "5.0.0\n" "--system-llvm" "--cc" "" "--cxx" "" "--cflags" "" "--llvm-components" "" "--llvm-cxxflags" "" "--adb-path" "adb" "--adb-test-dir" "/data/tmp/work" "--android-cross-path" "" "--color" "always"
[00:55:01] 
[00:55:01] 
[00:55:01] failed to run: /checkout/obj/build/bootstrap/debug/bootstrap test
[00:55:01] Build completed unsuccessfully in 0:10:20
[00:55:01] Build completed unsuccessfully in 0:10:20
[00:55:01] Makefile:58: recipe for target 'check' failed
[00:55:01] make: *** [check] Error 1

The command "stamp sh -x -c "$RUN_SCRIPT"" exited with 2.
travis_time:start:257f9421
$ date && (curl -fs --head https://google.com | grep ^Date: | sed 's/Date: //g' || true)

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@cramertj cramertj force-pushed the fix-generator-mir branch from 97903bf to 48ecb2e Compare July 11, 2018 23:03
kind: StatementKind::StorageDead(index)
});
// Drop the storage for both value and storage drops.
// Only temps and vars need their storage dead.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a check above, I don't think you need another here. You can keep an assert though, and have an unreachable!() in the _ => {} arm.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

// option. This file may not be copied, modified, or distributed
// except according to those terms.

// compile-flags: -Z identify_regions -Z emit-end-regions
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need these two lines? (cc @nikomatsakis @arielb1) I expect the MIR to be shorter and easier to read without them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done-- made it a bit shorter.

@eddyb
Copy link
Member

eddyb commented Jul 12, 2018

r=me with nits fixed

@cramertj cramertj force-pushed the fix-generator-mir branch from 48ecb2e to 9c15a66 Compare July 12, 2018 17:13
@cramertj
Copy link
Member Author

@bors r=eddyb

@bors
Copy link
Collaborator

bors commented Jul 12, 2018

📌 Commit 9c15a66 has been approved by eddyb

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 12, 2018
}

// END RUST SOURCE
// START rustc.main.mir_map.0.mir
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, what happens if you use the MIR after the first simplifycfg? There should be mir-opt examples around that to that. I'm hoping the distinction is not only visible, but much clearer. Right now there are a bunch of pointless blocks being created.

@bors
Copy link
Collaborator

bors commented Jul 13, 2018

⌛ Testing commit 9c15a66 with merge e92e9ce...

bors added a commit that referenced this pull request Jul 13, 2018
Ensure StorageDead is created even if variable initialization fails

Rebase and slight cleanup of #51109
Fixes #49232

r? @eddyb
@bors
Copy link
Collaborator

bors commented Jul 13, 2018

☀️ Test successful - status-appveyor, status-travis
Approved by: eddyb
Pushing e92e9ce to master...

@bors bors merged commit 9c15a66 into rust-lang:master Jul 13, 2018
@cramertj cramertj deleted the fix-generator-mir branch July 13, 2018 05:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants