diff --git a/compiler/rustc_mir_transform/src/dead_store_elimination.rs b/compiler/rustc_mir_transform/src/dead_store_elimination.rs index 60230bea02e29..0e7946041cb46 100644 --- a/compiler/rustc_mir_transform/src/dead_store_elimination.rs +++ b/compiler/rustc_mir_transform/src/dead_store_elimination.rs @@ -12,6 +12,7 @@ //! will still not cause any further changes. //! +use crate::simplify::preserve_debug_even_if_never_generated; use crate::util::is_within_packed; use rustc_middle::bug; use rustc_middle::mir::visit::Visitor; @@ -32,10 +33,16 @@ pub fn eliminate<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // If the user requests complete debuginfo, mark the locals that appear in it as live, so // we don't remove assignements to them. - let mut always_live = debuginfo_locals(body); - always_live.union(&borrowed_locals); - - let mut live = MaybeTransitiveLiveLocals::new(&always_live) + let mut always_live; + let always_live = if preserve_debug_even_if_never_generated(tcx) { + always_live = debuginfo_locals(body); + always_live.union(&borrowed_locals); + &always_live + } else { + &borrowed_locals + }; + + let mut live = MaybeTransitiveLiveLocals::new(always_live) .into_engine(tcx, body) .iterate_to_fixpoint() .into_results_cursor(body); diff --git a/compiler/rustc_mir_transform/src/inline.rs b/compiler/rustc_mir_transform/src/inline.rs index fd9f0fec88ddd..7978d3223614f 100644 --- a/compiler/rustc_mir_transform/src/inline.rs +++ b/compiler/rustc_mir_transform/src/inline.rs @@ -12,14 +12,14 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::TypeVisitableExt; use rustc_middle::ty::{self, Instance, InstanceKind, ParamEnv, Ty, TyCtxt, TypeFlags}; -use rustc_session::config::{DebugInfo, OptLevel}; +use rustc_session::config::OptLevel; use rustc_span::source_map::Spanned; use rustc_span::sym; use rustc_target::abi::FieldIdx; use rustc_target::spec::abi::Abi; use crate::cost_checker::CostChecker; -use crate::simplify::simplify_cfg; +use crate::simplify::{preserve_debug_even_if_never_generated, simplify_cfg}; use crate::util; use crate::validate::validate_types; use std::iter; @@ -719,14 +719,7 @@ impl<'tcx> Inliner<'tcx> { // Insert all of the (mapped) parts of the callee body into the caller. caller_body.local_decls.extend(callee_body.drain_vars_and_temps()); caller_body.source_scopes.extend(&mut callee_body.source_scopes.drain(..)); - if self - .tcx - .sess - .opts - .unstable_opts - .inline_mir_preserve_debug - .unwrap_or(self.tcx.sess.opts.debuginfo != DebugInfo::None) - { + if preserve_debug_even_if_never_generated(self.tcx) { // Note that we need to preserve these in the standard library so that // people working on rust can build with or without debuginfo while // still getting consistent results from the mir-opt tests. diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 5d253d7384df4..3801013cc4d6e 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -597,7 +597,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &gvn::GVN, &simplify::SimplifyLocals::AfterGVN, &dataflow_const_prop::DataflowConstProp, - &single_use_consts::SingleUseConsts, + &single_use_consts::SingleUseConsts::Initial, &o1(simplify_branches::SimplifyConstCondition::AfterConstProp), &jump_threading::JumpThreading, &early_otherwise_branch::EarlyOtherwiseBranch, @@ -607,6 +607,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &o1(remove_noop_landing_pads::RemoveNoopLandingPads), &o1(simplify::SimplifyCfg::Final), ©_prop::CopyProp, + &single_use_consts::SingleUseConsts::Final, &dead_store_elimination::DeadStoreElimination::Final, &nrvo::RenameReturnPlace, &simplify::SimplifyLocals::Final, diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 5bbe3bb747fd9..fbd604266fd0a 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -31,6 +31,7 @@ use rustc_index::{Idx, IndexSlice, IndexVec}; use rustc_middle::mir::visit::{MutVisitor, MutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::ty::TyCtxt; +use rustc_session::config::DebugInfo; use smallvec::SmallVec; pub enum SimplifyCfg { @@ -581,3 +582,12 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater<'tcx> { *l = self.map[*l].unwrap(); } } + +pub(crate) fn preserve_debug_even_if_never_generated(tcx: TyCtxt<'_>) -> bool { + tcx.sess.opts.unstable_opts.inline_mir_preserve_debug.unwrap_or_else(|| { + match tcx.sess.opts.debuginfo { + DebugInfo::None | DebugInfo::LineDirectivesOnly | DebugInfo::LineTablesOnly => false, + DebugInfo::Limited | DebugInfo::Full => true, + } + }) +} diff --git a/compiler/rustc_mir_transform/src/single_use_consts.rs b/compiler/rustc_mir_transform/src/single_use_consts.rs index 93736e55996ec..5a36e21318911 100644 --- a/compiler/rustc_mir_transform/src/single_use_consts.rs +++ b/compiler/rustc_mir_transform/src/single_use_consts.rs @@ -18,13 +18,23 @@ use rustc_middle::ty::TyCtxt; /// /// It also removes *never*-used constants, since it had all the information /// needed to do that too, including updating the debug info. -pub struct SingleUseConsts; +pub enum SingleUseConsts { + Initial, + Final, +} impl<'tcx> MirPass<'tcx> for SingleUseConsts { fn is_enabled(&self, sess: &rustc_session::Session) -> bool { sess.mir_opt_level() > 0 } + fn name(&self) -> &'static str { + match self { + SingleUseConsts::Initial => "SingleUseConsts-initial", + SingleUseConsts::Final => "SingleUseConsts-final", + } + } + fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { let mut finder = SingleUseConstsFinder { ineligible_locals: BitSet::new_empty(body.local_decls.len()), diff --git a/tests/codegen/slice-ref-equality.rs b/tests/codegen/slice-ref-equality.rs index 1153d7817b278..9b1397bfb6b92 100644 --- a/tests/codegen/slice-ref-equality.rs +++ b/tests/codegen/slice-ref-equality.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O -Zmerge-functions=disabled +//@ compile-flags: -O -Zmerge-functions=disabled -Cdebuginfo=0 #![crate_type = "lib"] use std::num::NonZero; diff --git a/tests/crashes/101962.rs b/tests/crashes/101962.rs index b6a78ce053af0..c8924a9f3bf38 100644 --- a/tests/crashes/101962.rs +++ b/tests/crashes/101962.rs @@ -1,4 +1,5 @@ //@ known-bug: #101962 +//@ compile-flags: -Cdebuginfo=2 #![feature(core_intrinsics)] diff --git a/tests/crashes/79409.rs b/tests/crashes/79409.rs index 98b5f60633627..5bff6dfff93e7 100644 --- a/tests/crashes/79409.rs +++ b/tests/crashes/79409.rs @@ -1,4 +1,5 @@ //@ known-bug: #79409 +//@ compile-flags: -Cdebuginfo=2 #![feature(extern_types)] #![feature(unsized_locals)] diff --git a/tests/incremental/hashes/enum_constructors.rs b/tests/incremental/hashes/enum_constructors.rs index d839dabf293af..b94e86a73cc09 100644 --- a/tests/incremental/hashes/enum_constructors.rs +++ b/tests/incremental/hashes/enum_constructors.rs @@ -318,9 +318,9 @@ pub fn change_constructor_variant_c_like() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn change_constructor_variant_c_like() { let _x = Clike::C; diff --git a/tests/incremental/hashes/for_loops.rs b/tests/incremental/hashes/for_loops.rs index 9cd99bf76b7ae..c5930f9a3dbaf 100644 --- a/tests/incremental/hashes/for_loops.rs +++ b/tests/incremental/hashes/for_loops.rs @@ -28,9 +28,9 @@ pub fn change_loop_body() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn change_loop_body() { let mut _x = 0; @@ -180,7 +180,7 @@ pub fn add_loop_label_to_break() { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn add_loop_label_to_break() { let mut _x = 0; diff --git a/tests/incremental/hashes/let_expressions.rs b/tests/incremental/hashes/let_expressions.rs index 86578855699b2..a40564c98666d 100644 --- a/tests/incremental/hashes/let_expressions.rs +++ b/tests/incremental/hashes/let_expressions.rs @@ -91,7 +91,7 @@ pub fn change_mutability_of_slot() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail6")] @@ -176,7 +176,7 @@ pub fn change_mutability_of_binding_in_pattern() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] #[rustc_clean(cfg="cfail6")] @@ -193,9 +193,9 @@ pub fn add_initializer() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck,optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn add_initializer() { let _x: i16 = 3i16; @@ -210,9 +210,9 @@ pub fn change_initializer() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn change_initializer() { let _x = 5u16; diff --git a/tests/incremental/hashes/loop_expressions.rs b/tests/incremental/hashes/loop_expressions.rs index 631699d3d6874..26cbf177db71d 100644 --- a/tests/incremental/hashes/loop_expressions.rs +++ b/tests/incremental/hashes/loop_expressions.rs @@ -28,9 +28,9 @@ pub fn change_loop_body() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn change_loop_body() { let mut _x = 0; diff --git a/tests/incremental/hashes/match_expressions.rs b/tests/incremental/hashes/match_expressions.rs index 9ed5b55fb2505..657d283c23c4b 100644 --- a/tests/incremental/hashes/match_expressions.rs +++ b/tests/incremental/hashes/match_expressions.rs @@ -227,7 +227,7 @@ pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { // Ignore optimized_mir in cfail2, the only change to optimized MIR is a span. #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] diff --git a/tests/incremental/hashes/while_loops.rs b/tests/incremental/hashes/while_loops.rs index dc343c3cbfaef..d8fd6de70af1d 100644 --- a/tests/incremental/hashes/while_loops.rs +++ b/tests/incremental/hashes/while_loops.rs @@ -28,9 +28,9 @@ pub fn change_loop_body() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn change_loop_body() { let mut _x = 0; @@ -53,9 +53,9 @@ pub fn change_loop_condition() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail6")] pub fn change_loop_condition() { let mut _x = 0; @@ -211,7 +211,7 @@ pub fn change_continue_label() { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir")] #[rustc_clean(cfg="cfail6")] pub fn change_continue_label() { let mut _x = 0; diff --git a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff b/tests/mir-opt/const_debuginfo.main.SingleUseConsts-final.diff similarity index 97% rename from tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff rename to tests/mir-opt/const_debuginfo.main.SingleUseConsts-final.diff index 8088984bc77ab..435bf57816900 100644 --- a/tests/mir-opt/const_debuginfo.main.SingleUseConsts.diff +++ b/tests/mir-opt/const_debuginfo.main.SingleUseConsts-final.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before SingleUseConsts -+ // MIR for `main` after SingleUseConsts +- // MIR for `main` before SingleUseConsts-final ++ // MIR for `main` after SingleUseConsts-final fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_debuginfo.rs b/tests/mir-opt/const_debuginfo.rs index 3b2bc4559ced9..be61c736bc2d5 100644 --- a/tests/mir-opt/const_debuginfo.rs +++ b/tests/mir-opt/const_debuginfo.rs @@ -1,4 +1,4 @@ -//@ test-mir-pass: SingleUseConsts +//@ test-mir-pass: SingleUseConsts-final //@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN -Zdump-mir-exclude-alloc-bytes #![allow(unused)] @@ -8,7 +8,7 @@ struct Point { y: u32, } -// EMIT_MIR const_debuginfo.main.SingleUseConsts.diff +// EMIT_MIR const_debuginfo.main.SingleUseConsts-final.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => const 1_u8; diff --git a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination-initial.diff b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination-initial.diff index 2766b6ce6a9fa..964b7734eb881 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination-initial.diff +++ b/tests/mir-opt/dead-store-elimination/cycle.cycle.DeadStoreElimination-initial.diff @@ -2,31 +2,70 @@ + // MIR for `cycle` after DeadStoreElimination-initial fn cycle(_1: i32, _2: i32, _3: i32) -> () { + debug x => _1; + debug y => _2; + debug z => _3; let mut _0: (); - let mut _4: bool; - let mut _5: i32; + let mut _4: (); + let mut _5: bool; + let _6: i32; + let mut _7: i32; + let mut _8: i32; + let mut _9: i32; + let mut _10: !; + let _11: (); + let mut _12: !; + scope 1 { + debug temp => _6; + } bb0: { - _4 = cond() -> [return: bb1, unwind continue]; + goto -> bb1; } bb1: { - switchInt(_4) -> [1: bb2, otherwise: bb3]; + StorageLive(_5); + _5 = cond() -> [return: bb2, unwind continue]; } bb2: { -- _5 = _3; -- _3 = _2; -- _2 = _1; -- _1 = _5; + switchInt(move _5) -> [0: bb4, otherwise: bb3]; + } + + bb3: { + StorageLive(_6); +- _6 = _3; ++ nop; + StorageLive(_7); +- _7 = _2; +- _3 = move _7; + nop; + nop; + StorageDead(_7); + StorageLive(_8); +- _8 = _1; +- _2 = move _8; + nop; + nop; - _4 = cond() -> [return: bb1, unwind continue]; + StorageDead(_8); + StorageLive(_9); +- _9 = _6; +- _1 = move _9; ++ nop; ++ nop; + StorageDead(_9); +- _4 = const (); ++ nop; + StorageDead(_6); + StorageDead(_5); + goto -> bb1; } - bb3: { + bb4: { + StorageLive(_11); + _0 = const (); + StorageDead(_11); + StorageDead(_5); return; } } diff --git a/tests/mir-opt/dead-store-elimination/cycle.rs b/tests/mir-opt/dead-store-elimination/cycle.rs index c8f0c2644ab3b..bb2be86951446 100644 --- a/tests/mir-opt/dead-store-elimination/cycle.rs +++ b/tests/mir-opt/dead-store-elimination/cycle.rs @@ -4,43 +4,28 @@ //@ needs-unwind //@ test-mir-pass: DeadStoreElimination-initial -#![feature(core_intrinsics, custom_mir)] -use std::intrinsics::mir::*; - #[inline(never)] fn cond() -> bool { false } // EMIT_MIR cycle.cycle.DeadStoreElimination-initial.diff -#[custom_mir(dialect = "runtime", phase = "post-cleanup")] fn cycle(mut x: i32, mut y: i32, mut z: i32) { // CHECK-LABEL: fn cycle( - // CHECK-NOT: {{_.*}} = {{_.*}}; - // CHECK-NOT: {{_.*}} = move {{_.*}}; - - // We use custom MIR to avoid generating debuginfo, that would force to preserve writes. - mir! { - let condition: bool; - { - Call(condition = cond(), ReturnTo(bb1), UnwindContinue()) - } - bb1 = { - match condition { true => bb2, _ => ret } - } - bb2 = { - let temp = z; - z = y; - y = x; - x = temp; - Call(condition = cond(), ReturnTo(bb1), UnwindContinue()) - } - ret = { - Return() - } + // CHECK-NOT: {{_.*}} = + // CHECK: {{_.*}} = cond() + // CHECK-NOT: {{_.*}} = + // CHECK: _0 = const (); + // CHECK-NOT: {{_.*}} = + while cond() { + let temp = z; + z = y; + y = x; + x = temp; } } fn main() { + // CHECK-LABEL: fn main( cycle(1, 2, 3); } diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff index 311de9e1c93f3..b85f8c10b6aec 100644 --- a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff @@ -30,7 +30,6 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - nop; - StorageLive(_14); - _14 = BitAnd(_5, const 255_u32); - _4 = BitOr(const 0_u32, move _14); diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff index c5fd042161d27..3c6c501237d8e 100644 --- a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff @@ -30,7 +30,6 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - nop; - StorageLive(_14); - _14 = BitAnd(_5, const 255_u32); - _4 = BitOr(const 0_u32, move _14); diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff index 1f88339b5861b..770b7912d97e7 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-abort.diff @@ -40,11 +40,8 @@ bb2: { StorageLive(_7); - _7 = &(*_2)[0 of 3]; StorageLive(_8); - _8 = &(*_2)[1 of 3]; StorageLive(_9); - _9 = &(*_2)[2 of 3]; StorageDead(_9); StorageDead(_8); StorageDead(_7); diff --git a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff index 19a581ba3f096..6114965505805 100644 --- a/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff +++ b/tests/mir-opt/issue_76432.test.SimplifyComparisonIntegral.panic-unwind.diff @@ -40,11 +40,8 @@ bb2: { StorageLive(_7); - _7 = &(*_2)[0 of 3]; StorageLive(_8); - _8 = &(*_2)[1 of 3]; StorageLive(_9); - _9 = &(*_2)[2 of 3]; StorageDead(_9); StorageDead(_8); StorageDead(_7); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff index 465cb1a9b1f41..279cb5cc3b8dd 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-abort.diff @@ -100,19 +100,15 @@ } bb6: { - _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); + nop; StorageDead(_12); StorageDead(_6); -- StorageLive(_17); -+ nop; - _17 = (_5.0: *const [u8]); -- _4 = move _17 as *mut [u8] (PtrToPtr); -- StorageDead(_17); -+ _4 = _17 as *mut [u8] (PtrToPtr); -+ nop; + StorageLive(_17); + nop; + nop; + StorageDead(_17); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = _17 as *mut u8 (PtrToPtr); + nop; StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff index 4a37c8603204b..62bc87217adea 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.32bit.panic-unwind.diff @@ -45,16 +45,12 @@ bb1: { StorageDead(_6); -- StorageLive(_12); -+ nop; - _12 = (_5.0: *const [u8]); -- _4 = move _12 as *mut [u8] (PtrToPtr); -- StorageDead(_12); -+ _4 = _12 as *mut [u8] (PtrToPtr); -+ nop; + StorageLive(_12); + nop; + nop; + StorageDead(_12); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = _12 as *mut u8 (PtrToPtr); + nop; StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff index 925d8997b8a55..2c949be807819 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-abort.diff @@ -100,19 +100,15 @@ } bb6: { - _5 = move ((_6 as Ok).0: std::ptr::NonNull<[u8]>); + nop; StorageDead(_12); StorageDead(_6); -- StorageLive(_17); -+ nop; - _17 = (_5.0: *const [u8]); -- _4 = move _17 as *mut [u8] (PtrToPtr); -- StorageDead(_17); -+ _4 = _17 as *mut [u8] (PtrToPtr); -+ nop; + StorageLive(_17); + nop; + nop; + StorageDead(_17); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = _17 as *mut u8 (PtrToPtr); + nop; StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff index ec2e95fecb620..d6ce27deb76ab 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.main.GVN.64bit.panic-unwind.diff @@ -45,16 +45,12 @@ bb1: { StorageDead(_6); -- StorageLive(_12); -+ nop; - _12 = (_5.0: *const [u8]); -- _4 = move _12 as *mut [u8] (PtrToPtr); -- StorageDead(_12); -+ _4 = _12 as *mut [u8] (PtrToPtr); -+ nop; + StorageLive(_12); + nop; + nop; + StorageDead(_12); StorageDead(_5); -- _3 = move _4 as *mut u8 (PtrToPtr); -+ _3 = _12 as *mut u8 (PtrToPtr); + nop; StorageDead(_4); StorageDead(_3); - StorageDead(_1); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff index 45b8d89c0f4fa..feb924c350739 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff @@ -31,11 +31,10 @@ } bb1: { -- _1 = move (_2.0: i32); -+ _1 = const 4_i32; + nop; StorageLive(_3); StorageLive(_4); - _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + nop; StorageLive(_5); _5 = const 3_usize; _6 = const 6_usize; @@ -46,15 +45,13 @@ } bb2: { -- _3 = _4[_5]; -+ _3 = const 3_i32; + nop; StorageDead(_5); StorageDead(_4); StorageLive(_8); StorageLive(_9); - _9 = const 42_u32; -- _8 = _9; -+ _8 = const 42_u32; + nop; + nop; StorageDead(_9); StorageDead(_8); StorageDead(_3); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff index e6ee1e6f9a348..331a6fae506ac 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff @@ -31,11 +31,10 @@ } bb1: { -- _1 = move (_2.0: i32); -+ _1 = const 4_i32; + nop; StorageLive(_3); StorageLive(_4); - _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + nop; StorageLive(_5); _5 = const 3_usize; _6 = const 6_usize; @@ -46,15 +45,13 @@ } bb2: { -- _3 = _4[_5]; -+ _3 = const 3_i32; + nop; StorageDead(_5); StorageDead(_4); StorageLive(_8); StorageLive(_9); - _9 = const 42_u32; -- _8 = _9; -+ _8 = const 42_u32; + nop; + nop; StorageDead(_9); StorageDead(_8); StorageDead(_3); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff index 45b8d89c0f4fa..feb924c350739 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff @@ -31,11 +31,10 @@ } bb1: { -- _1 = move (_2.0: i32); -+ _1 = const 4_i32; + nop; StorageLive(_3); StorageLive(_4); - _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + nop; StorageLive(_5); _5 = const 3_usize; _6 = const 6_usize; @@ -46,15 +45,13 @@ } bb2: { -- _3 = _4[_5]; -+ _3 = const 3_i32; + nop; StorageDead(_5); StorageDead(_4); StorageLive(_8); StorageLive(_9); - _9 = const 42_u32; -- _8 = _9; -+ _8 = const 42_u32; + nop; + nop; StorageDead(_9); StorageDead(_8); StorageDead(_3); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff index e6ee1e6f9a348..331a6fae506ac 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff @@ -31,11 +31,10 @@ } bb1: { -- _1 = move (_2.0: i32); -+ _1 = const 4_i32; + nop; StorageLive(_3); StorageLive(_4); - _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + nop; StorageLive(_5); _5 = const 3_usize; _6 = const 6_usize; @@ -46,15 +45,13 @@ } bb2: { -- _3 = _4[_5]; -+ _3 = const 3_i32; + nop; StorageDead(_5); StorageDead(_4); StorageLive(_8); StorageLive(_9); - _9 = const 42_u32; -- _8 = _9; -+ _8 = const 42_u32; + nop; + nop; StorageDead(_9); StorageDead(_8); StorageDead(_3); diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir index 681dadff302b9..0c3417bf27dcd 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-abort.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir index 681dadff302b9..0c3417bf27dcd 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.32bit.panic-unwind.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir index 681dadff302b9..0c3417bf27dcd 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-abort.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir index 681dadff302b9..0c3417bf27dcd 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.PreCodegen.after.64bit.panic-unwind.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir index 425b95db3363a..0fd04e3c5ccee 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-abort.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir index 425b95db3363a..0fd04e3c5ccee 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.32bit.panic-unwind.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir index 425b95db3363a..0fd04e3c5ccee 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-abort.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir index 425b95db3363a..0fd04e3c5ccee 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.SimplifyLocals-final.after.64bit.panic-unwind.mir @@ -2,17 +2,26 @@ fn main() -> () { let mut _0: (); + let _1: i32; scope 1 { - debug x => const 4_i32; + debug x => _1; + let _2: i32; scope 2 { - debug y => const 3_i32; + debug y => _2; + let _3: u32; scope 3 { - debug z => const 42_u32; + debug z => _3; } } } bb0: { + StorageLive(_1); + StorageLive(_2); + StorageLive(_3); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } diff --git a/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff index f749586299221..065b6b14ea22d 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff @@ -55,7 +55,6 @@ bb5: { StorageLive(_8); - _8 = ((_2 as Break).0: usize); _0 = const Option::::None; StorageDead(_8); goto -> bb7; diff --git a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts-initial.panic-abort.diff similarity index 54% rename from tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts-initial.panic-abort.diff index 8818c891e94b1..5f57f8b3a0d8b 100644 --- a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `assign_const_to_return` before SingleUseConsts -+ // MIR for `assign_const_to_return` after SingleUseConsts +- // MIR for `assign_const_to_return` before SingleUseConsts-initial ++ // MIR for `assign_const_to_return` after SingleUseConsts-initial fn assign_const_to_return() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts-initial.panic-unwind.diff similarity index 54% rename from tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts-initial.panic-unwind.diff index 8818c891e94b1..5f57f8b3a0d8b 100644 --- a/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.assign_const_to_return.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `assign_const_to_return` before SingleUseConsts -+ // MIR for `assign_const_to_return` after SingleUseConsts +- // MIR for `assign_const_to_return` before SingleUseConsts-initial ++ // MIR for `assign_const_to_return` after SingleUseConsts-initial fn assign_const_to_return() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.if_const.SingleUseConsts-initial.panic-abort.diff similarity index 83% rename from tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.if_const.SingleUseConsts-initial.panic-abort.diff index 468076e5ee3ce..f691f07c1cf82 100644 --- a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.if_const.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const` before SingleUseConsts -+ // MIR for `if_const` after SingleUseConsts +- // MIR for `if_const` before SingleUseConsts-initial ++ // MIR for `if_const` after SingleUseConsts-initial fn if_const() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.if_const.SingleUseConsts-initial.panic-unwind.diff similarity index 83% rename from tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.if_const.SingleUseConsts-initial.panic-unwind.diff index 468076e5ee3ce..f691f07c1cf82 100644 --- a/tests/mir-opt/single_use_consts.if_const.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.if_const.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const` before SingleUseConsts -+ // MIR for `if_const` after SingleUseConsts +- // MIR for `if_const` before SingleUseConsts-initial ++ // MIR for `if_const` after SingleUseConsts-initial fn if_const() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts-initial.panic-abort.diff similarity index 88% rename from tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts-initial.panic-abort.diff index ad1a2b300f2a9..73ae583b7a00d 100644 --- a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const_debug` before SingleUseConsts -+ // MIR for `if_const_debug` after SingleUseConsts +- // MIR for `if_const_debug` before SingleUseConsts-initial ++ // MIR for `if_const_debug` after SingleUseConsts-initial fn if_const_debug() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts-initial.panic-unwind.diff similarity index 88% rename from tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts-initial.panic-unwind.diff index 827a292e5d024..7db6ed106eae4 100644 --- a/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.if_const_debug.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `if_const_debug` before SingleUseConsts -+ // MIR for `if_const_debug` after SingleUseConsts +- // MIR for `if_const_debug` before SingleUseConsts-initial ++ // MIR for `if_const_debug` after SingleUseConsts-initial fn if_const_debug() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts-initial.panic-abort.diff similarity index 63% rename from tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts-initial.panic-abort.diff index f7d823af9e3d7..e143f2b3d2641 100644 --- a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `keep_parameter` before SingleUseConsts -+ // MIR for `keep_parameter` after SingleUseConsts +- // MIR for `keep_parameter` before SingleUseConsts-initial ++ // MIR for `keep_parameter` after SingleUseConsts-initial fn keep_parameter(_1: i32) -> () { debug other => _1; diff --git a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts-initial.panic-unwind.diff similarity index 63% rename from tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts-initial.panic-unwind.diff index f7d823af9e3d7..e143f2b3d2641 100644 --- a/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.keep_parameter.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `keep_parameter` before SingleUseConsts -+ // MIR for `keep_parameter` after SingleUseConsts +- // MIR for `keep_parameter` before SingleUseConsts-initial ++ // MIR for `keep_parameter` after SingleUseConsts-initial fn keep_parameter(_1: i32) -> () { debug other => _1; diff --git a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts-initial.panic-abort.diff similarity index 85% rename from tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.match_const.SingleUseConsts-initial.panic-abort.diff index 8d87438a47aec..d150752b80105 100644 --- a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const` before SingleUseConsts -+ // MIR for `match_const` after SingleUseConsts +- // MIR for `match_const` before SingleUseConsts-initial ++ // MIR for `match_const` after SingleUseConsts-initial fn match_const() -> &str { let mut _0: &str; diff --git a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts-initial.panic-unwind.diff similarity index 85% rename from tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.match_const.SingleUseConsts-initial.panic-unwind.diff index 8d87438a47aec..d150752b80105 100644 --- a/tests/mir-opt/single_use_consts.match_const.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.match_const.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const` before SingleUseConsts -+ // MIR for `match_const` after SingleUseConsts +- // MIR for `match_const` before SingleUseConsts-initial ++ // MIR for `match_const` after SingleUseConsts-initial fn match_const() -> &str { let mut _0: &str; diff --git a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts-initial.panic-abort.diff similarity index 87% rename from tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts-initial.panic-abort.diff index f192f3feb96e5..98b7adcc2fe13 100644 --- a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const_debug` before SingleUseConsts -+ // MIR for `match_const_debug` after SingleUseConsts +- // MIR for `match_const_debug` before SingleUseConsts-initial ++ // MIR for `match_const_debug` after SingleUseConsts-initial fn match_const_debug() -> &str { let mut _0: &str; diff --git a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts-initial.panic-unwind.diff similarity index 87% rename from tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts-initial.panic-unwind.diff index 261faf415f3bc..4f466e922e52d 100644 --- a/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.match_const_debug.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `match_const_debug` before SingleUseConsts -+ // MIR for `match_const_debug` after SingleUseConsts +- // MIR for `match_const_debug` before SingleUseConsts-initial ++ // MIR for `match_const_debug` after SingleUseConsts-initial fn match_const_debug() -> &str { let mut _0: &str; diff --git a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff b/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts-initial.panic-abort.diff similarity index 75% rename from tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff rename to tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts-initial.panic-abort.diff index 8ef94a790a343..50e76c909c55e 100644 --- a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-abort.diff +++ b/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts-initial.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `never_used_debug` before SingleUseConsts -+ // MIR for `never_used_debug` after SingleUseConsts +- // MIR for `never_used_debug` before SingleUseConsts-initial ++ // MIR for `never_used_debug` after SingleUseConsts-initial fn never_used_debug() -> () { let mut _0: (); diff --git a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff b/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts-initial.panic-unwind.diff similarity index 75% rename from tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff rename to tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts-initial.panic-unwind.diff index 8ef94a790a343..50e76c909c55e 100644 --- a/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts.panic-unwind.diff +++ b/tests/mir-opt/single_use_consts.never_used_debug.SingleUseConsts-initial.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `never_used_debug` before SingleUseConsts -+ // MIR for `never_used_debug` after SingleUseConsts +- // MIR for `never_used_debug` before SingleUseConsts-initial ++ // MIR for `never_used_debug` after SingleUseConsts-initial fn never_used_debug() -> () { let mut _0: (); diff --git a/tests/mir-opt/single_use_consts.rs b/tests/mir-opt/single_use_consts.rs index ecb602c647a50..d296f1ea11058 100644 --- a/tests/mir-opt/single_use_consts.rs +++ b/tests/mir-opt/single_use_consts.rs @@ -1,4 +1,4 @@ -//@ test-mir-pass: SingleUseConsts +//@ test-mir-pass: SingleUseConsts-initial //@ compile-flags: -C debuginfo=full // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -7,14 +7,14 @@ trait MyTrait { const ASSOC_INT: i32; } -// EMIT_MIR single_use_consts.if_const.SingleUseConsts.diff +// EMIT_MIR single_use_consts.if_const.SingleUseConsts-initial.diff fn if_const() -> i32 { // CHECK-LABEL: fn if_const( // CHECK: switchInt(const ::ASSOC_BOOL) if T::ASSOC_BOOL { 7 } else { 42 } } -// EMIT_MIR single_use_consts.match_const.SingleUseConsts.diff +// EMIT_MIR single_use_consts.match_const.SingleUseConsts-initial.diff fn match_const() -> &'static str { // CHECK-LABEL: fn match_const( // CHECK: switchInt(const ::ASSOC_INT) @@ -25,7 +25,7 @@ fn match_const() -> &'static str { } } -// EMIT_MIR single_use_consts.if_const_debug.SingleUseConsts.diff +// EMIT_MIR single_use_consts.if_const_debug.SingleUseConsts-initial.diff fn if_const_debug() -> i32 { // CHECK-LABEL: fn if_const_debug( // CHECK: my_bool => const ::ASSOC_BOOL; @@ -37,7 +37,7 @@ fn if_const_debug() -> i32 { if my_bool { 7 } else { 42 } } -// EMIT_MIR single_use_consts.match_const_debug.SingleUseConsts.diff +// EMIT_MIR single_use_consts.match_const_debug.SingleUseConsts-initial.diff fn match_const_debug() -> &'static str { // CHECK-LABEL: fn match_const_debug( // CHECK: my_int => const ::ASSOC_INT; @@ -51,7 +51,7 @@ fn match_const_debug() -> &'static str { } } -// EMIT_MIR single_use_consts.never_used_debug.SingleUseConsts.diff +// EMIT_MIR single_use_consts.never_used_debug.SingleUseConsts-initial.diff #[allow(unused_variables)] fn never_used_debug() { // CHECK-LABEL: fn never_used_debug( @@ -62,14 +62,14 @@ fn never_used_debug() { let my_int = T::ASSOC_INT; } -// EMIT_MIR single_use_consts.assign_const_to_return.SingleUseConsts.diff +// EMIT_MIR single_use_consts.assign_const_to_return.SingleUseConsts-initial.diff fn assign_const_to_return() -> bool { // CHECK-LABEL: fn assign_const_to_return( // CHECK: _0 = const ::ASSOC_BOOL; T::ASSOC_BOOL } -// EMIT_MIR single_use_consts.keep_parameter.SingleUseConsts.diff +// EMIT_MIR single_use_consts.keep_parameter.SingleUseConsts-initial.diff fn keep_parameter(mut other: i32) { // CHECK-LABEL: fn keep_parameter( // CHECK: _1 = const ::ASSOC_INT; diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr index a50c49d536251..20ada73a2a4e2 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.noopt.stderr @@ -7,13 +7,13 @@ LL | const C: () = panic!(); = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $DIR/collect-in-promoted-const.rs:20:21 + --> $DIR/collect-in-promoted-const.rs:17:21 | LL | let _val = &Fail::::C; | ^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn f::` - --> $DIR/collect-in-promoted-const.rs:25:5 + --> $DIR/collect-in-promoted-const.rs:22:5 | LL | f::(); | ^^^^^^^^^^ diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr index cf0aa8ef7a73d..20ada73a2a4e2 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.opt.stderr @@ -1,17 +1,3 @@ -error[E0080]: evaluation of `Fail::::C` failed - --> $DIR/collect-in-promoted-const.rs:9:19 - | -LL | const C: () = panic!(); - | ^^^^^^^^ the evaluated program panicked at 'explicit panic', $DIR/collect-in-promoted-const.rs:9:19 - | - = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) - -note: erroneous constant encountered - --> $DIR/collect-in-promoted-const.rs:20:21 - | -LL | let _val = &Fail::::C; - | ^^^^^^^^^^^^ - error[E0080]: evaluation of `Fail::::C` failed --> $DIR/collect-in-promoted-const.rs:9:19 | @@ -21,19 +7,17 @@ LL | const C: () = panic!(); = note: this error originates in the macro `$crate::panic::panic_2015` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $DIR/collect-in-promoted-const.rs:20:21 + --> $DIR/collect-in-promoted-const.rs:17:21 | LL | let _val = &Fail::::C; | ^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn f::` - --> $DIR/collect-in-promoted-const.rs:25:5 + --> $DIR/collect-in-promoted-const.rs:22:5 | LL | f::(); | ^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/required-consts/collect-in-promoted-const.rs b/tests/ui/consts/required-consts/collect-in-promoted-const.rs index 4a3ce92e8f90d..6e2e0e26aba0b 100644 --- a/tests/ui/consts/required-consts/collect-in-promoted-const.rs +++ b/tests/ui/consts/required-consts/collect-in-promoted-const.rs @@ -7,9 +7,6 @@ struct Fail(T); impl Fail { const C: () = panic!(); //~ERROR evaluation of `Fail::::C` failed - //[opt]~^ ERROR evaluation of `Fail::::C` failed - // (Not sure why optimizations lead to this being emitted twice, but as long as compilation - // fails either way it's fine.) } #[inline(never)]