diff --git a/compiler/rustc_mir_transform/src/remove_zsts.rs b/compiler/rustc_mir_transform/src/remove_zsts.rs index f0a1e08d2bc29..86706c5a7c7f1 100644 --- a/compiler/rustc_mir_transform/src/remove_zsts.rs +++ b/compiler/rustc_mir_transform/src/remove_zsts.rs @@ -110,21 +110,30 @@ impl<'tcx> MutVisitor<'tcx> for Replacer<'_, 'tcx> { } fn visit_statement(&mut self, statement: &mut Statement<'tcx>, loc: Location) { - if let StatementKind::Assign(box (place, _)) | StatementKind::Deinit(box place) = - statement.kind - { - let place_ty = place.ty(self.local_decls, self.tcx).ty; - if self.known_to_be_zst(place_ty) - && self.tcx.consider_optimizing(|| { - format!( - "RemoveZsts - Place: {:?} SourceInfo: {:?}", - place, statement.source_info - ) - }) - { - statement.make_nop(); + let place_for_ty = match statement.kind { + StatementKind::Assign(box (place, ref rvalue)) => { + rvalue.is_safe_to_remove().then_some(place) + } + StatementKind::Deinit(box place) + | StatementKind::SetDiscriminant { box place, variant_index: _ } + | StatementKind::AscribeUserType(box (place, _), _) + | StatementKind::Retag(_, box place) + | StatementKind::FakeRead(box (_, place)) => Some(place), + StatementKind::StorageLive(local) | StatementKind::StorageDead(local) => { + Some(local.into()) } + StatementKind::Coverage(_) | StatementKind::Intrinsic(_) | StatementKind::Nop => None, + }; + if let Some(place_for_ty) = place_for_ty + && let ty = place_for_ty.ty(self.local_decls, self.tcx).ty + && self.known_to_be_zst(ty) + && self.tcx.consider_optimizing(|| { + format!("RemoveZsts - Place: {:?} SourceInfo: {:?}", place_for_ty, statement.source_info) + }) + { + statement.make_nop(); + } else { + self.super_statement(statement, loc); } - self.super_statement(statement, loc); } } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff index f270ab8b69f0e..7e77c18d5758e 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.diff @@ -14,7 +14,6 @@ } bb1: { - StorageLive(_2); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL _2 = begin_panic::<&str>(const "explicit panic"); // scope 0 at $SRC_DIR/std/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/std/src/panic.rs:LL:COL diff --git a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff index 2d63101173719..ef9e33bbb062f 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.RemoveZsts.diff @@ -49,22 +49,28 @@ _3 = [move _4]; // scope 1 at $DIR/invalid_constant.rs:+13:24: +13:60 StorageDead(_4); // scope 1 at $DIR/invalid_constant.rs:+13:59: +13:60 StorageDead(_5); // scope 1 at $DIR/invalid_constant.rs:+13:60: +13:61 - StorageLive(_6); // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 - StorageLive(_7); // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 +- StorageLive(_6); // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 +- StorageLive(_7); // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:9: +20:31 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:35: +20:73 StorageLive(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 Deinit(_8); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 (_8.0: u32) = const 0_u32; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:65 - _7 = (_8.1: Empty); // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 - _6 = [move _7]; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 +- StorageDead(_7); // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 + nop; // scope 6 at $DIR/invalid_constant.rs:+20:44: +20:71 + nop; // scope 3 at $DIR/invalid_constant.rs:+20:34: +20:74 - StorageDead(_7); // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+20:73: +20:74 StorageDead(_8); // scope 3 at $DIR/invalid_constant.rs:+20:74: +20:75 - StorageLive(_9); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 +- StorageLive(_9); // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 - _0 = const (); // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 +- StorageDead(_9); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 +- StorageDead(_6); // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 ++ nop; // scope 5 at $DIR/invalid_constant.rs:+24:9: +24:22 + nop; // scope 0 at $DIR/invalid_constant.rs:+0:11: +27:2 - StorageDead(_9); // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 - StorageDead(_6); // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 ++ nop; // scope 5 at $DIR/invalid_constant.rs:+27:1: +27:2 ++ nop; // scope 3 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_3); // scope 1 at $DIR/invalid_constant.rs:+27:1: +27:2 StorageDead(_1); // scope 0 at $DIR/invalid_constant.rs:+27:1: +27:2 return; // scope 0 at $DIR/invalid_constant.rs:+27:2: +27:2 diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff index 488e772d0ea8b..ef0f8ca706143 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.ConstProp.diff @@ -7,7 +7,6 @@ let mut _2: ((), u8, u8); // in scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_66971.rs:+1:5: +1:23 StorageLive(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 Deinit(_2); // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 (_2.1: u8) = const 0_u8; // scope 0 at $DIR/issue_66971.rs:+1:12: +1:22 @@ -20,7 +19,6 @@ bb1: { StorageDead(_2); // scope 0 at $DIR/issue_66971.rs:+1:22: +1:23 - StorageDead(_1); // scope 0 at $DIR/issue_66971.rs:+1:23: +1:24 return; // scope 0 at $DIR/issue_66971.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff index cd53048597b82..f45b0eac82794 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.ConstProp.diff @@ -8,7 +8,6 @@ let mut _3: (u8, u8); // in scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 bb0: { - StorageLive(_1); // scope 0 at $DIR/issue_67019.rs:+1:5: +1:20 StorageLive(_2); // scope 0 at $DIR/issue_67019.rs:+1:10: +1:19 StorageLive(_3); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 Deinit(_3); // scope 0 at $DIR/issue_67019.rs:+1:11: +1:17 @@ -26,7 +25,6 @@ bb1: { StorageDead(_2); // scope 0 at $DIR/issue_67019.rs:+1:19: +1:20 - StorageDead(_1); // scope 0 at $DIR/issue_67019.rs:+1:20: +1:21 return; // scope 0 at $DIR/issue_67019.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff index d518eff04eba2..d118b02127b1a 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.diff @@ -13,7 +13,6 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+1:9: +1:10 _1 = const 1_u32; // scope 0 at $DIR/scalar_literal_propagation.rs:+1:13: +1:14 - StorageLive(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 StorageLive(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 - _3 = _1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:13: +2:14 - _2 = consume(move _3) -> bb1; // scope 1 at $DIR/scalar_literal_propagation.rs:+2:5: +2:15 @@ -26,7 +25,6 @@ bb1: { StorageDead(_3); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:14: +2:15 - StorageDead(_2); // scope 1 at $DIR/scalar_literal_propagation.rs:+2:15: +2:16 StorageDead(_1); // scope 0 at $DIR/scalar_literal_propagation.rs:+3:1: +3:2 return; // scope 0 at $DIR/scalar_literal_propagation.rs:+3:2: +3:2 } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff index e4c92b617c6a3..83af9841e0651 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.diff @@ -15,7 +15,6 @@ Deinit(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 (_1.0: u32) = const 1_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 (_1.1: u32) = const 2_u32; // scope 0 at $DIR/tuple_literal_propagation.rs:+1:13: +1:19 - StorageLive(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:5: +3:15 StorageLive(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 - _3 = _1; // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 + _3 = const (1_u32, 2_u32); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:13: +3:14 @@ -27,7 +26,6 @@ bb1: { StorageDead(_3); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:14: +3:15 - StorageDead(_2); // scope 1 at $DIR/tuple_literal_propagation.rs:+3:15: +3:16 StorageDead(_1); // scope 0 at $DIR/tuple_literal_propagation.rs:+4:1: +4:2 return; // scope 0 at $DIR/tuple_literal_propagation.rs:+4:2: +4:2 } diff --git a/tests/mir-opt/inline/asm_unwind.main.Inline.diff b/tests/mir-opt/inline/asm_unwind.main.Inline.diff index a4193290a9521..ed290063a9305 100644 --- a/tests/mir-opt/inline/asm_unwind.main.Inline.diff +++ b/tests/mir-opt/inline/asm_unwind.main.Inline.diff @@ -19,21 +19,21 @@ - // mir::Constant - // + span: $DIR/asm_unwind.rs:21:5: 21:8 - // + literal: Const { ty: fn() {foo}, val: Value() } -+ StorageLive(_2); // scope 1 at $DIR/asm_unwind.rs:15:9: 15:11 -+ asm!("", options(MAY_UNWIND)) -> [return: bb1, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 ++ StorageLive(_2); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 ++ asm!("", options(MAY_UNWIND)) -> [return: bb2, unwind: bb3]; // scope 3 at $DIR/asm_unwind.rs:16:14: 16:54 } bb1: { -+ drop(_2) -> bb2; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 -+ } -+ -+ bb2: { -+ StorageDead(_2); // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ StorageDead(_2); // scope 0 at $DIR/asm_unwind.rs:+1:5: +1:10 StorageDead(_1); // scope 0 at $DIR/asm_unwind.rs:+1:10: +1:11 _0 = const (); // scope 0 at $DIR/asm_unwind.rs:+0:15: +2:2 return; // scope 0 at $DIR/asm_unwind.rs:+2:2: +2:2 + } + ++ bb2: { ++ drop(_2) -> bb1; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 ++ } ++ + bb3 (cleanup): { + drop(_2) -> bb4; // scope 1 at $DIR/asm_unwind.rs:17:1: 17:2 + } diff --git a/tests/mir-opt/inline/cycle.g.Inline.diff b/tests/mir-opt/inline/cycle.g.Inline.diff index d1c9f2ff37945..20d313aecf588 100644 --- a/tests/mir-opt/inline/cycle.g.Inline.diff +++ b/tests/mir-opt/inline/cycle.g.Inline.diff @@ -25,7 +25,7 @@ - // mir::Constant // + span: $DIR/cycle.rs:12:7: 12:11 // + literal: Const { ty: fn() {main}, val: Value() } -+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 + StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 + _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 @@ -34,6 +34,7 @@ } bb1: { ++ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 + StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:12 StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:12: +1:13 _0 = const (); // scope 0 at $DIR/cycle.rs:+0:8: +2:2 @@ -51,7 +52,6 @@ + bb4: { + StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 } } diff --git a/tests/mir-opt/inline/cycle.main.Inline.diff b/tests/mir-opt/inline/cycle.main.Inline.diff index 03035c1e73f20..dacc5f4be9d7f 100644 --- a/tests/mir-opt/inline/cycle.main.Inline.diff +++ b/tests/mir-opt/inline/cycle.main.Inline.diff @@ -25,7 +25,7 @@ - // mir::Constant // + span: $DIR/cycle.rs:17:7: 17:8 // + literal: Const { ty: fn() {g}, val: Value() } -+ StorageLive(_3); // scope 1 at $DIR/cycle.rs:6:5: 6:8 ++ StorageLive(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 + StorageLive(_4); // scope 1 at $DIR/cycle.rs:6:5: 6:6 + _4 = &_2; // scope 1 at $DIR/cycle.rs:6:5: 6:6 + StorageLive(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 @@ -34,6 +34,7 @@ } bb1: { ++ StorageDead(_3); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 + StorageDead(_2); // scope 0 at $DIR/cycle.rs:+1:5: +1:9 StorageDead(_1); // scope 0 at $DIR/cycle.rs:+1:9: +1:10 _0 = const (); // scope 0 at $DIR/cycle.rs:+0:11: +2:2 @@ -51,7 +52,6 @@ + bb4: { + StorageDead(_5); // scope 1 at $DIR/cycle.rs:6:5: 6:8 + StorageDead(_4); // scope 1 at $DIR/cycle.rs:6:7: 6:8 -+ StorageDead(_3); // scope 1 at $DIR/cycle.rs:6:8: 6:9 + drop(_2) -> bb1; // scope 1 at $DIR/cycle.rs:7:1: 7:2 } } diff --git a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff index 7fd62be7ab9c3..dd1f253cb47dd 100644 --- a/tests/mir-opt/inline/exponential_runtime.main.Inline.diff +++ b/tests/mir-opt/inline/exponential_runtime.main.Inline.diff @@ -18,9 +18,13 @@ bb0: { StorageLive(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 - _1 = <() as G>::call() -> bb1; // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 -+ StorageLive(_2); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 -+ StorageLive(_5); // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 -+ _5 = <() as E>::call() -> bb3; // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 ++ StorageLive(_2); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_3); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_4); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageLive(_5); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ StorageLive(_6); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ StorageLive(_7); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ _5 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:61:9: 61:25 // mir::Constant - // + span: $DIR/exponential_runtime.rs:86:5: 86:20 - // + literal: Const { ty: fn() {<() as G>::call}, val: Value() } @@ -29,47 +33,43 @@ } bb1: { -+ StorageDead(_3); // scope 1 at $DIR/exponential_runtime.rs:74:25: 74:26 -+ StorageLive(_4); // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ _4 = <() as F>::call() -> bb2; // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 -+ // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:75:9: 75:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } -+ } -+ -+ bb2: { -+ StorageDead(_4); // scope 1 at $DIR/exponential_runtime.rs:75:25: 75:26 ++ StorageDead(_4); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageDead(_3); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 ++ StorageDead(_2); // scope 0 at $DIR/exponential_runtime.rs:+1:5: +1:22 StorageDead(_1); // scope 0 at $DIR/exponential_runtime.rs:+1:22: +1:23 _0 = const (); // scope 0 at $DIR/exponential_runtime.rs:+0:11: +2:2 return; // scope 0 at $DIR/exponential_runtime.rs:+2:2: +2:2 + } + ++ bb2: { ++ StorageDead(_7); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ StorageDead(_6); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ StorageDead(_5); // scope 1 at $DIR/exponential_runtime.rs:73:9: 73:25 ++ _3 = <() as F>::call() -> bb3; // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ // mir::Constant ++ // + span: $DIR/exponential_runtime.rs:74:9: 74:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } ++ } ++ + bb3: { -+ StorageDead(_5); // scope 2 at $DIR/exponential_runtime.rs:61:25: 61:26 -+ StorageLive(_6); // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 -+ _6 = <() as E>::call() -> bb4; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 ++ _4 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:75:9: 75:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 -+ // + literal: Const { ty: fn() {<() as E>::call}, val: Value() } ++ // + span: $DIR/exponential_runtime.rs:75:9: 75:23 ++ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } + } + + bb4: { -+ StorageDead(_6); // scope 2 at $DIR/exponential_runtime.rs:62:25: 62:26 -+ StorageLive(_7); // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 -+ _7 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 ++ _6 = <() as E>::call() -> bb5; // scope 2 at $DIR/exponential_runtime.rs:62:9: 62:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:63:9: 63:23 ++ // + span: $DIR/exponential_runtime.rs:62:9: 62:23 + // + literal: Const { ty: fn() {<() as E>::call}, val: Value() } + } + + bb5: { -+ StorageDead(_7); // scope 2 at $DIR/exponential_runtime.rs:63:25: 63:26 -+ StorageDead(_2); // scope 1 at $DIR/exponential_runtime.rs:73:25: 73:26 -+ StorageLive(_3); // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 -+ _3 = <() as F>::call() -> bb1; // scope 1 at $DIR/exponential_runtime.rs:74:9: 74:25 ++ _7 = <() as E>::call() -> bb2; // scope 2 at $DIR/exponential_runtime.rs:63:9: 63:25 + // mir::Constant -+ // + span: $DIR/exponential_runtime.rs:74:9: 74:23 -+ // + literal: Const { ty: fn() {<() as F>::call}, val: Value() } ++ // + span: $DIR/exponential_runtime.rs:63:9: 63:23 ++ // + literal: Const { ty: fn() {<() as E>::call}, val: Value() } } } diff --git a/tests/mir-opt/inline/inline_cycle.two.Inline.diff b/tests/mir-opt/inline/inline_cycle.two.Inline.diff index 5c395a3b24c65..0215b3d93f9e3 100644 --- a/tests/mir-opt/inline/inline_cycle.two.Inline.diff +++ b/tests/mir-opt/inline/inline_cycle.two.Inline.diff @@ -24,7 +24,7 @@ - // mir::Constant // + span: $DIR/inline_cycle.rs:49:10: 49:11 // + literal: Const { ty: fn() {f}, val: Value() } -+ StorageLive(_3); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 ++ StorageLive(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + StorageLive(_4); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 + _4 = const (); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 + _3 = move _2() -> bb1; // scope 2 at $SRC_DIR/core/src/ops/function.rs:LL:COL @@ -32,7 +32,7 @@ bb1: { + StorageDead(_4); // scope 1 at $DIR/inline_cycle.rs:54:5: 54:8 -+ StorageDead(_3); // scope 1 at $DIR/inline_cycle.rs:54:8: 54:9 ++ StorageDead(_3); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 + StorageDead(_2); // scope 0 at $DIR/inline_cycle.rs:+1:5: +1:12 StorageDead(_1); // scope 0 at $DIR/inline_cycle.rs:+1:12: +1:13 _0 = const (); // scope 0 at $DIR/inline_cycle.rs:+0:10: +2:2 diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.diff index b787a19f4b21c..4f22ad43700ac 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.diff @@ -34,7 +34,7 @@ bb2: { StorageLive(_6); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 - _6 = panic(); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 -+ StorageLive(_7); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL ++ StorageLive(_7); // scope 0 at $DIR/inline_diverging.rs:+4:9: +4:16 + _7 = begin_panic::<&str>(const "explicit panic"); // scope 1 at $SRC_DIR/std/src/panic.rs:LL:COL // mir::Constant - // + span: $DIR/inline_diverging.rs:16:9: 16:14 diff --git a/tests/mir-opt/inline/inline_options.main.Inline.after.mir b/tests/mir-opt/inline/inline_options.main.Inline.after.mir index 1c590be945c9e..abe26bd8ce363 100644 --- a/tests/mir-opt/inline/inline_options.main.Inline.after.mir +++ b/tests/mir-opt/inline/inline_options.main.Inline.after.mir @@ -21,35 +21,35 @@ fn main() -> () { bb1: { StorageDead(_1); // scope 0 at $DIR/inline_options.rs:+1:18: +1:19 StorageLive(_2); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 - StorageLive(_3); // scope 1 at $DIR/inline_options.rs:16:23: 16:26 - _3 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:16:23: 16:26 + StorageLive(_3); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageLive(_4); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageLive(_5); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + _3 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:16:23: 16:26 // mir::Constant // + span: $DIR/inline_options.rs:16:23: 16:24 // + literal: Const { ty: fn() {g}, val: Value() } } bb2: { - StorageDead(_3); // scope 1 at $DIR/inline_options.rs:16:26: 16:27 - StorageLive(_4); // scope 1 at $DIR/inline_options.rs:16:28: 16:31 - _4 = g() -> bb3; // scope 1 at $DIR/inline_options.rs:16:28: 16:31 - // mir::Constant - // + span: $DIR/inline_options.rs:16:28: 16:29 - // + literal: Const { ty: fn() {g}, val: Value() } + StorageDead(_5); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageDead(_4); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageDead(_3); // scope 0 at $DIR/inline_options.rs:+2:5: +2:21 + StorageDead(_2); // scope 0 at $DIR/inline_options.rs:+2:21: +2:22 + _0 = const (); // scope 0 at $DIR/inline_options.rs:+0:11: +3:2 + return; // scope 0 at $DIR/inline_options.rs:+3:2: +3:2 } bb3: { - StorageDead(_4); // scope 1 at $DIR/inline_options.rs:16:31: 16:32 - StorageLive(_5); // scope 1 at $DIR/inline_options.rs:16:33: 16:36 - _5 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:16:33: 16:36 + _4 = g() -> bb4; // scope 1 at $DIR/inline_options.rs:16:28: 16:31 // mir::Constant - // + span: $DIR/inline_options.rs:16:33: 16:34 + // + span: $DIR/inline_options.rs:16:28: 16:29 // + literal: Const { ty: fn() {g}, val: Value() } } bb4: { - StorageDead(_5); // scope 1 at $DIR/inline_options.rs:16:36: 16:37 - StorageDead(_2); // scope 0 at $DIR/inline_options.rs:+2:21: +2:22 - _0 = const (); // scope 0 at $DIR/inline_options.rs:+0:11: +3:2 - return; // scope 0 at $DIR/inline_options.rs:+3:2: +3:2 + _5 = g() -> bb2; // scope 1 at $DIR/inline_options.rs:16:33: 16:36 + // mir::Constant + // + span: $DIR/inline_options.rs:16:33: 16:34 + // + literal: Const { ty: fn() {g}, val: Value() } } } diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff index c24543daeacb7..5721237d48536 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.diff @@ -56,7 +56,6 @@ } bb1: { - StorageLive(_15); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL _15 = core::panicking::panic(const "internal error: entered unreachable code"); // scope 1 at $SRC_DIR/core/src/panic.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/panic.rs:LL:COL diff --git a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index c17d221f86a84..9df508cc71fa0 100644 --- a/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/tests/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -70,7 +70,6 @@ fn num_to_digit(_1: char) -> u32 { } bb6: { - StorageLive(_8); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL diff --git a/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir b/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir index f6d8bdd742289..adfc6b2731c1a 100644 --- a/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir +++ b/tests/mir-opt/lower_intrinsics_e2e.f_u64.PreCodegen.after.mir @@ -12,7 +12,6 @@ fn f_u64() -> () { bb0: { StorageLive(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 - StorageLive(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 _2 = f_non_zst::(const 0_u64) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:9: 23:21 // mir::Constant // + span: $DIR/lower_intrinsics_e2e.rs:23:9: 23:18 @@ -20,7 +19,6 @@ fn f_u64() -> () { } bb1: { - StorageDead(_2); // scope 1 at $DIR/lower_intrinsics_e2e.rs:23:21: 23:22 StorageDead(_1); // scope 0 at $DIR/lower_intrinsics_e2e.rs:+1:5: +1:21 return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir b/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir index 9d6e71ab78a9a..302ca09aac4b2 100644 --- a/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir +++ b/tests/mir-opt/lower_intrinsics_e2e.f_unit.PreCodegen.after.mir @@ -10,7 +10,6 @@ fn f_unit() -> () { } bb0: { - StorageLive(_1); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 _1 = f_zst::<()>(const ()) -> bb1; // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:9: 21:17 // mir::Constant // + span: $DIR/lower_intrinsics_e2e.rs:21:9: 21:14 @@ -18,7 +17,6 @@ fn f_unit() -> () { } bb1: { - StorageDead(_1); // scope 1 at $DIR/lower_intrinsics_e2e.rs:21:17: 21:18 return; // scope 0 at $DIR/lower_intrinsics_e2e.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff index 07e4dd4181324..7713649c5b96b 100644 --- a/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.cannot_opt_generic.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -23,7 +23,7 @@ bb2: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:32: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff index e809ca4e90066..533db4051ef1f 100644 --- a/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.dont_opt.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = move _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 drop(_3) -> [return: bb2, unwind: bb1]; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -23,7 +23,7 @@ bb2: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 + nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:27: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff index 087f76dbda83b..04a2d54e9a19b 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 - drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -19,7 +19,7 @@ - - bb1: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 - nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:17: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff index 933d6895f4594..782d0c6c5f267 100644 --- a/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff +++ b/tests/mir-opt/remove_unneeded_drops.opt_generic_copy.RemoveUnneededDrops.diff @@ -11,7 +11,7 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:5: +1:12 StorageLive(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 _3 = _1; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:10: +1:11 - drop(_3) -> bb1; // scope 1 at $SRC_DIR/core/src/mem/mod.rs:LL:COL @@ -19,7 +19,7 @@ - - bb1: { StorageDead(_3); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:11: +1:12 - StorageDead(_2); // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 +- nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+1:12: +1:13 - nop; // scope 0 at $DIR/remove_unneeded_drops.rs:+0:36: +2:2 return; // scope 0 at $DIR/remove_unneeded_drops.rs:+2:2: +2:2 } diff --git a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff index 169b7b1054b47..18b612faaacaa 100644 --- a/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff +++ b/tests/mir-opt/remove_zsts.get_union.RemoveZsts.diff @@ -6,13 +6,15 @@ let mut _1: (); // in scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 bb0: { - StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 +- StorageLive(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 - Deinit(_1); // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 ++ nop; // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 + nop; // scope 0 at $DIR/remove_zsts.rs:+1:14: +1:16 Deinit(_0); // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 - (_0.0: ()) = move _1; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 +- StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 + nop; // scope 0 at $DIR/remove_zsts.rs:+1:5: +1:18 - StorageDead(_1); // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 ++ nop; // scope 0 at $DIR/remove_zsts.rs:+1:17: +1:18 return; // scope 0 at $DIR/remove_zsts.rs:+2:2: +2:2 } } diff --git a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff index f9e22866bee99..ac79e72701344 100644 --- a/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff +++ b/tests/mir-opt/simplify_if.main.SimplifyConstCondition-after-const-prop.diff @@ -14,7 +14,6 @@ } bb1: { - StorageLive(_2); // scope 0 at $DIR/simplify_if.rs:+2:9: +2:15 _2 = noop() -> bb2; // scope 0 at $DIR/simplify_if.rs:+2:9: +2:15 // mir::Constant // + span: $DIR/simplify_if.rs:7:9: 7:13 @@ -22,7 +21,6 @@ } bb2: { - StorageDead(_2); // scope 0 at $DIR/simplify_if.rs:+2:15: +2:16 goto -> bb4; // scope 0 at $DIR/simplify_if.rs:+1:5: +3:6 }