diff options
31 files changed, 459 insertions, 409 deletions
diff --git a/compiler/rustc_mir_build/src/build/matches/mod.rs b/compiler/rustc_mir_build/src/build/matches/mod.rs index 3c450740712..5ec216cea61 100644 --- a/compiler/rustc_mir_build/src/build/matches/mod.rs +++ b/compiler/rustc_mir_build/src/build/matches/mod.rs @@ -64,6 +64,43 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { rhs_then_block.unit() } + ExprKind::LogicalOp { op: LogicalOp::Or, lhs, rhs } => { + let local_scope = this.local_scope(); + let (lhs_success_block, failure_block) = + this.in_if_then_scope(local_scope, expr_span, |this| { + this.then_else_break( + block, + &this.thir[lhs], + temp_scope_override, + local_scope, + variable_source_info, + ) + }); + let rhs_success_block = unpack!(this.then_else_break( + failure_block, + &this.thir[rhs], + temp_scope_override, + break_scope, + variable_source_info, + )); + this.cfg.goto(lhs_success_block, variable_source_info, rhs_success_block); + rhs_success_block.unit() + } + ExprKind::Unary { op: UnOp::Not, arg } => { + let local_scope = this.local_scope(); + let (success_block, failure_block) = + this.in_if_then_scope(local_scope, expr_span, |this| { + this.then_else_break( + block, + &this.thir[arg], + temp_scope_override, + local_scope, + variable_source_info, + ) + }); + this.break_for_else(success_block, break_scope, variable_source_info); + failure_block.unit() + } ExprKind::Scope { region_scope, lint_level, value } => { let region_scope = (region_scope, this.source_info(expr_span)); this.in_scope(region_scope, lint_level, |this| { @@ -76,6 +113,13 @@ impl<'a, 'tcx> Builder<'a, 'tcx> { ) }) } + ExprKind::Use { source } => this.then_else_break( + block, + &this.thir[source], + temp_scope_override, + break_scope, + variable_source_info, + ), ExprKind::Let { expr, ref pat } => this.lower_let_expr( block, &this.thir[expr], diff --git a/tests/mir-opt/bool_compare.opt1.InstSimplify.diff b/tests/mir-opt/bool_compare.opt1.InstSimplify.diff index 8d0011d5067..657c11516a1 100644 --- a/tests/mir-opt/bool_compare.opt1.InstSimplify.diff +++ b/tests/mir-opt/bool_compare.opt1.InstSimplify.diff @@ -13,16 +13,17 @@ _3 = _1; - _2 = Ne(move _3, const true); + _2 = Not(move _3); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/bool_compare.opt2.InstSimplify.diff b/tests/mir-opt/bool_compare.opt2.InstSimplify.diff index 35f1068709b..bc8be62bd49 100644 --- a/tests/mir-opt/bool_compare.opt2.InstSimplify.diff +++ b/tests/mir-opt/bool_compare.opt2.InstSimplify.diff @@ -13,16 +13,17 @@ _3 = _1; - _2 = Ne(const true, move _3); + _2 = Not(move _3); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/bool_compare.opt3.InstSimplify.diff b/tests/mir-opt/bool_compare.opt3.InstSimplify.diff index ab15c30ca11..034d5e44013 100644 --- a/tests/mir-opt/bool_compare.opt3.InstSimplify.diff +++ b/tests/mir-opt/bool_compare.opt3.InstSimplify.diff @@ -13,16 +13,17 @@ _3 = _1; - _2 = Eq(move _3, const false); + _2 = Not(move _3); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/bool_compare.opt4.InstSimplify.diff b/tests/mir-opt/bool_compare.opt4.InstSimplify.diff index 40fd1cfe112..d3096da6c5a 100644 --- a/tests/mir-opt/bool_compare.opt4.InstSimplify.diff +++ b/tests/mir-opt/bool_compare.opt4.InstSimplify.diff @@ -13,16 +13,17 @@ _3 = _1; - _2 = Eq(const false, move _3); + _2 = Not(move _3); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir index 1eac8e6acb5..096aaec4a38 100644 --- a/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir +++ b/tests/mir-opt/building/logical_or_in_conditional.test_complex.built.after.mir @@ -7,22 +7,19 @@ fn test_complex() -> () { let mut _3: isize; let mut _4: bool; let mut _5: bool; - let mut _6: bool; - let mut _7: bool; - let mut _8: u8; - let mut _9: Droppy; - let mut _10: bool; - let mut _11: u8; - let mut _12: Droppy; - let mut _13: bool; - let mut _14: bool; - let mut _15: E; - let mut _16: isize; + let mut _6: u8; + let mut _7: Droppy; + let mut _8: bool; + let mut _9: u8; + let mut _10: Droppy; + let mut _11: bool; + let mut _12: E; + let mut _13: isize; bb0: { StorageLive(_1); StorageLive(_2); - _2 = E::f() -> [return: bb1, unwind: bb27]; + _2 = E::f() -> [return: bb1, unwind: bb31]; } bb1: { @@ -36,145 +33,154 @@ fn test_complex() -> () { } bb3: { - goto -> bb16; + goto -> bb19; } bb4: { StorageLive(_4); - StorageLive(_5); - StorageLive(_6); - _6 = always_true() -> [return: bb11, unwind: bb27]; + _4 = always_true() -> [return: bb5, unwind: bb31]; } bb5: { - _4 = const true; - goto -> bb7; + switchInt(move _4) -> [0: bb7, otherwise: bb6]; } bb6: { - StorageLive(_10); - StorageLive(_11); - StorageLive(_12); - _12 = Droppy(const 1_u8); - _11 = (_12.0: u8); - _10 = Gt(move _11, const 1_u8); - drop(_12) -> [return: bb13, unwind: bb27]; + StorageLive(_5); + StorageLive(_6); + StorageLive(_7); + _7 = Droppy(const 0_u8); + _6 = (_7.0: u8); + _5 = Gt(move _6, const 0_u8); + switchInt(move _5) -> [0: bb9, otherwise: bb8]; } bb7: { - StorageDead(_10); - StorageDead(_5); - switchInt(move _4) -> [0: bb15, otherwise: bb14]; + goto -> bb13; } bb8: { - _5 = const false; - goto -> bb10; + drop(_7) -> [return: bb10, unwind: bb31]; } bb9: { - StorageLive(_7); - StorageLive(_8); - StorageLive(_9); - _9 = Droppy(const 0_u8); - _8 = (_9.0: u8); - _7 = Gt(move _8, const 0_u8); - drop(_9) -> [return: bb12, unwind: bb27]; + goto -> bb11; } bb10: { StorageDead(_7); StorageDead(_6); - switchInt(move _5) -> [0: bb6, otherwise: bb5]; + goto -> bb16; } bb11: { - switchInt(move _6) -> [0: bb8, otherwise: bb9]; + drop(_7) -> [return: bb12, unwind: bb31]; } bb12: { - StorageDead(_9); - StorageDead(_8); - _5 = move _7; - goto -> bb10; + StorageDead(_7); + StorageDead(_6); + goto -> bb13; } bb13: { - StorageDead(_12); - StorageDead(_11); - _4 = move _10; - goto -> bb7; + StorageLive(_8); + StorageLive(_9); + StorageLive(_10); + _10 = Droppy(const 1_u8); + _9 = (_10.0: u8); + _8 = Gt(move _9, const 1_u8); + switchInt(move _8) -> [0: bb15, otherwise: bb14]; } bb14: { - _1 = const (); - goto -> bb17; + drop(_10) -> [return: bb16, unwind: bb31]; } bb15: { - goto -> bb16; + goto -> bb17; } bb16: { + StorageDead(_10); + StorageDead(_9); _1 = const (); - goto -> bb17; + goto -> bb20; } bb17: { - StorageDead(_4); - StorageDead(_2); - StorageDead(_1); - StorageLive(_13); - StorageLive(_14); - _14 = always_true() -> [return: bb18, unwind: bb27]; + drop(_10) -> [return: bb18, unwind: bb31]; } bb18: { - _13 = Not(move _14); - StorageDead(_14); - switchInt(move _13) -> [0: bb20, otherwise: bb19]; + StorageDead(_10); + StorageDead(_9); + goto -> bb19; } bb19: { - StorageLive(_15); - _15 = E::f() -> [return: bb21, unwind: bb27]; + _1 = const (); + goto -> bb20; } bb20: { - goto -> bb25; + StorageDead(_8); + StorageDead(_5); + StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + StorageLive(_11); + _11 = always_true() -> [return: bb21, unwind: bb31]; } bb21: { - FakeRead(ForMatchedPlace(None), _15); - _16 = discriminant(_15); - switchInt(move _16) -> [1: bb23, otherwise: bb22]; + switchInt(move _11) -> [0: bb23, otherwise: bb22]; } bb22: { - goto -> bb25; + goto -> bb29; } bb23: { - falseEdge -> [real: bb24, imaginary: bb22]; + goto -> bb24; } bb24: { - _0 = const (); - goto -> bb26; + StorageLive(_12); + _12 = E::f() -> [return: bb25, unwind: bb31]; } bb25: { - _0 = const (); - goto -> bb26; + FakeRead(ForMatchedPlace(None), _12); + _13 = discriminant(_12); + switchInt(move _13) -> [1: bb27, otherwise: bb26]; } bb26: { - StorageDead(_13); - StorageDead(_15); + goto -> bb29; + } + + bb27: { + falseEdge -> [real: bb28, imaginary: bb26]; + } + + bb28: { + _0 = const (); + goto -> bb30; + } + + bb29: { + _0 = const (); + goto -> bb30; + } + + bb30: { + StorageDead(_11); + StorageDead(_12); return; } - bb27 (cleanup): { + bb31 (cleanup): { resume; } } diff --git a/tests/mir-opt/building/logical_or_in_conditional.test_or.built.after.mir b/tests/mir-opt/building/logical_or_in_conditional.test_or.built.after.mir index 0bb992f2273..b84c17c2188 100644 --- a/tests/mir-opt/building/logical_or_in_conditional.test_or.built.after.mir +++ b/tests/mir-opt/building/logical_or_in_conditional.test_or.built.after.mir @@ -3,78 +3,85 @@ fn test_or() -> () { let mut _0: (); let mut _1: bool; - let mut _2: bool; - let mut _3: u8; - let mut _4: Droppy; - let mut _5: bool; - let mut _6: u8; - let mut _7: Droppy; + let mut _2: u8; + let mut _3: Droppy; + let mut _4: bool; + let mut _5: u8; + let mut _6: Droppy; bb0: { StorageLive(_1); StorageLive(_2); StorageLive(_3); - StorageLive(_4); - _4 = Droppy(const 0_u8); - _3 = (_4.0: u8); - _2 = Gt(move _3, const 0_u8); - drop(_4) -> [return: bb4, unwind: bb10]; + _3 = Droppy(const 0_u8); + _2 = (_3.0: u8); + _1 = Gt(move _2, const 0_u8); + switchInt(move _1) -> [0: bb2, otherwise: bb1]; } bb1: { - _1 = const true; - goto -> bb3; + drop(_3) -> [return: bb3, unwind: bb12]; } bb2: { - StorageLive(_5); - StorageLive(_6); - StorageLive(_7); - _7 = Droppy(const 1_u8); - _6 = (_7.0: u8); - _5 = Gt(move _6, const 1_u8); - drop(_7) -> [return: bb5, unwind: bb10]; + goto -> bb4; } bb3: { - StorageDead(_5); + StorageDead(_3); StorageDead(_2); - switchInt(move _1) -> [0: bb7, otherwise: bb6]; + goto -> bb8; } bb4: { - StorageDead(_4); - StorageDead(_3); - switchInt(move _2) -> [0: bb2, otherwise: bb1]; + drop(_3) -> [return: bb5, unwind: bb12]; } bb5: { - StorageDead(_7); - StorageDead(_6); - _1 = move _5; - goto -> bb3; + StorageDead(_3); + StorageDead(_2); + StorageLive(_4); + StorageLive(_5); + StorageLive(_6); + _6 = Droppy(const 1_u8); + _5 = (_6.0: u8); + _4 = Gt(move _5, const 1_u8); + switchInt(move _4) -> [0: bb7, otherwise: bb6]; } bb6: { - _0 = const (); - goto -> bb9; + drop(_6) -> [return: bb8, unwind: bb12]; } bb7: { - goto -> bb8; + goto -> bb9; } bb8: { + StorageDead(_6); + StorageDead(_5); _0 = const (); - goto -> bb9; + goto -> bb11; } bb9: { + drop(_6) -> [return: bb10, unwind: bb12]; + } + + bb10: { + StorageDead(_6); + StorageDead(_5); + _0 = const (); + goto -> bb11; + } + + bb11: { + StorageDead(_4); StorageDead(_1); return; } - bb10 (cleanup): { + bb12 (cleanup): { resume; } } diff --git a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff b/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff index d1dbc7089a1..1768298d521 100644 --- a/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff +++ b/tests/mir-opt/const_goto_storage.match_nested_if.ConstGoto.diff @@ -43,31 +43,33 @@ } bb3: { -- StorageDead(_6); - switchInt(move _5) -> [0: bb5, otherwise: bb4]; - } - - bb4: { +- StorageDead(_6); - _4 = const true; - goto -> bb6; - } - - bb5: { +- StorageDead(_6); - _4 = const false; - goto -> bb6; - } - - bb6: { -- StorageDead(_5); - switchInt(move _4) -> [0: bb8, otherwise: bb7]; - } - - bb7: { +- StorageDead(_5); - _3 = const true; - goto -> bb9; - } - - bb8: { +- StorageDead(_5); - _3 = const false; - goto -> bb9; - } diff --git a/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff b/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff index 08b599f9f5d..355f28b03db 100644 --- a/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff +++ b/tests/mir-opt/dataflow-const-prop/if.main.DataflowConstProp.diff @@ -39,19 +39,20 @@ StorageLive(_4); - _4 = _1; - _3 = Eq(move _4, const 1_i32); +- switchInt(move _3) -> [0: bb2, otherwise: bb1]; + _4 = const 1_i32; + _3 = const true; - StorageDead(_4); -- switchInt(move _3) -> [0: bb2, otherwise: bb1]; + switchInt(const true) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_4); _2 = const 2_i32; goto -> bb3; } bb2: { + StorageDead(_4); _2 = const 3_i32; goto -> bb3; } @@ -70,20 +71,21 @@ StorageLive(_9); - _9 = _1; - _8 = Eq(move _9, const 1_i32); +- switchInt(move _8) -> [0: bb5, otherwise: bb4]; + _9 = const 1_i32; + _8 = const true; - StorageDead(_9); -- switchInt(move _8) -> [0: bb5, otherwise: bb4]; + switchInt(const true) -> [0: bb5, otherwise: bb4]; } bb4: { + StorageDead(_9); - _7 = _1; + _7 = const 1_i32; goto -> bb6; } bb5: { + StorageDead(_9); StorageLive(_10); _10 = _1; _7 = Add(move _10, const 1_i32); diff --git a/tests/mir-opt/equal_true.opt.InstSimplify.diff b/tests/mir-opt/equal_true.opt.InstSimplify.diff index 7b38862e4d5..88a51000c93 100644 --- a/tests/mir-opt/equal_true.opt.InstSimplify.diff +++ b/tests/mir-opt/equal_true.opt.InstSimplify.diff @@ -13,16 +13,17 @@ _3 = _1; - _2 = Eq(move _3, const true); + _2 = move _3; - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_i32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_i32; goto -> bb3; } diff --git a/tests/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff b/tests/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff index 8483b89f814..15319586062 100644 --- a/tests/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/if_condition_int.dont_opt_floats.SimplifyComparisonIntegral.diff @@ -12,16 +12,17 @@ StorageLive(_3); _3 = _1; _2 = Eq(move _3, const -42f32); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_i32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_i32; goto -> bb3; } diff --git a/tests/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff b/tests/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff index 837841b009b..fedbd6cdd24 100644 --- a/tests/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/if_condition_int.opt_char.SimplifyComparisonIntegral.diff @@ -12,21 +12,19 @@ StorageLive(_3); _3 = _1; - _2 = Eq(move _3, const 'x'); -- StorageDead(_3); - switchInt(move _2) -> [0: bb2, otherwise: bb1]; + nop; -+ nop; + switchInt(move _3) -> [120: bb1, otherwise: bb2]; } bb1: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff b/tests/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff index 3cbf912996c..9c38d8fe065 100644 --- a/tests/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/if_condition_int.opt_i8.SimplifyComparisonIntegral.diff @@ -12,21 +12,19 @@ StorageLive(_3); _3 = _1; - _2 = Eq(move _3, const 42_i8); -- StorageDead(_3); - switchInt(move _2) -> [0: bb2, otherwise: bb1]; + nop; -+ nop; + switchInt(move _3) -> [42: bb1, otherwise: bb2]; } bb1: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff b/tests/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff index 8d6f3b2249e..8c85ce78565 100644 --- a/tests/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/if_condition_int.opt_multiple_ifs.SimplifyComparisonIntegral.diff @@ -14,40 +14,36 @@ StorageLive(_3); _3 = _1; - _2 = Eq(move _3, const 42_u32); -- StorageDead(_3); - switchInt(move _2) -> [0: bb2, otherwise: bb1]; + nop; -+ nop; + switchInt(move _3) -> [42: bb1, otherwise: bb2]; } bb1: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 0_u32; goto -> bb6; } bb2: { -+ StorageDead(_3); + StorageDead(_3); StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = Ne(move _5, const 21_u32); -- StorageDead(_5); - switchInt(move _4) -> [0: bb4, otherwise: bb3]; + nop; -+ nop; + switchInt(move _5) -> [21: bb4, otherwise: bb3]; } bb3: { -+ StorageDead(_5); + StorageDead(_5); _0 = const 1_u32; goto -> bb5; } bb4: { -+ StorageDead(_5); + StorageDead(_5); _0 = const 2_u32; goto -> bb5; } diff --git a/tests/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff b/tests/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff index e2566b13c59..876ed61e9fa 100644 --- a/tests/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/if_condition_int.opt_negative.SimplifyComparisonIntegral.diff @@ -12,21 +12,19 @@ StorageLive(_3); _3 = _1; - _2 = Eq(move _3, const -42_i32); -- StorageDead(_3); - switchInt(move _2) -> [0: bb2, otherwise: bb1]; + nop; -+ nop; + switchInt(move _3) -> [4294967254: bb1, otherwise: bb2]; } bb1: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff b/tests/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff index dc8da5b44b2..ed3eb47dd3d 100644 --- a/tests/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff +++ b/tests/mir-opt/if_condition_int.opt_u32.SimplifyComparisonIntegral.diff @@ -12,21 +12,19 @@ StorageLive(_3); _3 = _1; - _2 = Eq(move _3, const 42_u32); -- StorageDead(_3); - switchInt(move _2) -> [0: bb2, otherwise: bb1]; + nop; -+ nop; + switchInt(move _3) -> [42: bb1, otherwise: bb2]; } bb1: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { -+ StorageDead(_3); + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff index 9db0d385da7..d675695eb10 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-abort.diff @@ -18,11 +18,11 @@ StorageLive(_3); _3 = _1; _2 = Gt(move _3, const 0_i32); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); StorageLive(_4); _4 = _1; _0 = move _4 as u32 (IntToInt); @@ -32,6 +32,7 @@ } bb2: { + StorageDead(_3); StorageLive(_6); - _6 = panic() -> unwind unreachable; + StorageLive(_7); diff --git a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff index 5663b462400..1142616115f 100644 --- a/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff +++ b/tests/mir-opt/inline/inline_diverging.g.Inline.panic-unwind.diff @@ -18,11 +18,11 @@ StorageLive(_3); _3 = _1; _2 = Gt(move _3, const 0_i32); - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); StorageLive(_4); _4 = _1; _0 = move _4 as u32 (IntToInt); @@ -32,6 +32,7 @@ } bb2: { + StorageDead(_3); StorageLive(_6); - _6 = panic() -> unwind continue; + StorageLive(_7); diff --git a/tests/mir-opt/issue_99325.main.built.after.mir b/tests/mir-opt/issue_99325.main.built.after.mir index aef89c7f9f7..f12179a8905 100644 --- a/tests/mir-opt/issue_99325.main.built.after.mir +++ b/tests/mir-opt/issue_99325.main.built.after.mir @@ -16,51 +16,49 @@ fn main() -> () { let _8: &&[u8]; let _9: &&[u8; 4]; let mut _10: bool; - let mut _11: bool; - let mut _12: &&[u8]; - let mut _13: &&[u8; 4]; - let mut _14: !; - let _16: !; - let mut _17: core::panicking::AssertKind; - let mut _18: &&[u8]; - let _19: &&[u8]; - let mut _20: &&[u8; 4]; - let _21: &&[u8; 4]; - let mut _22: std::option::Option<std::fmt::Arguments<'_>>; - let _23: (); - let mut _24: (&&[u8], &&[u8; 4]); - let mut _25: &&[u8]; - let _26: &[u8]; - let mut _27: &&[u8; 4]; - let _28: &[u8; 4]; - let _29: &&[u8]; - let _30: &&[u8; 4]; - let mut _31: bool; - let mut _32: bool; - let mut _33: &&[u8]; - let mut _34: &&[u8; 4]; - let mut _35: !; - let _37: !; - let mut _38: core::panicking::AssertKind; - let mut _39: &&[u8]; - let _40: &&[u8]; - let mut _41: &&[u8; 4]; - let _42: &&[u8; 4]; - let mut _43: std::option::Option<std::fmt::Arguments<'_>>; + let mut _11: &&[u8]; + let mut _12: &&[u8; 4]; + let mut _13: !; + let _15: !; + let mut _16: core::panicking::AssertKind; + let mut _17: &&[u8]; + let _18: &&[u8]; + let mut _19: &&[u8; 4]; + let _20: &&[u8; 4]; + let mut _21: std::option::Option<std::fmt::Arguments<'_>>; + let _22: (); + let mut _23: (&&[u8], &&[u8; 4]); + let mut _24: &&[u8]; + let _25: &[u8]; + let mut _26: &&[u8; 4]; + let _27: &[u8; 4]; + let _28: &&[u8]; + let _29: &&[u8; 4]; + let mut _30: bool; + let mut _31: &&[u8]; + let mut _32: &&[u8; 4]; + let mut _33: !; + let _35: !; + let mut _36: core::panicking::AssertKind; + let mut _37: &&[u8]; + let _38: &&[u8]; + let mut _39: &&[u8; 4]; + let _40: &&[u8; 4]; + let mut _41: std::option::Option<std::fmt::Arguments<'_>>; scope 1 { debug left_val => _8; debug right_val => _9; - let _15: core::panicking::AssertKind; + let _14: core::panicking::AssertKind; scope 2 { - debug kind => _15; + debug kind => _14; } } scope 3 { - debug left_val => _29; - debug right_val => _30; - let _36: core::panicking::AssertKind; + debug left_val => _28; + debug right_val => _29; + let _34: core::panicking::AssertKind; scope 4 { - debug kind => _36; + debug kind => _34; } } @@ -69,7 +67,7 @@ fn main() -> () { StorageLive(_2); StorageLive(_3); StorageLive(_4); - _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb19]; + _4 = function_with_bytes::<&*b"AAAA">() -> [return: bb1, unwind: bb21]; } bb1: { @@ -90,179 +88,185 @@ fn main() -> () { _9 = (_2.1: &&[u8; 4]); StorageLive(_10); StorageLive(_11); + _11 = &(*_8); StorageLive(_12); - _12 = &(*_8); - StorageLive(_13); - _13 = &(*_9); - _11 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _12, move _13) -> [return: bb2, unwind: bb19]; + _12 = &(*_9); + _10 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _11, move _12) -> [return: bb2, unwind: bb21]; } bb2: { - StorageDead(_13); - StorageDead(_12); - _10 = Not(move _11); - StorageDead(_11); switchInt(move _10) -> [0: bb4, otherwise: bb3]; } bb3: { + StorageDead(_12); + StorageDead(_11); + goto -> bb8; + } + + bb4: { + goto -> bb5; + } + + bb5: { + StorageDead(_12); + StorageDead(_11); + StorageLive(_14); + _14 = core::panicking::AssertKind::Eq; + FakeRead(ForLet(None), _14); StorageLive(_15); - _15 = core::panicking::AssertKind::Eq; - FakeRead(ForLet(None), _15); StorageLive(_16); + _16 = move _14; StorageLive(_17); - _17 = move _15; StorageLive(_18); + _18 = &(*_8); + _17 = &(*_18); StorageLive(_19); - _19 = &(*_8); - _18 = &(*_19); StorageLive(_20); + _20 = &(*_9); + _19 = &(*_20); StorageLive(_21); - _21 = &(*_9); - _20 = &(*_21); - StorageLive(_22); - _22 = Option::<Arguments<'_>>::None; - _16 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _17, move _18, move _20, move _22) -> bb19; - } - - bb4: { - goto -> bb7; + _21 = Option::<Arguments<'_>>::None; + _15 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _16, move _17, move _19, move _21) -> bb21; } - bb5: { - StorageDead(_22); - StorageDead(_20); - StorageDead(_18); - StorageDead(_17); + bb6: { StorageDead(_21); StorageDead(_19); + StorageDead(_17); StorageDead(_16); + StorageDead(_20); + StorageDead(_18); StorageDead(_15); + StorageDead(_14); unreachable; } - bb6: { - goto -> bb8; + bb7: { + goto -> bb9; } - bb7: { + bb8: { _1 = const (); - goto -> bb8; + goto -> bb9; } - bb8: { + bb9: { StorageDead(_10); StorageDead(_9); StorageDead(_8); - goto -> bb9; + goto -> bb10; } - bb9: { + bb10: { StorageDead(_7); StorageDead(_6); StorageDead(_4); StorageDead(_2); StorageDead(_1); + StorageLive(_22); StorageLive(_23); StorageLive(_24); StorageLive(_25); - StorageLive(_26); - _26 = function_with_bytes::<&*b"AAAA">() -> [return: bb10, unwind: bb19]; + _25 = function_with_bytes::<&*b"AAAA">() -> [return: bb11, unwind: bb21]; } - bb10: { - _25 = &_26; + bb11: { + _24 = &_25; + StorageLive(_26); StorageLive(_27); + _27 = const b"AAAA"; + _26 = &_27; + _23 = (move _24, move _26); + StorageDead(_26); + StorageDead(_24); + FakeRead(ForMatchedPlace(None), _23); StorageLive(_28); - _28 = const b"AAAA"; - _27 = &_28; - _24 = (move _25, move _27); - StorageDead(_27); - StorageDead(_25); - FakeRead(ForMatchedPlace(None), _24); + _28 = (_23.0: &&[u8]); StorageLive(_29); - _29 = (_24.0: &&[u8]); + _29 = (_23.1: &&[u8; 4]); StorageLive(_30); - _30 = (_24.1: &&[u8; 4]); StorageLive(_31); + _31 = &(*_28); StorageLive(_32); - StorageLive(_33); - _33 = &(*_29); - StorageLive(_34); - _34 = &(*_30); - _32 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _33, move _34) -> [return: bb11, unwind: bb19]; + _32 = &(*_29); + _30 = <&[u8] as PartialEq<&[u8; 4]>>::eq(move _31, move _32) -> [return: bb12, unwind: bb21]; } - bb11: { - StorageDead(_34); - StorageDead(_33); - _31 = Not(move _32); + bb12: { + switchInt(move _30) -> [0: bb14, otherwise: bb13]; + } + + bb13: { StorageDead(_32); - switchInt(move _31) -> [0: bb13, otherwise: bb12]; + StorageDead(_31); + goto -> bb18; } - bb12: { + bb14: { + goto -> bb15; + } + + bb15: { + StorageDead(_32); + StorageDead(_31); + StorageLive(_34); + _34 = core::panicking::AssertKind::Eq; + FakeRead(ForLet(None), _34); + StorageLive(_35); StorageLive(_36); - _36 = core::panicking::AssertKind::Eq; - FakeRead(ForLet(None), _36); + _36 = move _34; StorageLive(_37); StorageLive(_38); - _38 = move _36; + _38 = &(*_28); + _37 = &(*_38); StorageLive(_39); StorageLive(_40); _40 = &(*_29); _39 = &(*_40); StorageLive(_41); - StorageLive(_42); - _42 = &(*_30); - _41 = &(*_42); - StorageLive(_43); - _43 = Option::<Arguments<'_>>::None; - _37 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _38, move _39, move _41, move _43) -> bb19; - } - - bb13: { - goto -> bb16; + _41 = Option::<Arguments<'_>>::None; + _35 = core::panicking::assert_failed::<&[u8], &[u8; 4]>(move _36, move _37, move _39, move _41) -> bb21; } - bb14: { - StorageDead(_43); + bb16: { StorageDead(_41); StorageDead(_39); - StorageDead(_38); - StorageDead(_42); - StorageDead(_40); StorageDead(_37); StorageDead(_36); + StorageDead(_40); + StorageDead(_38); + StorageDead(_35); + StorageDead(_34); unreachable; } - bb15: { - goto -> bb17; + bb17: { + goto -> bb19; } - bb16: { - _23 = const (); - goto -> bb17; + bb18: { + _22 = const (); + goto -> bb19; } - bb17: { - StorageDead(_31); + bb19: { StorageDead(_30); StorageDead(_29); - goto -> bb18; + StorageDead(_28); + goto -> bb20; } - bb18: { - StorageDead(_28); - StorageDead(_26); - StorageDead(_24); + bb20: { + StorageDead(_27); + StorageDead(_25); StorageDead(_23); + StorageDead(_22); _0 = const (); return; } - bb19 (cleanup): { + bb21 (cleanup): { resume; } } diff --git a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff index 6174d5259d0..5242c5f6afd 100644 --- a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-abort.diff @@ -32,12 +32,12 @@ bb1: { StorageDead(_6); _3 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageDead(_5); + StorageDead(_4); StorageLive(_8); _8 = _1; _9 = Len((*_2)); @@ -52,6 +52,8 @@ } bb4: { + StorageDead(_5); + StorageDead(_4); _0 = const 42_u8; goto -> bb5; } diff --git a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff index 60c0772d8ec..a9e99933b12 100644 --- a/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound.NormalizeArrayLen.panic-unwind.diff @@ -32,12 +32,12 @@ bb1: { StorageDead(_6); _3 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageDead(_5); + StorageDead(_4); StorageLive(_8); _8 = _1; _9 = Len((*_2)); @@ -52,6 +52,8 @@ } bb4: { + StorageDead(_5); + StorageDead(_4); _0 = const 42_u8; goto -> bb5; } diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff index e2de1845296..7749ba6beca 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-abort.diff @@ -35,12 +35,12 @@ bb1: { StorageDead(_6); _3 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageDead(_5); + StorageDead(_4); StorageLive(_8); _8 = _1; _9 = Len((*_2)); @@ -55,6 +55,8 @@ } bb4: { + StorageDead(_5); + StorageDead(_4); StorageLive(_11); _11 = const 0_usize; _12 = Len((*_2)); diff --git a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff index eb81e0eea2c..fcc2c1653dc 100644 --- a/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff +++ b/tests/mir-opt/lower_array_len.array_bound_mut.NormalizeArrayLen.panic-unwind.diff @@ -35,12 +35,12 @@ bb1: { StorageDead(_6); _3 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageDead(_5); + StorageDead(_4); StorageLive(_8); _8 = _1; _9 = Len((*_2)); @@ -55,6 +55,8 @@ } bb4: { + StorageDead(_5); + StorageDead(_4); StorageLive(_11); _11 = const 0_usize; _12 = Len((*_2)); diff --git a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff index 70b33fb703b..7f752ca0f5a 100644 --- a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff +++ b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-abort.diff @@ -28,12 +28,12 @@ bb1: { StorageDead(_6); _3 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageDead(_5); + StorageDead(_4); StorageLive(_7); _7 = _1; _8 = Len((*_2)); @@ -48,6 +48,8 @@ } bb4: { + StorageDead(_5); + StorageDead(_4); _0 = const 42_u8; goto -> bb5; } diff --git a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff index 310b3b26ac5..d73b563a0e5 100644 --- a/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff +++ b/tests/mir-opt/lower_slice_len.bound.LowerSliceLenCalls.panic-unwind.diff @@ -28,12 +28,12 @@ bb1: { StorageDead(_6); _3 = Lt(move _4, move _5); - StorageDead(_5); - StorageDead(_4); switchInt(move _3) -> [0: bb4, otherwise: bb2]; } bb2: { + StorageDead(_5); + StorageDead(_4); StorageLive(_7); _7 = _1; _8 = Len((*_2)); @@ -48,6 +48,8 @@ } bb4: { + StorageDead(_5); + StorageDead(_4); _0 = const 42_u8; goto -> bb5; } diff --git a/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff b/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff index b5edbfee0fc..5a71bef9341 100644 --- a/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff +++ b/tests/mir-opt/matches_reduce_branches.match_nested_if.MatchBranchSimplification.diff @@ -40,39 +40,43 @@ - } - - bb3: { +- switchInt(move _5) -> [0: bb5, otherwise: bb4]; +- } +- +- bb4: { + StorageLive(_7); + _7 = move _6; + _5 = Ne(_7, const false); + StorageDead(_7); ++ StorageLive(_8); ++ _8 = move _5; StorageDead(_6); -- switchInt(move _5) -> [0: bb5, otherwise: bb4]; -- } -- -- bb4: { - _4 = const true; - goto -> bb6; - } - - bb5: { +- StorageDead(_6); - _4 = const false; - goto -> bb6; - } - - bb6: { -+ StorageLive(_8); -+ _8 = move _5; -+ _4 = Ne(_8, const false); -+ StorageDead(_8); - StorageDead(_5); - switchInt(move _4) -> [0: bb8, otherwise: bb7]; - } - - bb7: { ++ _4 = Ne(_8, const false); ++ StorageDead(_8); ++ StorageLive(_9); ++ _9 = move _4; + StorageDead(_5); - _3 = const true; - goto -> bb9; - } - - bb8: { +- StorageDead(_5); - _3 = const false; - goto -> bb9; - } @@ -82,8 +86,6 @@ - } - - bb10: { -+ StorageLive(_9); -+ _9 = move _4; + _3 = Ne(_9, const false); + StorageDead(_9); + StorageLive(_10); diff --git a/tests/mir-opt/not_equal_false.opt.InstSimplify.diff b/tests/mir-opt/not_equal_false.opt.InstSimplify.diff index 71353be24a6..1342966aa15 100644 --- a/tests/mir-opt/not_equal_false.opt.InstSimplify.diff +++ b/tests/mir-opt/not_equal_false.opt.InstSimplify.diff @@ -13,16 +13,17 @@ _3 = _1; - _2 = Ne(move _3, const false); + _2 = move _3; - StorageDead(_3); switchInt(move _2) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_3); _0 = const 0_u32; goto -> bb3; } bb2: { + StorageDead(_3); _0 = const 1_u32; goto -> bb3; } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir index 70efdbf4b34..566b6af95ba 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-abort.mir @@ -19,17 +19,16 @@ fn array_casts() -> () { let mut _18: &usize; let _19: usize; let mut _22: bool; - let mut _23: bool; + let mut _23: usize; let mut _24: usize; - let mut _25: usize; - let mut _26: !; - let _28: !; - let mut _29: core::panicking::AssertKind; - let mut _30: &usize; - let _31: &usize; - let mut _32: &usize; - let _33: &usize; - let mut _34: std::option::Option<std::fmt::Arguments<'_>>; + let mut _25: !; + let _27: !; + let mut _28: core::panicking::AssertKind; + let mut _29: &usize; + let _30: &usize; + let mut _31: &usize; + let _32: &usize; + let mut _33: std::option::Option<std::fmt::Arguments<'_>>; scope 1 { debug x => _1; let _2: *mut usize; @@ -45,15 +44,15 @@ fn array_casts() -> () { debug p => _9; let _20: &usize; let _21: &usize; - let mut _35: &usize; + let mut _34: &usize; scope 6 { } scope 7 { debug left_val => _20; debug right_val => _21; - let _27: core::panicking::AssertKind; + let _26: core::panicking::AssertKind; scope 8 { - debug kind => _27; + debug kind => _26; } } } @@ -110,9 +109,9 @@ fn array_casts() -> () { _15 = (*_16); _14 = &_15; StorageLive(_18); - _35 = const _; - Retag(_35); - _18 = &(*_35); + _34 = const _; + Retag(_34); + _18 = &(*_34); _13 = (move _14, move _18); Retag(_13); StorageDead(_18); @@ -125,39 +124,16 @@ fn array_casts() -> () { Retag(_21); StorageLive(_22); StorageLive(_23); + _23 = (*_20); StorageLive(_24); - _24 = (*_20); - StorageLive(_25); - _25 = (*_21); - _23 = Eq(move _24, move _25); - StorageDead(_25); - StorageDead(_24); - _22 = Not(move _23); - StorageDead(_23); + _24 = (*_21); + _22 = Eq(move _23, move _24); switchInt(move _22) -> [0: bb4, otherwise: bb3]; } bb3: { - StorageLive(_27); - _27 = core::panicking::AssertKind::Eq; - StorageLive(_28); - StorageLive(_29); - _29 = move _27; - StorageLive(_30); - StorageLive(_31); - _31 = &(*_20); - _30 = &(*_31); - StorageLive(_32); - StorageLive(_33); - _33 = &(*_21); - _32 = &(*_33); - StorageLive(_34); - _34 = Option::<Arguments<'_>>::None; - Retag(_34); - _28 = core::panicking::assert_failed::<usize, usize>(move _29, move _30, move _32, move _34) -> unwind unreachable; - } - - bb4: { + StorageDead(_24); + StorageDead(_23); _12 = const (); StorageDead(_22); StorageDead(_21); @@ -173,4 +149,26 @@ fn array_casts() -> () { StorageDead(_1); return; } + + bb4: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_26); + _26 = core::panicking::AssertKind::Eq; + StorageLive(_27); + StorageLive(_28); + _28 = move _26; + StorageLive(_29); + StorageLive(_30); + _30 = &(*_20); + _29 = &(*_30); + StorageLive(_31); + StorageLive(_32); + _32 = &(*_21); + _31 = &(*_32); + StorageLive(_33); + _33 = Option::<Arguments<'_>>::None; + Retag(_33); + _27 = core::panicking::assert_failed::<usize, usize>(move _28, move _29, move _31, move _33) -> unwind unreachable; + } } diff --git a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir index cfa9628d498..d0d3176320b 100644 --- a/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir +++ b/tests/mir-opt/retag.array_casts.SimplifyCfg-elaborate-drops.after.panic-unwind.mir @@ -19,17 +19,16 @@ fn array_casts() -> () { let mut _18: &usize; let _19: usize; let mut _22: bool; - let mut _23: bool; + let mut _23: usize; let mut _24: usize; - let mut _25: usize; - let mut _26: !; - let _28: !; - let mut _29: core::panicking::AssertKind; - let mut _30: &usize; - let _31: &usize; - let mut _32: &usize; - let _33: &usize; - let mut _34: std::option::Option<std::fmt::Arguments<'_>>; + let mut _25: !; + let _27: !; + let mut _28: core::panicking::AssertKind; + let mut _29: &usize; + let _30: &usize; + let mut _31: &usize; + let _32: &usize; + let mut _33: std::option::Option<std::fmt::Arguments<'_>>; scope 1 { debug x => _1; let _2: *mut usize; @@ -45,15 +44,15 @@ fn array_casts() -> () { debug p => _9; let _20: &usize; let _21: &usize; - let mut _35: &usize; + let mut _34: &usize; scope 6 { } scope 7 { debug left_val => _20; debug right_val => _21; - let _27: core::panicking::AssertKind; + let _26: core::panicking::AssertKind; scope 8 { - debug kind => _27; + debug kind => _26; } } } @@ -110,9 +109,9 @@ fn array_casts() -> () { _15 = (*_16); _14 = &_15; StorageLive(_18); - _35 = const _; - Retag(_35); - _18 = &(*_35); + _34 = const _; + Retag(_34); + _18 = &(*_34); _13 = (move _14, move _18); Retag(_13); StorageDead(_18); @@ -125,39 +124,16 @@ fn array_casts() -> () { Retag(_21); StorageLive(_22); StorageLive(_23); + _23 = (*_20); StorageLive(_24); - _24 = (*_20); - StorageLive(_25); - _25 = (*_21); - _23 = Eq(move _24, move _25); - StorageDead(_25); - StorageDead(_24); - _22 = Not(move _23); - StorageDead(_23); + _24 = (*_21); + _22 = Eq(move _23, move _24); switchInt(move _22) -> [0: bb4, otherwise: bb3]; } bb3: { - StorageLive(_27); - _27 = core::panicking::AssertKind::Eq; - StorageLive(_28); - StorageLive(_29); - _29 = move _27; - StorageLive(_30); - StorageLive(_31); - _31 = &(*_20); - _30 = &(*_31); - StorageLive(_32); - StorageLive(_33); - _33 = &(*_21); - _32 = &(*_33); - StorageLive(_34); - _34 = Option::<Arguments<'_>>::None; - Retag(_34); - _28 = core::panicking::assert_failed::<usize, usize>(move _29, move _30, move _32, move _34) -> unwind continue; - } - - bb4: { + StorageDead(_24); + StorageDead(_23); _12 = const (); StorageDead(_22); StorageDead(_21); @@ -173,4 +149,26 @@ fn array_casts() -> () { StorageDead(_1); return; } + + bb4: { + StorageDead(_24); + StorageDead(_23); + StorageLive(_26); + _26 = core::panicking::AssertKind::Eq; + StorageLive(_27); + StorageLive(_28); + _28 = move _26; + StorageLive(_29); + StorageLive(_30); + _30 = &(*_20); + _29 = &(*_30); + StorageLive(_31); + StorageLive(_32); + _32 = &(*_21); + _31 = &(*_32); + StorageLive(_33); + _33 = Option::<Arguments<'_>>::None; + Retag(_33); + _27 = core::panicking::assert_failed::<usize, usize>(move _28, move _29, move _31, move _33) -> unwind continue; + } } diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs index e0dded15217..484c1862839 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.rs @@ -1,7 +1,6 @@ fn and_chain() { let z; if true && { z = 3; true} && z == 3 {} - //~^ ERROR E0381 } fn and_chain_2() { @@ -13,7 +12,6 @@ fn and_chain_2() { fn or_chain() { let z; if false || { z = 3; false} || z == 3 {} - //~^ ERROR E0381 } fn main() { diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr index 30d5a6779fc..6bce7772bcc 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/chains-without-let.stderr @@ -1,15 +1,5 @@ error[E0381]: used binding `z` is possibly-uninitialized - --> $DIR/chains-without-let.rs:3:34 - | -LL | let z; - | - binding declared here but left uninitialized -LL | if true && { z = 3; true} && z == 3 {} - | ----- ^ `z` used here but it is possibly-uninitialized - | | - | binding initialized here in some conditions - -error[E0381]: used binding `z` is possibly-uninitialized - --> $DIR/chains-without-let.rs:9:31 + --> $DIR/chains-without-let.rs:8:31 | LL | let z; | - binding declared here but left uninitialized @@ -18,16 +8,6 @@ LL | true && { z = 3; true} && z == 3; | | | binding initialized here in some conditions -error[E0381]: used binding `z` is possibly-uninitialized - --> $DIR/chains-without-let.rs:15:36 - | -LL | let z; - | - binding declared here but left uninitialized -LL | if false || { z = 3; false} || z == 3 {} - | ----- ^ `z` used here but it is possibly-uninitialized - | | - | binding initialized here in some conditions - -error: aborting due to 3 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0381`. |
