diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 5bbe3bb747fd9..029055affcdcc 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, Options}; use smallvec::SmallVec; pub enum SimplifyCfg { @@ -373,9 +374,15 @@ impl<'tcx> MirPass<'tcx> for SimplifyLocals { } } -pub fn remove_unused_definitions<'tcx>(body: &mut Body<'tcx>) { +/// Go through the basic blocks and remove statements that assign locals that aren't read. +/// +/// This does *not* clean up the `local_decl`s. If you want it to do that too, +/// call [`simplify_locals`] instead of this. +pub(crate) fn remove_unused_definitions<'tcx>(body: &mut Body<'tcx>) { + let preserve_debug = true; + // First, we're going to get a count of *actual* uses for every `Local`. - let mut used_locals = UsedLocals::new(body); + let mut used_locals = UsedLocals::new(body, preserve_debug); // Next, we're going to remove any `Local` with zero actual uses. When we remove those // `Locals`, we're also going to subtract any uses of other `Locals` from the `used_locals` @@ -385,9 +392,18 @@ pub fn remove_unused_definitions<'tcx>(body: &mut Body<'tcx>) { remove_unused_definitions_helper(&mut used_locals, body); } -pub fn simplify_locals<'tcx>(body: &mut Body<'tcx>, tcx: TyCtxt<'tcx>) { +/// Go through the basic blocks and remove statements that assign locals that aren't read. +/// +/// Then go through and remove unneeded `local_decl`s, rewriting all mentions of them +/// in all the statements. +/// +/// If you only want the (faster) statement pruning, call [`remove_unused_definitions`] +/// instead of this. +pub(crate) fn simplify_locals<'tcx>(body: &mut Body<'tcx>, tcx: TyCtxt<'tcx>) { + let preserve_debug = preserve_debug_even_if_never_generated(&tcx.sess.opts); + // First, we're going to get a count of *actual* uses for every `Local`. - let mut used_locals = UsedLocals::new(body); + let mut used_locals = UsedLocals::new(body, preserve_debug); // Next, we're going to remove any `Local` with zero actual uses. When we remove those // `Locals`, we're also going to subtract any uses of other `Locals` from the `used_locals` @@ -438,15 +454,17 @@ struct UsedLocals { increment: bool, arg_count: u32, use_count: IndexVec, + preserve_debug: bool, } impl UsedLocals { /// Determines which locals are used & unused in the given body. - fn new(body: &Body<'_>) -> Self { + fn new(body: &Body<'_>, preserve_debug: bool) -> Self { let mut this = Self { increment: true, arg_count: body.arg_count.try_into().unwrap(), use_count: IndexVec::from_elem(0, &body.local_decls), + preserve_debug, }; this.visit_body(body); this @@ -527,6 +545,17 @@ impl<'tcx> Visitor<'tcx> for UsedLocals { self.use_count[local] -= 1; } } + + fn visit_var_debug_info(&mut self, var_debug_info: &VarDebugInfo<'tcx>) { + // We don't want to have to track *conditional* uses (such as + // "`_4` is used iff `_5` is used" from `debug x => Foo(_4, _5)`), + // so if this mentions multiple locals we just treat them all as used. + if !self.preserve_debug && debug_info_is_for_single_local(var_debug_info).is_some() { + return; + } + + self.super_var_debug_info(var_debug_info); + } } /// Removes unused definitions. Updates the used locals to reflect the changes made. @@ -540,6 +569,26 @@ fn remove_unused_definitions_helper(used_locals: &mut UsedLocals, body: &mut Bod while modified { modified = false; + if !used_locals.preserve_debug { + body.var_debug_info.retain(|info| { + let keep = if let Some(local) = debug_info_is_for_single_local(info) { + used_locals.is_used(local) + } else { + true + }; + + if !keep { + trace!("removing var_debug_info {:?}", info); + + // While we did modify the debug info, we don't need to set the + // `modified` flag, as we didn't change `used_locals`, and thus + // we don't need to re-run the loop to look again. + } + + keep + }); + } + for data in body.basic_blocks.as_mut_preserves_cfg() { // Remove unnecessary StorageLive and StorageDead annotations. data.statements.retain(|statement| { @@ -581,3 +630,35 @@ impl<'tcx> MutVisitor<'tcx> for LocalUpdater<'tcx> { *l = self.map[*l].unwrap(); } } + +fn preserve_debug_even_if_never_generated(opts: &Options) -> bool { + if let Some(p) = opts.unstable_opts.inline_mir_preserve_debug { + return p; + } + + match opts.debuginfo { + DebugInfo::None | DebugInfo::LineDirectivesOnly | DebugInfo::LineTablesOnly => false, + DebugInfo::Limited | DebugInfo::Full => true, + } +} + +/// Returns the only [`Local`] mentioned in `info`, if there's exactly one. +/// Otherwise return `None` if this mentions no `Local`s (probably because +/// it's [`VarDebugInfoContents::Const`]) or multiple `Local`s. +fn debug_info_is_for_single_local(info: &VarDebugInfo<'_>) -> Option { + struct SingleLocalFinder(Result, ()>); + impl Visitor<'_> for SingleLocalFinder { + fn visit_local(&mut self, local: Local, _ctx: PlaceContext, _location: Location) { + match &mut self.0 { + Err(()) => {} + Ok(opt @ None) => *opt = Some(local), + Ok(Some(current)) if *current == local => {} + res @ Ok(Some(_)) => *res = Err(()), + } + } + } + + let mut finder = SingleLocalFinder(Ok(None)); + finder.visit_var_debug_info(info); + if let Ok(Some(local)) = finder.0 { Some(local) } else { None } +} diff --git a/tests/codegen/slice-init.rs b/tests/codegen/slice-init.rs index 8126bf84618aa..62dd2adb9c0c3 100644 --- a/tests/codegen/slice-init.rs +++ b/tests/codegen/slice-init.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -C no-prepopulate-passes +//@ compile-flags: -C no-prepopulate-passes -C debuginfo=2 #![crate_type = "lib"] diff --git a/tests/crashes/101962.rs b/tests/crashes/101962.rs deleted file mode 100644 index b6a78ce053af0..0000000000000 --- a/tests/crashes/101962.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #101962 - -#![feature(core_intrinsics)] - -pub fn wrapping(a: T, b: T) { - let _z = core::intrinsics::wrapping_mul(a, b); -} - -fn main() { - wrapping(1,2); -} diff --git a/tests/crashes/79409.rs b/tests/crashes/79409.rs index 98b5f60633627..b5466f55b7d76 100644 --- a/tests/crashes/79409.rs +++ b/tests/crashes/79409.rs @@ -1,4 +1,6 @@ //@ known-bug: #79409 +//@ compile-flags: -Z mir-opt-level=0 +// (Only fails if the use of the place isn't optimized out) #![feature(extern_types)] #![feature(unsized_locals)] diff --git a/tests/incremental/hashes/enum_constructors.rs b/tests/incremental/hashes/enum_constructors.rs index d839dabf293af..374d8ff01b336 100644 --- a/tests/incremental/hashes/enum_constructors.rs +++ b/tests/incremental/hashes/enum_constructors.rs @@ -301,9 +301,9 @@ pub fn change_constructor_path_c_like() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn change_constructor_path_c_like() { let _x = Clike2::B; @@ -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..ebfdc2b36617a 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; @@ -53,9 +53,9 @@ pub fn change_iteration_variable_name() { } #[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_iteration_variable_name() { let mut _x = 0; @@ -78,9 +78,9 @@ pub fn change_iteration_variable_pattern() { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, optimized_mir, typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes, typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, optimized_mir, typeck")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes, typeck")] #[rustc_clean(cfg="cfail6")] pub fn change_iteration_variable_pattern() { 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/if_expressions.rs b/tests/incremental/hashes/if_expressions.rs index a21625c4f4ed8..01e2fd64aef75 100644 --- a/tests/incremental/hashes/if_expressions.rs +++ b/tests/incremental/hashes/if_expressions.rs @@ -131,9 +131,9 @@ pub fn change_condition_if_let(x: Option) -> u32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn change_condition_if_let(x: Option) -> u32 { if let Some(_ ) = x { diff --git a/tests/incremental/hashes/let_expressions.rs b/tests/incremental/hashes/let_expressions.rs index 86578855699b2..67080f0922f97 100644 --- a/tests/incremental/hashes/let_expressions.rs +++ b/tests/incremental/hashes/let_expressions.rs @@ -23,9 +23,9 @@ pub fn change_name() { } #[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_name() { let _y = 2u64; @@ -57,9 +57,9 @@ pub fn change_type() { } #[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 change_type() { let _x: u8 = 2; @@ -74,9 +74,9 @@ pub fn change_mutability_of_reference_type() { } #[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 change_mutability_of_reference_type() { let _x: &mut u64; @@ -93,7 +93,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="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 change_mutability_of_slot() { let _x: u64 = 0; @@ -108,9 +108,9 @@ pub fn change_simple_binding_to_pattern() { } #[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 change_simple_binding_to_pattern() { let (_a, _b) = (0u8, 'x'); @@ -125,9 +125,9 @@ pub fn change_name_in_pattern() { } #[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_name_in_pattern() { let (_a, _c) = (1u8, 'y'); @@ -142,9 +142,9 @@ pub fn add_ref_in_pattern() { } #[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_ref_in_pattern() { let (ref _a, _b) = (1u8, 'y'); @@ -159,9 +159,9 @@ pub fn add_amp_in_pattern() { } #[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_amp_in_pattern() { let (&_a, _b) = (&1u8, 'y'); @@ -178,7 +178,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="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 change_mutability_of_binding_in_pattern() { let (mut _a, _b) = (99u8, 'q'); @@ -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..3f85457a78533 100644 --- a/tests/incremental/hashes/match_expressions.rs +++ b/tests/incremental/hashes/match_expressions.rs @@ -154,9 +154,9 @@ pub fn change_name_of_at_binding(x: u32) -> u32 { } #[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_name_of_at_binding(x: u32) -> u32 { match x { @@ -178,7 +178,7 @@ pub fn change_simple_name_to_pattern(x: u32) -> u32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] #[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] #[rustc_clean(cfg="cfail6")] @@ -202,9 +202,9 @@ pub fn change_name_in_pattern(x: u32) -> u32 { } #[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_name_in_pattern(x: u32) -> u32 { match (x, x & 1) { @@ -229,7 +229,7 @@ pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { #[cfg(not(any(cfail1,cfail4)))] #[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn change_mutability_of_binding_in_pattern(x: u32) -> u32 { match (x, x & 1) { @@ -250,9 +250,9 @@ pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn add_ref_to_binding_in_pattern(x: u32) -> u32 { match (x, x & 1) { @@ -273,9 +273,9 @@ pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 { } #[cfg(not(any(cfail1,cfail4)))] -#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail2", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail3")] -#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,optimized_mir,typeck")] +#[rustc_clean(cfg="cfail5", except="opt_hir_owner_nodes,typeck")] #[rustc_clean(cfg="cfail6")] pub fn add_amp_to_binding_in_pattern(x: u32) -> u32 { match (&x, x & 1) { 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.rs b/tests/mir-opt/const_debuginfo.rs index 3b2bc4559ced9..6d19f8daba575 100644 --- a/tests/mir-opt/const_debuginfo.rs +++ b/tests/mir-opt/const_debuginfo.rs @@ -1,5 +1,5 @@ //@ test-mir-pass: SingleUseConsts -//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN -Zdump-mir-exclude-alloc-bytes +//@ compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN -Zdump-mir-exclude-alloc-bytes -C debuginfo=full #![allow(unused)] diff --git a/tests/mir-opt/issue_76432.rs b/tests/mir-opt/issue_76432.rs index 6d884063caafb..8cd208bb3cf25 100644 --- a/tests/mir-opt/issue_76432.rs +++ b/tests/mir-opt/issue_76432.rs @@ -1,4 +1,5 @@ // skip-filecheck +//@ compile-flags: -C debuginfo=full // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // Check that we do not insert StorageDead at each target if StorageDead was never seen diff --git a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir index 47f10451b057c..22a77a5d1da1e 100644 --- a/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/derived_ord.{impl#0}-partial_cmp.PreCodegen.after.mir @@ -7,7 +7,6 @@ fn ::partial_cmp(_1: &MultiField, _2: &M let mut _6: std::option::Option; let mut _7: i8; scope 1 { - debug cmp => _6; } scope 2 (inlined std::cmp::impls::::partial_cmp) { let mut _3: char; 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..4b6ff4f26c74f 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 @@ -18,26 +18,34 @@ debug ptr => _3; } scope 5 (inlined ::allocate) { + debug self => _9; + debug layout => _8; } scope 6 (inlined #[track_caller] Result::, std::alloc::AllocError>::unwrap) { + debug self => _6; let mut _12: isize; let _13: std::alloc::AllocError; let mut _14: !; let mut _15: &dyn std::fmt::Debug; let mut _16: &std::alloc::AllocError; scope 7 { + debug t => _5; } scope 8 { + debug e => const std::alloc::AllocError; } } scope 9 (inlined NonNull::<[u8]>::as_ptr) { + debug self => _5; let mut _17: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { + debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { + debug val => _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..603b140556226 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 @@ -18,15 +18,20 @@ debug ptr => _3; } scope 5 (inlined ::allocate) { + debug self => _9; + debug layout => _8; } scope 6 (inlined NonNull::<[u8]>::as_ptr) { + debug self => _5; let mut _12: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { + debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { + debug val => _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..db6c4f149a7aa 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 @@ -18,26 +18,34 @@ debug ptr => _3; } scope 5 (inlined ::allocate) { + debug self => _9; + debug layout => _8; } scope 6 (inlined #[track_caller] Result::, std::alloc::AllocError>::unwrap) { + debug self => _6; let mut _12: isize; let _13: std::alloc::AllocError; let mut _14: !; let mut _15: &dyn std::fmt::Debug; let mut _16: &std::alloc::AllocError; scope 7 { + debug t => _5; } scope 8 { + debug e => const std::alloc::AllocError; } } scope 9 (inlined NonNull::<[u8]>::as_ptr) { + debug self => _5; let mut _17: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { + debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { + debug val => _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..5fd4af21a11bc 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 @@ -18,15 +18,20 @@ debug ptr => _3; } scope 5 (inlined ::allocate) { + debug self => _9; + debug layout => _8; } scope 6 (inlined NonNull::<[u8]>::as_ptr) { + debug self => _5; let mut _12: *const [u8]; } } scope 3 (inlined #[track_caller] Option::::unwrap) { + debug self => _2; let mut _10: isize; let mut _11: !; scope 4 { + debug val => _1; } } diff --git a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs index c92424f298314..ee3b807004cb2 100644 --- a/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs +++ b/tests/mir-opt/pre-codegen/issue_117368_print_invalid_constant.rs @@ -1,6 +1,7 @@ // Verify that we do not ICE when printing an invalid constant. // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_PANIC_STRATEGY +//@ compile-flags: -C debuginfo=full #![feature(allocator_api)] diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs index 44b4b0ad888a5..fc4ea21beca64 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs @@ -1,6 +1,6 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -//@ compile-flags: -C overflow-checks=on -Zdump-mir-exclude-alloc-bytes +//@ compile-flags: -C overflow-checks=on -Zdump-mir-exclude-alloc-bytes -C debuginfo=full struct Point { x: u32, diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir index 96b4962854de9..306b413cf5597 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-abort.mir @@ -12,7 +12,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let _13: (); scope 1 { debug ((iter: std::ops::Range).0: u32) => _4; - debug ((iter: std::ops::Range).1: u32) => _2; let _10: u32; scope 2 { debug x => _10; diff --git a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir index ce8e2bd083ed4..5ede84ccba5d5 100644 --- a/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.forward_loop.PreCodegen.after.panic-unwind.mir @@ -12,7 +12,6 @@ fn forward_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { let _13: (); scope 1 { debug ((iter: std::ops::Range).0: u32) => _4; - debug ((iter: std::ops::Range).1: u32) => _2; let _10: u32; scope 2 { debug x => _10; diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir index cea2fcbcdc0b2..c6f99e6ce46ea 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-abort.mir @@ -14,7 +14,6 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _16: (); scope 1 { debug ((iter: std::ops::Range).0: usize) => _4; - debug ((iter: std::ops::Range).1: usize) => _3; let _10: usize; scope 2 { debug i => _10; diff --git a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir index bd658a770ea91..083fa93dcca39 100644 --- a/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/slice_iter.range_loop.PreCodegen.after.panic-unwind.mir @@ -14,7 +14,6 @@ fn range_loop(_1: &[T], _2: impl Fn(usize, &T)) -> () { let _16: (); scope 1 { debug ((iter: std::ops::Range).0: usize) => _4; - debug ((iter: std::ops::Range).1: usize) => _3; let _10: usize; scope 2 { debug i => _10; 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..b5db8d2312e25 100644 --- a/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff +++ b/tests/mir-opt/separate_const_switch.too_complex.JumpThreading.diff @@ -10,7 +10,6 @@ let _5: usize; let mut _6: isize; let _7: i32; - let _8: usize; scope 1 { debug v => _4; } @@ -21,7 +20,6 @@ debug v => _7; } scope 4 { - debug r => _8; } bb0: { @@ -54,10 +52,7 @@ } bb5: { - StorageLive(_8); - _8 = ((_2 as Break).0: usize); _0 = const Option::::None; - StorageDead(_8); goto -> bb7; } diff --git a/tests/mir-opt/simplify_locals.c.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals.c.SimplifyLocals-before-const-prop.diff index 7cc5e335cb00a..d5ab4c6b627bc 100644 --- a/tests/mir-opt/simplify_locals.c.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals.c.SimplifyLocals-before-const-prop.diff @@ -3,19 +3,19 @@ fn c() -> () { let mut _0: (); - let _1: [u8; 10]; +- let _1: [u8; 10]; - let mut _2: &[u8]; - let mut _3: &[u8; 10]; - let _4: &[u8; 10]; scope 1 { - debug bytes => _1; +- debug bytes => _1; scope 2 { } } bb0: { - StorageLive(_1); - _1 = [const 0_u8; 10]; +- StorageLive(_1); +- _1 = [const 0_u8; 10]; - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); @@ -26,7 +26,7 @@ - StorageDead(_4); - StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); return; } } diff --git a/tests/mir-opt/simplify_locals.r.SimplifyLocals-before-const-prop.diff b/tests/mir-opt/simplify_locals.r.SimplifyLocals-before-const-prop.diff index c9f7785a4994c..6cbcbb804a48b 100644 --- a/tests/mir-opt/simplify_locals.r.SimplifyLocals-before-const-prop.diff +++ b/tests/mir-opt/simplify_locals.r.SimplifyLocals-before-const-prop.diff @@ -3,11 +3,11 @@ fn r() -> () { let mut _0: (); - let mut _1: i32; +- let mut _1: i32; - let mut _2: &i32; - let mut _3: &mut i32; scope 1 { - debug a => _1; +- debug a => _1; scope 2 { scope 3 { } @@ -15,8 +15,8 @@ } bb0: { - StorageLive(_1); - _1 = const 1_i32; +- StorageLive(_1); +- _1 = const 1_i32; - StorageLive(_2); - _2 = &_1; - StorageDead(_2); @@ -24,7 +24,7 @@ - _3 = &mut _1; - StorageDead(_3); _0 = const (); - StorageDead(_1); +- StorageDead(_1); return; } } diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff index c520a159f47b2..5883b70ccd7aa 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-abort.diff @@ -9,8 +9,6 @@ let mut _4: isize; let mut _5: isize; scope 1 { - debug a => _6; - let _6: u8; } bb0: { @@ -23,31 +21,24 @@ StorageDead(_3); StorageDead(_2); _5 = discriminant((_1.0: std::option::Option)); - switchInt(move _5) -> [1: bb1, 0: bb3, otherwise: bb5]; + switchInt(move _5) -> [1: bb1, 0: bb2, otherwise: bb4]; } bb1: { _4 = discriminant((_1.1: std::option::Option)); - switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb5]; + switchInt(move _4) -> [0: bb2, 1: bb2, otherwise: bb4]; } bb2: { - StorageLive(_6); - _6 = (((_1.0: std::option::Option) as Some).0: u8); - StorageDead(_6); - goto -> bb3; + drop(_1) -> [return: bb3, unwind unreachable]; } bb3: { - drop(_1) -> [return: bb4, unwind unreachable]; - } - - bb4: { StorageDead(_1); return; } - bb5: { + bb4: { unreachable; } } diff --git a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff index 686581591fc4e..ed0be0942a518 100644 --- a/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff +++ b/tests/mir-opt/simplify_locals_fixedpoint.foo.SimplifyLocals-final.panic-unwind.diff @@ -9,8 +9,6 @@ let mut _4: isize; let mut _5: isize; scope 1 { - debug a => _6; - let _6: u8; } bb0: { @@ -23,31 +21,24 @@ StorageDead(_3); StorageDead(_2); _5 = discriminant((_1.0: std::option::Option)); - switchInt(move _5) -> [1: bb1, 0: bb3, otherwise: bb5]; + switchInt(move _5) -> [1: bb1, 0: bb2, otherwise: bb4]; } bb1: { _4 = discriminant((_1.1: std::option::Option)); - switchInt(move _4) -> [0: bb2, 1: bb3, otherwise: bb5]; + switchInt(move _4) -> [0: bb2, 1: bb2, otherwise: bb4]; } bb2: { - StorageLive(_6); - _6 = (((_1.0: std::option::Option) as Some).0: u8); - StorageDead(_6); - goto -> bb3; + drop(_1) -> [return: bb3, unwind continue]; } bb3: { - drop(_1) -> [return: bb4, unwind continue]; - } - - bb4: { StorageDead(_1); return; } - bb5: { + bb4: { unreachable; } } diff --git a/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir b/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir index 240f409817d77..949904203bc64 100644 --- a/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir +++ b/tests/mir-opt/uninhabited_enum.process_never.SimplifyLocals-final.after.mir @@ -3,9 +3,7 @@ fn process_never(_1: *const !) -> () { debug input => _1; let mut _0: (); - let _2: &!; scope 1 { - debug _input => _2; } bb0: { diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 7752ff51ac811..db2e8c03dbe3d 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -224,6 +224,7 @@ fn main() { let args = vec![ "rustc".to_string(), "--edition=2021".to_string(), + "-Cdebuginfo=full".to_string(), "--crate-name".to_string(), CRATE_NAME.to_string(), path.to_string(), diff --git a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs index 0b8cfcf27fd9b..0079f9209526e 100644 --- a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs +++ b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs @@ -81,6 +81,7 @@ fn main() { let args = vec![ "rustc".to_string(), "-Cpanic=abort".to_string(), + "-Cdebuginfo=full".to_string(), "--crate-name".to_string(), CRATE_NAME.to_string(), path.to_string(), 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)] diff --git a/tests/ui/extern/extern-types-field-offset.rs b/tests/ui/extern/extern-types-field-offset.rs index e9c4bb7b23046..e0c505797c655 100644 --- a/tests/ui/extern/extern-types-field-offset.rs +++ b/tests/ui/extern/extern-types-field-offset.rs @@ -2,6 +2,9 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=0 //@ normalize-stderr-test: "(core/src/panicking\.rs):[0-9]+:[0-9]+" -> "$1:$$LINE:$$COL" +//@ compile-flags: -Z mir-opt-level=0 +// (Don't optimize out the unused locals, so that we actually compute the offsets.) +// FIXME: As part of fixing #127336, re-enable the normal mir-opts. #![feature(extern_types)] extern "C" { diff --git a/tests/ui/limits/huge-array-simple-32.rs b/tests/ui/limits/huge-array-simple-32.rs index 6ff981cd160ab..d0bed25de4ad9 100644 --- a/tests/ui/limits/huge-array-simple-32.rs +++ b/tests/ui/limits/huge-array-simple-32.rs @@ -1,6 +1,9 @@ //@ ignore-64bit //@ build-fail +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + #![allow(arithmetic_overflow)] fn main() { diff --git a/tests/ui/limits/huge-array-simple-32.stderr b/tests/ui/limits/huge-array-simple-32.stderr index 1b86b02297f34..f00743c36bfc7 100644 --- a/tests/ui/limits/huge-array-simple-32.stderr +++ b/tests/ui/limits/huge-array-simple-32.stderr @@ -1,5 +1,5 @@ error: values of the type `[u8; 2147516416]` are too big for the current architecture - --> $DIR/huge-array-simple-32.rs:7:9 + --> $DIR/huge-array-simple-32.rs:10:9 | LL | let _fat: [u8; (1<<31)+(1<<15)] = | ^^^^ diff --git a/tests/ui/limits/huge-array-simple-64.rs b/tests/ui/limits/huge-array-simple-64.rs index 13b284503bf52..db5ab0de72479 100644 --- a/tests/ui/limits/huge-array-simple-64.rs +++ b/tests/ui/limits/huge-array-simple-64.rs @@ -1,6 +1,9 @@ //@ build-fail //@ ignore-32bit +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + #![allow(arithmetic_overflow)] fn main() { diff --git a/tests/ui/limits/huge-array-simple-64.stderr b/tests/ui/limits/huge-array-simple-64.stderr index 8d395c3c6a959..c8882188d4a09 100644 --- a/tests/ui/limits/huge-array-simple-64.stderr +++ b/tests/ui/limits/huge-array-simple-64.stderr @@ -1,5 +1,5 @@ error: values of the type `[u8; 2305843011361177600]` are too big for the current architecture - --> $DIR/huge-array-simple-64.rs:7:9 + --> $DIR/huge-array-simple-64.rs:10:9 | LL | let _fat: [u8; (1<<61)+(1<<31)] = | ^^^^ diff --git a/tests/ui/limits/huge-array.rs b/tests/ui/limits/huge-array.rs index 97cfd1ff8fb2c..31b41a1efd70e 100644 --- a/tests/ui/limits/huge-array.rs +++ b/tests/ui/limits/huge-array.rs @@ -1,5 +1,8 @@ //@ build-fail +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + fn generic(t: T) { let s: [T; 1518600000] = [t; 1518600000]; //~^ ERROR values of the type `[[u8; 1518599999]; 1518600000]` are too big diff --git a/tests/ui/limits/huge-array.stderr b/tests/ui/limits/huge-array.stderr index 2ebaf17a138cd..241e33d85b995 100644 --- a/tests/ui/limits/huge-array.stderr +++ b/tests/ui/limits/huge-array.stderr @@ -1,5 +1,5 @@ error: values of the type `[[u8; 1518599999]; 1518600000]` are too big for the current architecture - --> $DIR/huge-array.rs:4:9 + --> $DIR/huge-array.rs:7:9 | LL | let s: [T; 1518600000] = [t; 1518600000]; | ^ diff --git a/tests/ui/limits/huge-enum.rs b/tests/ui/limits/huge-enum.rs index cf6e637388c7f..b57b3a3f32f45 100644 --- a/tests/ui/limits/huge-enum.rs +++ b/tests/ui/limits/huge-enum.rs @@ -2,6 +2,9 @@ //@ normalize-stderr-test: "std::option::Option<\[u32; \d+\]>" -> "TYPE" //@ normalize-stderr-test: "\[u32; \d+\]" -> "TYPE" +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + #[cfg(target_pointer_width = "32")] type BIG = Option<[u32; (1<<29)-1]>; diff --git a/tests/ui/limits/huge-enum.stderr b/tests/ui/limits/huge-enum.stderr index fcd40607af461..c8186654b485c 100644 --- a/tests/ui/limits/huge-enum.stderr +++ b/tests/ui/limits/huge-enum.stderr @@ -1,5 +1,5 @@ error: values of the type `Option` are too big for the current architecture - --> $DIR/huge-enum.rs:12:9 + --> $DIR/huge-enum.rs:15:9 | LL | let big: BIG = None; | ^^^ diff --git a/tests/ui/limits/huge-struct.rs b/tests/ui/limits/huge-struct.rs index b9e90b3e9d1ae..616aa63db6d71 100644 --- a/tests/ui/limits/huge-struct.rs +++ b/tests/ui/limits/huge-struct.rs @@ -3,6 +3,9 @@ //@ normalize-stderr-test: "S1M" -> "SXX" //@ error-pattern: too big for the current +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + struct S32 { v0: T, v1: T, diff --git a/tests/ui/limits/huge-struct.stderr b/tests/ui/limits/huge-struct.stderr index 782db20c7f345..b1e8864b58976 100644 --- a/tests/ui/limits/huge-struct.stderr +++ b/tests/ui/limits/huge-struct.stderr @@ -1,5 +1,5 @@ error: values of the type `SXX>>` are too big for the current architecture - --> $DIR/huge-struct.rs:46:9 + --> $DIR/huge-struct.rs:49:9 | LL | let fat: Option>>> = None; | ^^^ diff --git a/tests/ui/limits/issue-15919-32.rs b/tests/ui/limits/issue-15919-32.rs index d1d1c33918130..ced2ba5361b0e 100644 --- a/tests/ui/limits/issue-15919-32.rs +++ b/tests/ui/limits/issue-15919-32.rs @@ -1,6 +1,9 @@ //@ ignore-64bit //@ build-fail +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + fn main() { let x = [0usize; 0xffff_ffff]; //~ ERROR too big } diff --git a/tests/ui/limits/issue-15919-32.stderr b/tests/ui/limits/issue-15919-32.stderr index abd65ff3c9eb7..26bbc2bb959e1 100644 --- a/tests/ui/limits/issue-15919-32.stderr +++ b/tests/ui/limits/issue-15919-32.stderr @@ -1,5 +1,5 @@ error: values of the type `[usize; usize::MAX]` are too big for the current architecture - --> $DIR/issue-15919-32.rs:5:9 + --> $DIR/issue-15919-32.rs:8:9 | LL | let x = [0usize; 0xffff_ffff]; | ^ diff --git a/tests/ui/limits/issue-15919-64.rs b/tests/ui/limits/issue-15919-64.rs index 7e6200882a966..6a2d6b0618eda 100644 --- a/tests/ui/limits/issue-15919-64.rs +++ b/tests/ui/limits/issue-15919-64.rs @@ -1,6 +1,9 @@ //@ build-fail //@ ignore-32bit +//@ compile-flags: -Z mir-opt-level=0 +// (The optimizations would remove the values on which this errors.) + fn main() { let x = [0usize; 0xffff_ffff_ffff_ffff]; //~ ERROR too big } diff --git a/tests/ui/limits/issue-15919-64.stderr b/tests/ui/limits/issue-15919-64.stderr index d1f0cc39c1884..17dcd071fd93d 100644 --- a/tests/ui/limits/issue-15919-64.stderr +++ b/tests/ui/limits/issue-15919-64.stderr @@ -1,5 +1,5 @@ error: values of the type `[usize; usize::MAX]` are too big for the current architecture - --> $DIR/issue-15919-64.rs:5:9 + --> $DIR/issue-15919-64.rs:8:9 | LL | let x = [0usize; 0xffff_ffff_ffff_ffff]; | ^