diff --git a/compiler/rustc_middle/src/ty/rvalue_scopes.rs b/compiler/rustc_middle/src/ty/rvalue_scopes.rs index e79b79a25aec9..8e81cac722a3f 100644 --- a/compiler/rustc_middle/src/ty/rvalue_scopes.rs +++ b/compiler/rustc_middle/src/ty/rvalue_scopes.rs @@ -38,6 +38,10 @@ impl RvalueScopes { debug!("temporary_scope({expr_id:?}) = {id:?} [enclosing]"); return Some(id); } + ScopeData::IfThen => { + debug!("temporary_scope({expr_id:?}) = {p:?} [enclosing]"); + return Some(p); + } _ => id = p, } } diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff index b4dccecc67265..4e6abb99841a6 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff @@ -32,10 +32,12 @@ bb2: { _2 = const 42_i32; // scope 2 at $DIR/discriminant.rs:+1:47: +1:49 + StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:50: +1:51 goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 } bb3: { + StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:50: +1:51 _2 = const 10_i32; // scope 0 at $DIR/discriminant.rs:+1:59: +1:61 goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 } @@ -43,7 +45,6 @@ bb4: { _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/discriminant.rs:+1:13: +1:68 StorageDead(_2); // scope 0 at $DIR/discriminant.rs:+1:67: +1:68 - StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:68: +1:69 _0 = const (); // scope 0 at $DIR/discriminant.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/discriminant.rs:+2:1: +2:2 return; // scope 0 at $DIR/discriminant.rs:+2:2: +2:2 diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff index b4dccecc67265..4e6abb99841a6 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff @@ -32,10 +32,12 @@ bb2: { _2 = const 42_i32; // scope 2 at $DIR/discriminant.rs:+1:47: +1:49 + StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:50: +1:51 goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 } bb3: { + StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:50: +1:51 _2 = const 10_i32; // scope 0 at $DIR/discriminant.rs:+1:59: +1:61 goto -> bb4; // scope 0 at $DIR/discriminant.rs:+1:13: +1:64 } @@ -43,7 +45,6 @@ bb4: { _1 = Add(move _2, const 0_i32); // scope 0 at $DIR/discriminant.rs:+1:13: +1:68 StorageDead(_2); // scope 0 at $DIR/discriminant.rs:+1:67: +1:68 - StorageDead(_3); // scope 0 at $DIR/discriminant.rs:+1:68: +1:69 _0 = const (); // scope 0 at $DIR/discriminant.rs:+0:11: +2:2 StorageDead(_1); // scope 0 at $DIR/discriminant.rs:+2:1: +2:2 return; // scope 0 at $DIR/discriminant.rs:+2:2: +2:2 diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff index df9f8dcf1a407..054b087823cea 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.diff @@ -100,10 +100,12 @@ StorageDead(_14); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 StorageDead(_13); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 StorageDead(_11); // scope 3 at $DIR/funky_arms.rs:+15:86: +15:87 + StorageDead(_7); // scope 2 at $DIR/funky_arms.rs:+16:5: +16:6 goto -> bb10; // scope 2 at $DIR/funky_arms.rs:+13:5: +18:6 } bb8: { + StorageDead(_7); // scope 2 at $DIR/funky_arms.rs:+16:5: +16:6 StorageLive(_18); // scope 2 at $DIR/funky_arms.rs:+17:46: +17:49 _18 = &mut (*_1); // scope 2 at $DIR/funky_arms.rs:+17:46: +17:49 StorageLive(_20); // scope 2 at $DIR/funky_arms.rs:+17:56: +17:60 @@ -123,7 +125,6 @@ bb10: { StorageDead(_6); // scope 1 at $DIR/funky_arms.rs:+19:1: +19:2 StorageDead(_4); // scope 0 at $DIR/funky_arms.rs:+19:1: +19:2 - StorageDead(_7); // scope 0 at $DIR/funky_arms.rs:+19:1: +19:2 return; // scope 0 at $DIR/funky_arms.rs:+19:2: +19:2 } } diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff index f888c622d9085..4c3e8b7c29c03 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.diff @@ -47,15 +47,24 @@ - StorageDead(_8); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+2:19: +2:20 - StorageDead(_7); // scope 1 at $DIR/simplify_locals_fixedpoint.rs:+4:9: +4:10 StorageDead(_6); // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6 - goto -> bb3; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:5: +5:6 + drop(_1) -> bb5; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6 } bb3: { - drop(_1) -> bb4; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:1: +6:2 + drop(_1) -> bb4; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6 } bb4: { - StorageDead(_1); // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:1: +6:2 + StorageDead(_1); // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6 + goto -> bb6; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:5: +5:6 + } + + bb5: { + StorageDead(_1); // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+5:5: +5:6 + goto -> bb6; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+1:5: +5:6 + } + + bb6: { return; // scope 0 at $DIR/simplify_locals_fixedpoint.rs:+6:2: +6:2 } } diff --git a/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff b/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff index a5488c1ec7bfe..7943d32ed604c 100644 --- a/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff +++ b/tests/mir-opt/sroa.enums.ScalarReplacementOfAggregates.diff @@ -29,16 +29,17 @@ _5 = ((_2 as Some).0: usize); // scope 1 at $DIR/sroa.rs:+1:17: +1:18 _0 = _5; // scope 1 at $DIR/sroa.rs:+1:32: +1:33 StorageDead(_5); // scope 0 at $DIR/sroa.rs:+1:34: +1:35 + StorageDead(_2); // scope 0 at $DIR/sroa.rs:+1:34: +1:35 goto -> bb3; // scope 0 at $DIR/sroa.rs:+1:5: +1:46 } bb2: { + StorageDead(_2); // scope 0 at $DIR/sroa.rs:+1:34: +1:35 _0 = const 0_usize; // scope 0 at $DIR/sroa.rs:+1:43: +1:44 goto -> bb3; // scope 0 at $DIR/sroa.rs:+1:5: +1:46 } bb3: { - StorageDead(_2); // scope 0 at $DIR/sroa.rs:+2:1: +2:2 return; // scope 0 at $DIR/sroa.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/unreachable.main.UnreachablePropagation.diff b/tests/mir-opt/unreachable.main.UnreachablePropagation.diff index 848bff1d4920c..a0df9097b5552 100644 --- a/tests/mir-opt/unreachable.main.UnreachablePropagation.diff +++ b/tests/mir-opt/unreachable.main.UnreachablePropagation.diff @@ -62,8 +62,8 @@ - } - - bb6: { + StorageDead(_1); // scope 0 at $DIR/unreachable.rs:+11:5: +11:6 _0 = const (); // scope 0 at $DIR/unreachable.rs:+11:6: +11:6 - StorageDead(_1); // scope 0 at $DIR/unreachable.rs:+12:1: +12:2 return; // scope 0 at $DIR/unreachable.rs:+12:2: +12:2 } } diff --git a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff index fb778470e5323..b1c0d37e934bb 100644 --- a/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff +++ b/tests/mir-opt/unreachable_diverging.main.UnreachablePropagation.diff @@ -62,9 +62,9 @@ } bb6: { + StorageDead(_2); // scope 1 at $DIR/unreachable_diverging.rs:+7:5: +7:6 _0 = const (); // scope 1 at $DIR/unreachable_diverging.rs:+7:6: +7:6 StorageDead(_1); // scope 0 at $DIR/unreachable_diverging.rs:+8:1: +8:2 - StorageDead(_2); // scope 0 at $DIR/unreachable_diverging.rs:+8:1: +8:2 return; // scope 0 at $DIR/unreachable_diverging.rs:+8:2: +8:2 } } diff --git a/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff b/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff index bb1de59d4a73f..3ab0823f8578c 100644 --- a/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff +++ b/tests/mir-opt/while_let_loops.change_loop_body.ConstProp.diff @@ -30,15 +30,16 @@ bb2: { _1 = const 1_i32; // scope 2 at $DIR/while_let_loops.rs:+3:9: +3:15 - goto -> bb4; // scope 2 at $DIR/while_let_loops.rs:+4:9: +4:14 + StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 + goto -> bb4; // scope 1 at no-location } bb3: { + StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 goto -> bb4; // scope 1 at no-location } bb4: { - StorageDead(_2); // scope 1 at $DIR/while_let_loops.rs:+5:5: +5:6 StorageDead(_1); // scope 0 at $DIR/while_let_loops.rs:+6:1: +6:2 return; // scope 0 at $DIR/while_let_loops.rs:+6:2: +6:2 } diff --git a/tests/ui/drop/drop_order.rs b/tests/ui/drop/drop_order.rs index 5ce1fd54a9e62..0666326ccf9ca 100644 --- a/tests/ui/drop/drop_order.rs +++ b/tests/ui/drop/drop_order.rs @@ -55,10 +55,10 @@ impl DropOrderCollector { } fn if_let(&self) { - if let None = self.option_loud_drop(2) { + if let None = self.option_loud_drop(1) { unreachable!(); } else { - self.print(1); + self.print(2); } if let Some(_) = self.option_loud_drop(4) { @@ -197,10 +197,10 @@ impl DropOrderCollector { // take the "else" branch if self.option_loud_drop(5).is_some() // 1 && self.option_loud_drop(6).is_some() // 2 - && let None = self.option_loud_drop(8) { // 4 + && let None = self.option_loud_drop(7) { // 3 unreachable!(); } else { - self.print(7); // 3 + self.print(8); // 4 } // let exprs interspersed diff --git a/tests/ui/mir/mir_let_chains_drop_order.rs b/tests/ui/mir/mir_let_chains_drop_order.rs index 6471553e93fd1..8128d38ac8b6c 100644 --- a/tests/ui/mir/mir_let_chains_drop_order.rs +++ b/tests/ui/mir/mir_let_chains_drop_order.rs @@ -57,7 +57,7 @@ fn main() { d(10, None) }, ); - assert_eq!(get(), vec![8, 7, 1, 3, 2]); + assert_eq!(get(), vec![3, 2, 8, 7, 1]); } assert_eq!(get(), vec![0, 4, 6, 9, 5]); @@ -89,5 +89,5 @@ fn main() { panic::panic_any(InjectedFailure) ); }); - assert_eq!(get(), vec![20, 17, 15, 11, 19, 18, 16, 12, 14, 13]); + assert_eq!(get(), vec![14, 13, 19, 18, 20, 17, 15, 11, 16, 12]); } diff --git a/tests/ui/nll/issue-54556-niconii.rs b/tests/ui/nll/issue-54556-niconii.rs index cae389e8ccb52..8e8759c674d39 100644 --- a/tests/ui/nll/issue-54556-niconii.rs +++ b/tests/ui/nll/issue-54556-niconii.rs @@ -1,3 +1,4 @@ +// check-pass // This is a reduction of a concrete test illustrating a case that was // annoying to Rust developer niconii (see comment thread on #21114). // @@ -19,7 +20,7 @@ impl Mutex { fn main() { let counter = Mutex; - if let Ok(_) = counter.lock() { } //~ ERROR does not live long enough + if let Ok(_) = counter.lock() { } // With this code as written, the dynamic semantics here implies // that `Mutex::drop` for `counter` runs *before* diff --git a/tests/ui/nll/issue-54556-niconii.stderr b/tests/ui/nll/issue-54556-niconii.stderr deleted file mode 100644 index d41d462f2bcb0..0000000000000 --- a/tests/ui/nll/issue-54556-niconii.stderr +++ /dev/null @@ -1,26 +0,0 @@ -error[E0597]: `counter` does not live long enough - --> $DIR/issue-54556-niconii.rs:22:20 - | -LL | let counter = Mutex; - | ------- binding `counter` declared here -LL | -LL | if let Ok(_) = counter.lock() { } - | ^^^^^^^^^^^^^^ - | | - | borrowed value does not live long enough - | a temporary with access to the borrow is created here ... -... -LL | } - | - - | | - | `counter` dropped here while still borrowed - | ... and the borrow might be used here, when that temporary is dropped and runs the destructor for type `Result, ()>` - | -help: consider adding semicolon after the expression so its temporaries are dropped sooner, before the local variables declared by the block are dropped - | -LL | if let Ok(_) = counter.lock() { }; - | + - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0597`.