From 3f3c38990de81c5ba5e97103723a8daa2cfca384 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sat, 12 Oct 2024 16:22:57 -0400 Subject: [PATCH 1/5] Add post-mono passes to make mono-reachable analysis more accurate --- compiler/rustc_codegen_cranelift/src/base.rs | 2 +- compiler/rustc_codegen_ssa/src/mir/mod.rs | 2 +- compiler/rustc_middle/src/mir/mod.rs | 1 + compiler/rustc_middle/src/mir/mono.rs | 2 +- compiler/rustc_middle/src/mir/syntax.rs | 2 + compiler/rustc_middle/src/query/mod.rs | 10 +- compiler/rustc_mir_transform/src/gvn.rs | 44 ++++- .../rustc_mir_transform/src/instsimplify.rs | 25 +++ compiler/rustc_mir_transform/src/lib.rs | 47 ++++- .../rustc_mir_transform/src/pass_manager.rs | 2 +- compiler/rustc_mir_transform/src/simplify.rs | 2 + .../src/simplify_branches.rs | 2 + compiler/rustc_mir_transform/src/validate.rs | 2 +- compiler/rustc_monomorphize/src/collector.rs | 2 +- .../issue-122600-ptr-discriminant-update.rs | 2 +- tests/codegen/skip-mono-inside-if-false.rs | 41 ----- tests/coverage/branch/generics.cov-map | 44 +++-- tests/coverage/issue-84561.cov-map | 18 +- tests/coverage/try_error_result.cov-map | 169 ++++++++---------- tests/crashes/129372.rs | 52 ------ tests/crashes/131342-2.rs | 40 ----- .../const-eval/issue-50814-2.mir-opt.stderr | 46 +---- .../const-eval/issue-50814-2.normal.stderr | 16 +- tests/ui/consts/const-eval/issue-50814-2.rs | 1 + tests/ui/consts/const-eval/issue-50814.stderr | 8 + .../ui/consts/mono-reachable-invalid-const.rs | 1 + .../mono-reachable-invalid-const.stderr | 14 +- .../ui/inline-const/const-expr-generic-err.rs | 1 + .../const-expr-generic-err.stderr | 20 +-- tests/ui/layout/layout-cycle.rs | 3 +- tests/ui/layout/layout-cycle.stderr | 10 +- tests/ui/layout/post-mono-layout-cycle.rs | 1 - tests/ui/layout/post-mono-layout-cycle.stderr | 10 +- .../large_assignments/copy_into_fn.stderr | 8 +- tests/ui/mir/validate/critical-edge.rs | 8 +- tests/ui/recursion_limit/zero-overflow.rs | 2 +- tests/ui/recursion_limit/zero-overflow.stderr | 2 +- 37 files changed, 289 insertions(+), 373 deletions(-) delete mode 100644 tests/codegen/skip-mono-inside-if-false.rs delete mode 100644 tests/crashes/129372.rs delete mode 100644 tests/crashes/131342-2.rs diff --git a/compiler/rustc_codegen_cranelift/src/base.rs b/compiler/rustc_codegen_cranelift/src/base.rs index a681e6d9f3cd1..394351e3fe1e3 100644 --- a/compiler/rustc_codegen_cranelift/src/base.rs +++ b/compiler/rustc_codegen_cranelift/src/base.rs @@ -41,7 +41,7 @@ pub(crate) fn codegen_fn<'tcx>( let symbol_name = tcx.symbol_name(instance).name.to_string(); let _timer = tcx.prof.generic_activity_with_arg("codegen fn", &*symbol_name); - let mir = tcx.instance_mir(instance.def); + let mir = tcx.build_codegen_mir(instance); let _mir_guard = crate::PrintOnPanic(|| { let mut buf = Vec::new(); with_no_trimmed_paths!({ diff --git a/compiler/rustc_codegen_ssa/src/mir/mod.rs b/compiler/rustc_codegen_ssa/src/mir/mod.rs index 8bd172a9ce6d3..15bb733f26d8d 100644 --- a/compiler/rustc_codegen_ssa/src/mir/mod.rs +++ b/compiler/rustc_codegen_ssa/src/mir/mod.rs @@ -167,7 +167,7 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>( let llfn = cx.get_fn(instance); - let mir = cx.tcx().instance_mir(instance.def); + let mir = cx.tcx().build_codegen_mir(instance); let fn_abi = cx.fn_abi_of_instance(instance, ty::List::empty()); debug!("fn_abi: {:?}", fn_abi); diff --git a/compiler/rustc_middle/src/mir/mod.rs b/compiler/rustc_middle/src/mir/mod.rs index cd148aef29ba8..c251a3ae8ce56 100644 --- a/compiler/rustc_middle/src/mir/mod.rs +++ b/compiler/rustc_middle/src/mir/mod.rs @@ -159,6 +159,7 @@ impl RuntimePhase { "initial" => Self::Initial, "post_cleanup" | "post-cleanup" | "postcleanup" => Self::PostCleanup, "optimized" => Self::Optimized, + "codegen" => Self::Codegen, _ => bug!("Unknown runtime phase: '{}'", phase), } } diff --git a/compiler/rustc_middle/src/mir/mono.rs b/compiler/rustc_middle/src/mir/mono.rs index 56ca9167d4daa..fbff91a373b11 100644 --- a/compiler/rustc_middle/src/mir/mono.rs +++ b/compiler/rustc_middle/src/mir/mono.rs @@ -73,7 +73,7 @@ impl<'tcx> MonoItem<'tcx> { InstanceKind::Item(..) | InstanceKind::DropGlue(..) | InstanceKind::AsyncDropGlueCtorShim(..) => { - let mir = tcx.instance_mir(instance.def); + let mir = tcx.build_codegen_mir(instance); mir.basic_blocks.iter().map(|bb| bb.statements.len() + 1).sum() } // Other compiler-generated shims size estimate: 1 diff --git a/compiler/rustc_middle/src/mir/syntax.rs b/compiler/rustc_middle/src/mir/syntax.rs index c610fac80f68f..e71b6b140a2dc 100644 --- a/compiler/rustc_middle/src/mir/syntax.rs +++ b/compiler/rustc_middle/src/mir/syntax.rs @@ -99,6 +99,7 @@ impl MirPhase { MirPhase::Runtime(RuntimePhase::Initial) => "runtime", MirPhase::Runtime(RuntimePhase::PostCleanup) => "runtime-post-cleanup", MirPhase::Runtime(RuntimePhase::Optimized) => "runtime-optimized", + MirPhase::Runtime(RuntimePhase::Codegen) => "codegen", } } @@ -153,6 +154,7 @@ pub enum RuntimePhase { /// * [`ProjectionElem::Deref`] of `Box` PostCleanup = 1, Optimized = 2, + Codegen = 3, } /////////////////////////////////////////////////////////////////////////// diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index f0be70e00dfca..155d8f3a03589 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -554,14 +554,20 @@ rustc_queries! { desc { |tcx| "verify auto trait bounds for coroutine interior type `{}`", tcx.def_path_str(key) } } - /// MIR after our optimization passes have run. This is MIR that is ready - /// for codegen. This is also the only query that can fetch non-local MIR, at present. + /// Polymorphic MIR after our pre-mono optimization passes have run. This is the MIR that + /// crates export. query optimized_mir(key: DefId) -> &'tcx mir::Body<'tcx> { desc { |tcx| "optimizing MIR for `{}`", tcx.def_path_str(key) } cache_on_disk_if { key.is_local() } separate_provide_extern } + /// MIR for a specific Instance ready for codegen. This is `optimized_mir` but monomorphized + /// and with extra transforms applied. + query build_codegen_mir(key: ty::Instance<'tcx>) -> &'tcx mir::Body<'tcx> { + desc { |tcx| "finalizing codegen MIR for `{}`", tcx.def_path_str_with_args(key.def_id(), key.args) } + } + /// Checks for the nearest `#[coverage(off)]` or `#[coverage(on)]` on /// this def and any enclosing defs, up to the crate root. /// diff --git a/compiler/rustc_mir_transform/src/gvn.rs b/compiler/rustc_mir_transform/src/gvn.rs index daf868559bcae..66fe43e9d1a9d 100644 --- a/compiler/rustc_mir_transform/src/gvn.rs +++ b/compiler/rustc_mir_transform/src/gvn.rs @@ -85,6 +85,7 @@ use std::borrow::Cow; use either::Either; +use rustc_ast::attr; use rustc_const_eval::const_eval::DummyMachine; use rustc_const_eval::interpret::{ ImmTy, Immediate, InterpCx, MemPlaceMeta, MemoryKind, OpTy, Projectable, Scalar, @@ -101,17 +102,27 @@ use rustc_middle::mir::visit::*; use rustc_middle::mir::*; use rustc_middle::ty::layout::{HasParamEnv, LayoutOf}; use rustc_middle::ty::{self, Ty, TyCtxt}; -use rustc_span::DUMMY_SP; use rustc_span::def_id::DefId; +use rustc_span::{DUMMY_SP, sym}; use rustc_target::abi::{self, Abi, FIRST_VARIANT, FieldIdx, Primitive, Size, VariantIdx}; use smallvec::SmallVec; use tracing::{debug, instrument, trace}; use crate::ssa::{AssignedValue, SsaLocals}; -pub(super) struct GVN; +pub(super) enum GVN { + Polymorphic, + PostMono, +} impl<'tcx> crate::MirPass<'tcx> for GVN { + fn name(&self) -> &'static str { + match self { + GVN::Polymorphic => "GVN", + GVN::PostMono => "GVN-post-mono", + } + } + fn is_enabled(&self, sess: &rustc_session::Session) -> bool { sess.mir_opt_level() >= 2 } @@ -125,7 +136,22 @@ impl<'tcx> crate::MirPass<'tcx> for GVN { // Clone dominators because we need them while mutating the body. let dominators = body.basic_blocks.dominators().clone(); - let mut state = VnState::new(tcx, body, param_env, &ssa, dominators, &body.local_decls); + let preserve_ub_checks = match self { + GVN::Polymorphic => { + attr::contains_name(tcx.hir().krate_attrs(), sym::rustc_preserve_ub_checks) + } + GVN::PostMono => false, + }; + + let mut state = VnState::new( + tcx, + body, + param_env, + &ssa, + dominators, + &body.local_decls, + preserve_ub_checks, + ); ssa.for_each_assignment_mut( body.basic_blocks.as_mut_preserves_cfg(), |local, value, location| { @@ -260,6 +286,7 @@ struct VnState<'body, 'tcx> { ssa: &'body SsaLocals, dominators: Dominators, reused_locals: BitSet, + preserve_ub_checks: bool, } impl<'body, 'tcx> VnState<'body, 'tcx> { @@ -270,6 +297,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { ssa: &'body SsaLocals, dominators: Dominators, local_decls: &'body LocalDecls<'tcx>, + preserve_ub_checks: bool, ) -> Self { // Compute a rough estimate of the number of values in the body from the number of // statements. This is meant to reduce the number of allocations, but it's all right if @@ -292,6 +320,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { ssa, dominators, reused_locals: BitSet::new_empty(local_decls.len()), + preserve_ub_checks, } } @@ -530,7 +559,14 @@ impl<'body, 'tcx> VnState<'body, 'tcx> { .tcx .offset_of_subfield(self.ecx.param_env(), layout, fields.iter()) .bytes(), - NullOp::UbChecks => return None, + NullOp::UbChecks => { + if self.preserve_ub_checks { + return None; + } else { + let val = ImmTy::from_bool(self.tcx.sess.ub_checks(), self.tcx); + return Some(val.into()); + } + } }; let usize_layout = self.ecx.layout_of(self.tcx.types.usize).unwrap(); let imm = ImmTy::from_uint(val, usize_layout); diff --git a/compiler/rustc_mir_transform/src/instsimplify.rs b/compiler/rustc_mir_transform/src/instsimplify.rs index 8bcc91b448858..11609e7652c52 100644 --- a/compiler/rustc_mir_transform/src/instsimplify.rs +++ b/compiler/rustc_mir_transform/src/instsimplify.rs @@ -16,6 +16,7 @@ use crate::take_array; pub(super) enum InstSimplify { BeforeInline, AfterSimplifyCfg, + PostMono, } impl<'tcx> crate::MirPass<'tcx> for InstSimplify { @@ -23,6 +24,7 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify { match self { InstSimplify::BeforeInline => "InstSimplify-before-inline", InstSimplify::AfterSimplifyCfg => "InstSimplify-after-simplifycfg", + InstSimplify::PostMono => "InstSimplify-post-mono", } } @@ -51,6 +53,29 @@ impl<'tcx> crate::MirPass<'tcx> for InstSimplify { ctx.simplify_ptr_aggregate(&statement.source_info, rvalue); ctx.simplify_cast(rvalue); } + StatementKind::Intrinsic(box NonDivergingIntrinsic::Assume(ref op)) => { + // UnreachablePropagation likes to generate this MIR: + // + // _1 = UbChecks(); + // assume(copy _1); + // _2 = unreachable_unchecked::precondition_check() -> [return: bb2, unwind unreachable]; + // + // Which is mind-bending but correct. When UbChecks is false, we + // assume(false) which is unreachable, and we never hit the precondition + // check. When UbChecks is true, we assume(true) and fall through to the + // precondition check. + // + // So the branch on UbChecks is implicit, which is both clever and makes + // the rest of MIR optimizations unable to delete this precondition check + // call when UB checks are off. + if let Some(ConstOperand { const_, .. }) = op.constant() { + if let Some(false) = const_.try_to_bool() { + block.statements.clear(); + block.terminator_mut().kind = TerminatorKind::Unreachable; + break; + } + } + } _ => {} } } diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index d184328748f84..acb9c425c8937 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -30,7 +30,7 @@ use rustc_middle::mir::{ MirPhase, Operand, Place, ProjectionElem, Promoted, RuntimePhase, Rvalue, START_BLOCK, SourceInfo, Statement, StatementKind, TerminatorKind, }; -use rustc_middle::ty::{self, TyCtxt, TypeVisitableExt}; +use rustc_middle::ty::{self, Instance, TyCtxt, TypeVisitableExt}; use rustc_middle::util::Providers; use rustc_middle::{bug, query, span_bug}; use rustc_span::source_map::Spanned; @@ -136,6 +136,7 @@ pub fn provide(providers: &mut Providers) { promoted_mir, deduced_param_attrs: deduce_param_attrs::deduced_param_attrs, coroutine_by_move_body_def_id: coroutine::coroutine_by_move_body_def_id, + build_codegen_mir, ..providers.queries }; } @@ -564,11 +565,11 @@ fn run_runtime_cleanup_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { } } -fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - fn o1(x: T) -> WithMinOptLevel { - WithMinOptLevel(1, x) - } +fn o1(x: T) -> WithMinOptLevel { + WithMinOptLevel(1, x) +} +fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { // The main optimizations that we do on MIR. pm::run_passes( tcx, @@ -609,7 +610,7 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &instsimplify::InstSimplify::AfterSimplifyCfg, &simplify::SimplifyLocals::BeforeConstProp, &dead_store_elimination::DeadStoreElimination::Initial, - &gvn::GVN, + &gvn::GVN::Polymorphic, &simplify::SimplifyLocals::AfterGVN, &dataflow_const_prop::DataflowConstProp, &single_use_consts::SingleUseConsts, @@ -628,8 +629,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &multiple_return_terminators::MultipleReturnTerminators, &deduplicate_blocks::DeduplicateBlocks, &large_enums::EnumSizeOpt { discrepancy: 128 }, - // Some cleanup necessary at least for LLVM and potentially other codegen backends. - &add_call_guards::CriticalCallEdges, // Cleanup for human readability, off by default. &prettify::ReorderBasicBlocks, &prettify::ReorderLocals, @@ -689,6 +688,38 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { body } +pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> &'tcx Body<'tcx> { + let body = tcx.instance_mir(instance.def); + let mut body = instance.instantiate_mir_and_normalize_erasing_regions( + tcx, + ty::ParamEnv::reveal_all(), + ty::EarlyBinder::bind(body.clone()), + ); + pm::run_passes( + tcx, + &mut body, + &[ + // Validation calls layout::fn_can_unwind to figure out if a function can unwind, which + // always returns false if the current crate is compiled with -Cpanic=abort. So when + // a crate with panic=abort compiles MIR from a panic=unwind crate, we get validation + // failures. So we rely on the fact that validation only runs after passes? It's + // probably better to just delete that validation check. + &abort_unwinding_calls::AbortUnwindingCalls, + &o1(gvn::GVN::PostMono), + // FIXME: Enabling this InstSimplify is required to fix the MIR from the + // unreachable_unchecked precondition check that UnreachablePropagation creates, but + // also enabling it breaks tests/codegen/issues/issue-122600-ptr-discriminant-update.rs + // LLVM appears to handle switches on i64 better than it handles icmp eq + br. + &o1(instsimplify::InstSimplify::PostMono), + &o1(simplify_branches::SimplifyConstCondition::PostMono), + &o1(simplify::SimplifyCfg::PostMono), + &add_call_guards::CriticalCallEdges, + ], + Some(MirPhase::Runtime(RuntimePhase::Codegen)), + ); + tcx.arena.alloc(body) +} + /// Fetch all the promoteds of an item and prepare their MIR bodies to be ready for /// constant evaluation once all generic parameters become known. fn promoted_mir(tcx: TyCtxt<'_>, def: LocalDefId) -> &IndexVec> { diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index 29f8b4f6e4ddf..ca0f28b8fbfb0 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -265,7 +265,7 @@ fn run_passes_inner<'tcx>( } } -pub(super) fn validate_body<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when: String) { +fn validate_body<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>, when: String) { validate::Validator { when, mir_phase: body.phase }.run_pass(tcx, body); } diff --git a/compiler/rustc_mir_transform/src/simplify.rs b/compiler/rustc_mir_transform/src/simplify.rs index 7ed43547e1127..451eb008536cf 100644 --- a/compiler/rustc_mir_transform/src/simplify.rs +++ b/compiler/rustc_mir_transform/src/simplify.rs @@ -47,6 +47,7 @@ pub(super) enum SimplifyCfg { Final, MakeShim, AfterUnreachableEnumBranching, + PostMono, } impl SimplifyCfg { @@ -62,6 +63,7 @@ impl SimplifyCfg { SimplifyCfg::AfterUnreachableEnumBranching => { "SimplifyCfg-after-unreachable-enum-branching" } + SimplifyCfg::PostMono => "SimplifyCfg-post-mono", } } } diff --git a/compiler/rustc_mir_transform/src/simplify_branches.rs b/compiler/rustc_mir_transform/src/simplify_branches.rs index e83b4727c4856..4e0f87760490b 100644 --- a/compiler/rustc_mir_transform/src/simplify_branches.rs +++ b/compiler/rustc_mir_transform/src/simplify_branches.rs @@ -5,6 +5,7 @@ use tracing::trace; pub(super) enum SimplifyConstCondition { AfterConstProp, Final, + PostMono, } /// A pass that replaces a branch with a goto when its condition is known. @@ -13,6 +14,7 @@ impl<'tcx> crate::MirPass<'tcx> for SimplifyConstCondition { match self { SimplifyConstCondition::AfterConstProp => "SimplifyConstCondition-after-const-prop", SimplifyConstCondition::Final => "SimplifyConstCondition-final", + SimplifyConstCondition::PostMono => "SimplifyConstCondition-post-mono", } } diff --git a/compiler/rustc_mir_transform/src/validate.rs b/compiler/rustc_mir_transform/src/validate.rs index e353be6a105f0..f4e6463f284e0 100644 --- a/compiler/rustc_mir_transform/src/validate.rs +++ b/compiler/rustc_mir_transform/src/validate.rs @@ -395,7 +395,7 @@ impl<'a, 'tcx> Visitor<'tcx> for CfgChecker<'a, 'tcx> { // the return edge from the call. FIXME(tmiasko): Since this is a strictly code // generation concern, the code generation should be responsible for handling // it. - if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Optimized) + if self.mir_phase >= MirPhase::Runtime(RuntimePhase::Codegen) && self.is_critical_call_edge(target, unwind) { self.fail( diff --git a/compiler/rustc_monomorphize/src/collector.rs b/compiler/rustc_monomorphize/src/collector.rs index b4d084d4dffc4..a3240fda12813 100644 --- a/compiler/rustc_monomorphize/src/collector.rs +++ b/compiler/rustc_monomorphize/src/collector.rs @@ -1207,7 +1207,7 @@ fn collect_items_of_instance<'tcx>( mentioned_items: &mut MonoItems<'tcx>, mode: CollectionMode, ) { - let body = tcx.instance_mir(instance.def); + let body = tcx.build_codegen_mir(instance); // Naively, in "used" collection mode, all functions get added to *both* `used_items` and // `mentioned_items`. Mentioned items processing will then notice that they have already been // visited, but at that point each mentioned item has been monomorphized, added to the diff --git a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs index 4b520a6206951..5c4c36d306a05 100644 --- a/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs +++ b/tests/codegen/issues/issue-122600-ptr-discriminant-update.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -O +//@ compile-flags: -O -Zmir-enable-passes=-InstSimplify-post-mono //@ min-llvm-version: 19 #![crate_type = "lib"] diff --git a/tests/codegen/skip-mono-inside-if-false.rs b/tests/codegen/skip-mono-inside-if-false.rs deleted file mode 100644 index 8b95de99dd3bd..0000000000000 --- a/tests/codegen/skip-mono-inside-if-false.rs +++ /dev/null @@ -1,41 +0,0 @@ -//@ compile-flags: -Cno-prepopulate-passes -Copt-level=0 - -#![crate_type = "lib"] - -#[no_mangle] -pub fn demo_for_i32() { - generic_impl::(); -} - -// Two important things here: -// - We replace the "then" block with `unreachable` to avoid linking problems -// - We neither declare nor define the `big_impl` that said block "calls". - -// CHECK-LABEL: ; skip_mono_inside_if_false::generic_impl -// CHECK: start: -// CHECK-NEXT: br label %[[ELSE_BRANCH:bb[0-9]+]] -// CHECK: [[ELSE_BRANCH]]: -// CHECK-NEXT: call skip_mono_inside_if_false::small_impl -// CHECK: bb{{[0-9]+}}: -// CHECK-NEXT: ret void -// CHECK: bb{{[0-9+]}}: -// CHECK-NEXT: unreachable - -fn generic_impl() { - trait MagicTrait { - const IS_BIG: bool; - } - impl MagicTrait for T { - const IS_BIG: bool = std::mem::size_of::() > 10; - } - if T::IS_BIG { - big_impl::(); - } else { - small_impl::(); - } -} - -#[inline(never)] -fn small_impl() {} -#[inline(never)] -fn big_impl() {} diff --git a/tests/coverage/branch/generics.cov-map b/tests/coverage/branch/generics.cov-map index 656890634ff4e..c4f1062085324 100644 --- a/tests/coverage/branch/generics.cov-map +++ b/tests/coverage/branch/generics.cov-map @@ -1,51 +1,49 @@ Function name: generics::print_size::<()> -Raw bytes (33): 0x[01, 01, 01, 01, 05, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] +Raw bytes (33): 0x[01, 01, 01, 01, 00, 05, 01, 06, 01, 01, 24, 20, 00, 02, 01, 08, 00, 24, 00, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 0 operands: lhs = Counter(0), rhs = Zero Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) -- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6) +- Branch { true: Zero, false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) + true = Zero + false = (c0 - Zero) +- Code(Zero) at (prev + 0, 37) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c1) + = (c0 - Zero) - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c1 +Highest counter ID seen: c0 Function name: generics::print_size:: -Raw bytes (33): 0x[01, 01, 01, 01, 05, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] +Raw bytes (33): 0x[01, 01, 01, 01, 00, 05, 01, 06, 01, 01, 24, 20, 00, 02, 01, 08, 00, 24, 00, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +- expression 0 operands: lhs = Counter(0), rhs = Zero Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) -- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) - true = c1 - false = (c0 - c1) -- Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6) +- Branch { true: Zero, false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) + true = Zero + false = (c0 - Zero) +- Code(Zero) at (prev + 0, 37) to (start + 2, 6) - Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c1) + = (c0 - Zero) - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) -Highest counter ID seen: c1 +Highest counter ID seen: c0 Function name: generics::print_size:: -Raw bytes (33): 0x[01, 01, 01, 01, 05, 05, 01, 06, 01, 01, 24, 20, 05, 02, 01, 08, 00, 24, 05, 00, 25, 02, 06, 02, 02, 0c, 02, 06, 01, 03, 01, 00, 02] +Raw bytes (31): 0x[01, 01, 00, 05, 01, 06, 01, 01, 24, 20, 05, 00, 01, 08, 00, 24, 05, 00, 25, 02, 06, 00, 02, 0c, 02, 06, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Counter(1) +Number of expressions: 0 Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 36) -- Branch { true: Counter(1), false: Expression(0, Sub) } at (prev + 1, 8) to (start + 0, 36) +- Branch { true: Counter(1), false: Zero } at (prev + 1, 8) to (start + 0, 36) true = c1 - false = (c0 - c1) + false = Zero - Code(Counter(1)) at (prev + 0, 37) to (start + 2, 6) -- Code(Expression(0, Sub)) at (prev + 2, 12) to (start + 2, 6) - = (c0 - c1) +- Code(Zero) at (prev + 2, 12) to (start + 2, 6) - Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Highest counter ID seen: c1 diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index a8ad17574ba3d..303cb38c03041 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -59,7 +59,7 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: issue_84561::test3 -Raw bytes (375): 0x[01, 01, 31, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 7a, 55, 51, 00, 7a, 55, 51, 00, 77, 5d, 7a, 55, 51, 00, 77, 61, 7a, 55, 51, 00, 72, 65, 77, 61, 7a, 55, 51, 00, 75, be, 01, c2, 01, 79, 69, 6d, 69, 6d, 69, 6d, c2, 01, 00, 69, 6d, c2, 01, 79, 69, 6d, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, b6, 01, 00, bb, 01, 7d, 75, be, 01, c2, 01, 79, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 77, 03, 05, 00, 0f, 77, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 56, 02, 0d, 00, 13, 72, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 6e, 02, 0d, 00, 13, bb, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, c2, 01, 02, 0d, 00, 17, c2, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 92, 01, 02, 15, 00, 1b, be, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, b6, 01, 02, 05, 00, 0f, b2, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] +Raw bytes (375): 0x[01, 01, 31, 05, 09, 0d, 00, 15, 19, 12, 00, 15, 19, 21, 00, 1e, 00, 21, 00, 31, 00, 3d, 00, 2e, 45, 3d, 00, 42, 49, 45, 00, 3f, 51, 42, 49, 45, 00, 7a, 55, 51, 00, 7a, 55, 51, 00, 77, 5d, 7a, 55, 51, 00, 77, 61, 7a, 55, 51, 00, 72, 65, 77, 61, 7a, 55, 51, 00, 75, be, 01, c2, 01, 00, 69, 6d, 69, 6d, 69, 6d, c2, 01, 00, 69, 6d, c2, 01, 00, 69, 6d, bb, 01, 7d, 75, be, 01, c2, 01, 00, 69, 6d, b6, 01, 00, bb, 01, 7d, 75, be, 01, c2, 01, 00, 69, 6d, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 02, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 06, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 12, 02, 05, 00, 1f, 0e, 01, 05, 00, 0f, 00, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 00, 03, 20, 00, 30, 00, 00, 33, 00, 41, 00, 00, 4b, 00, 5a, 1e, 01, 05, 00, 0f, 00, 05, 09, 03, 10, 00, 05, 0d, 00, 1b, 00, 02, 0d, 00, 1c, 1a, 04, 09, 05, 06, 31, 06, 05, 03, 06, 22, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 2e, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 2a, 05, 09, 03, 0a, 3f, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 00, 03, 0d, 00, 1d, 3a, 03, 09, 00, 13, 00, 03, 0d, 00, 1d, 77, 03, 05, 00, 0f, 77, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 56, 02, 0d, 00, 13, 72, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 6e, 02, 0d, 00, 13, bb, 01, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 75, 04, 0d, 00, 13, c2, 01, 02, 0d, 00, 17, c2, 01, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 92, 01, 02, 15, 00, 1b, be, 01, 04, 0d, 00, 13, 7d, 03, 09, 00, 19, b6, 01, 02, 05, 00, 0f, b2, 01, 03, 09, 00, 22, 00, 02, 05, 00, 0f, 00, 03, 09, 00, 2c, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 Number of expressions: 49 @@ -95,22 +95,22 @@ Number of expressions: 49 - expression 29 operands: lhs = Expression(30, Sub), rhs = Counter(21) - expression 30 operands: lhs = Counter(20), rhs = Zero - expression 31 operands: lhs = Counter(29), rhs = Expression(47, Sub) -- expression 32 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 32 operands: lhs = Expression(48, Sub), rhs = Zero - expression 33 operands: lhs = Counter(26), rhs = Counter(27) - expression 34 operands: lhs = Counter(26), rhs = Counter(27) - expression 35 operands: lhs = Counter(26), rhs = Counter(27) - expression 36 operands: lhs = Expression(48, Sub), rhs = Zero - expression 37 operands: lhs = Counter(26), rhs = Counter(27) -- expression 38 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 38 operands: lhs = Expression(48, Sub), rhs = Zero - expression 39 operands: lhs = Counter(26), rhs = Counter(27) - expression 40 operands: lhs = Expression(46, Add), rhs = Counter(31) - expression 41 operands: lhs = Counter(29), rhs = Expression(47, Sub) -- expression 42 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 42 operands: lhs = Expression(48, Sub), rhs = Zero - expression 43 operands: lhs = Counter(26), rhs = Counter(27) - expression 44 operands: lhs = Expression(45, Sub), rhs = Zero - expression 45 operands: lhs = Expression(46, Add), rhs = Counter(31) - expression 46 operands: lhs = Counter(29), rhs = Expression(47, Sub) -- expression 47 operands: lhs = Expression(48, Sub), rhs = Counter(30) +- expression 47 operands: lhs = Expression(48, Sub), rhs = Zero - expression 48 operands: lhs = Counter(26), rhs = Counter(27) Number of file 0 mappings: 51 - Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28) @@ -166,7 +166,7 @@ Number of file 0 mappings: 51 - Code(Expression(27, Sub)) at (prev + 2, 13) to (start + 0, 19) = ((((c20 - Zero) + c21) - c24) - c25) - Code(Expression(46, Add)) at (prev + 3, 5) to (start + 0, 15) - = (c29 + ((c26 - c27) - c30)) + = (c29 + ((c26 - c27) - Zero)) - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14) - Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19) @@ -178,12 +178,12 @@ Number of file 0 mappings: 51 - Code(Expression(36, Sub)) at (prev + 2, 21) to (start + 0, 27) = ((c26 - c27) - Zero) - Code(Expression(47, Sub)) at (prev + 4, 13) to (start + 0, 19) - = ((c26 - c27) - c30) + = ((c26 - c27) - Zero) - Code(Counter(31)) at (prev + 3, 9) to (start + 0, 25) - Code(Expression(45, Sub)) at (prev + 2, 5) to (start + 0, 15) - = ((c29 + ((c26 - c27) - c30)) - c31) + = ((c29 + ((c26 - c27) - Zero)) - c31) - Code(Expression(44, Sub)) at (prev + 3, 9) to (start + 0, 34) - = (((c29 + ((c26 - c27) - c30)) - c31) - Zero) + = (((c29 + ((c26 - c27) - Zero)) - c31) - Zero) - Code(Zero) at (prev + 2, 5) to (start + 0, 15) - Code(Zero) at (prev + 3, 9) to (start + 0, 44) - Code(Zero) at (prev + 2, 1) to (start + 0, 2) diff --git a/tests/coverage/try_error_result.cov-map b/tests/coverage/try_error_result.cov-map index 246a1ba738b28..0e88ee40da8e8 100644 --- a/tests/coverage/try_error_result.cov-map +++ b/tests/coverage/try_error_result.cov-map @@ -86,131 +86,112 @@ Number of file 0 mappings: 11 Highest counter ID seen: c7 Function name: try_error_result::test2 -Raw bytes (358): 0x[01, 01, 3b, 01, 07, 05, 09, 03, 0d, 41, 11, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 4a, 15, 41, 11, 46, 19, 4a, 15, 41, 11, 42, 1d, 46, 19, 4a, 15, 41, 11, 5e, 25, 49, 21, 49, 21, 5e, 25, 49, 21, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, 92, 01, 41, 03, 0d, 8e, 01, 29, 92, 01, 41, 03, 0d, 8a, 01, 2d, 8e, 01, 29, 92, 01, 41, 03, 0d, a6, 01, 35, 45, 31, 45, 31, a6, 01, 35, 45, 31, ba, 01, 3d, 4d, 39, 4d, 39, ba, 01, 3d, 4d, 39, c3, 01, 0d, c7, 01, db, 01, cb, 01, cf, 01, 11, 15, d3, 01, d7, 01, 19, 1d, 21, 25, df, 01, e3, 01, 29, 2d, e7, 01, eb, 01, 31, 35, 39, 3d, 28, 01, 3d, 01, 03, 17, 03, 08, 09, 00, 0e, 92, 01, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 4a, 00, 31, 03, 35, 15, 04, 11, 00, 12, 46, 02, 11, 04, 12, 3e, 05, 11, 00, 14, 46, 00, 17, 00, 41, 19, 00, 41, 00, 42, 42, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 3e, 01, 0d, 00, 20, 5a, 01, 11, 00, 14, 49, 00, 17, 00, 41, 21, 00, 41, 00, 42, 5e, 00, 43, 00, 60, 25, 00, 60, 00, 61, 5a, 01, 0d, 00, 20, 86, 01, 04, 11, 00, 14, 8e, 01, 00, 17, 00, 42, 29, 00, 42, 00, 43, 8a, 01, 00, 44, 00, 61, 2d, 00, 61, 00, 62, 86, 01, 01, 0d, 00, 20, a2, 01, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, a6, 01, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, a2, 01, 01, 0d, 00, 20, b6, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, ba, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, b6, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, bf, 01, 01, 01, 00, 02] +Raw bytes (310): 0x[01, 01, 2d, 01, 07, 00, 09, 03, 0d, 41, 11, 2a, 15, 41, 11, 2a, 15, 41, 11, 26, 19, 2a, 15, 41, 11, 56, 00, 5a, 29, 5e, 41, 03, 0d, 5e, 41, 03, 0d, 5a, 29, 5e, 41, 03, 0d, 56, 00, 5a, 29, 5e, 41, 03, 0d, 72, 35, 45, 31, 45, 31, 72, 35, 45, 31, 86, 01, 3d, 4d, 39, 4d, 39, 86, 01, 3d, 4d, 39, 8f, 01, 0d, 93, 01, a3, 01, 97, 01, 9b, 01, 11, 15, 9f, 01, 00, 19, 1d, a7, 01, ab, 01, 29, 00, af, 01, b3, 01, 31, 35, 39, 3d, 28, 01, 3d, 01, 03, 17, 03, 08, 09, 00, 0e, 5e, 02, 09, 04, 1a, 41, 06, 0d, 00, 2f, 11, 00, 2f, 00, 30, 2a, 00, 31, 03, 35, 15, 04, 11, 00, 12, 26, 02, 11, 04, 12, 00, 05, 11, 00, 14, 26, 00, 17, 00, 41, 19, 00, 41, 00, 42, 22, 00, 43, 00, 5f, 1d, 00, 5f, 00, 60, 00, 01, 0d, 00, 20, 00, 01, 11, 00, 14, 00, 00, 17, 00, 41, 00, 00, 41, 00, 42, 00, 00, 43, 00, 60, 00, 00, 60, 00, 61, 00, 01, 0d, 00, 20, 52, 04, 11, 00, 14, 5a, 00, 17, 00, 42, 29, 00, 42, 00, 43, 56, 00, 44, 00, 61, 00, 00, 61, 00, 62, 52, 01, 0d, 00, 20, 6e, 01, 11, 00, 14, 45, 00, 17, 01, 36, 31, 01, 36, 00, 37, 72, 01, 12, 00, 2f, 35, 00, 2f, 00, 30, 6e, 01, 0d, 00, 20, 82, 01, 01, 11, 00, 14, 4d, 00, 17, 01, 36, 39, 02, 11, 00, 12, 86, 01, 01, 12, 00, 2f, 3d, 01, 11, 00, 12, 82, 01, 02, 0d, 00, 20, 0d, 03, 05, 00, 0b, 8b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 59 +Number of expressions: 45 - expression 0 operands: lhs = Counter(0), rhs = Expression(1, Add) -- expression 1 operands: lhs = Counter(1), rhs = Counter(2) +- expression 1 operands: lhs = Zero, rhs = Counter(2) - expression 2 operands: lhs = Expression(0, Add), rhs = Counter(3) - expression 3 operands: lhs = Counter(16), rhs = Counter(4) -- expression 4 operands: lhs = Expression(18, Sub), rhs = Counter(5) +- expression 4 operands: lhs = Expression(10, Sub), rhs = Counter(5) - expression 5 operands: lhs = Counter(16), rhs = Counter(4) -- expression 6 operands: lhs = Expression(16, Sub), rhs = Counter(7) -- expression 7 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 8 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 9 operands: lhs = Counter(16), rhs = Counter(4) -- expression 10 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 11 operands: lhs = Counter(16), rhs = Counter(4) -- expression 12 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 13 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 14 operands: lhs = Counter(16), rhs = Counter(4) -- expression 15 operands: lhs = Expression(16, Sub), rhs = Counter(7) -- expression 16 operands: lhs = Expression(17, Sub), rhs = Counter(6) -- expression 17 operands: lhs = Expression(18, Sub), rhs = Counter(5) -- expression 18 operands: lhs = Counter(16), rhs = Counter(4) -- expression 19 operands: lhs = Expression(23, Sub), rhs = Counter(9) -- expression 20 operands: lhs = Counter(18), rhs = Counter(8) -- expression 21 operands: lhs = Counter(18), rhs = Counter(8) -- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(9) -- expression 23 operands: lhs = Counter(18), rhs = Counter(8) -- expression 24 operands: lhs = Expression(34, Sub), rhs = Counter(11) -- expression 25 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 26 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 27 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 28 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 29 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 30 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 31 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 32 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 33 operands: lhs = Expression(34, Sub), rhs = Counter(11) -- expression 34 operands: lhs = Expression(35, Sub), rhs = Counter(10) -- expression 35 operands: lhs = Expression(36, Sub), rhs = Counter(16) -- expression 36 operands: lhs = Expression(0, Add), rhs = Counter(3) -- expression 37 operands: lhs = Expression(41, Sub), rhs = Counter(13) -- expression 38 operands: lhs = Counter(17), rhs = Counter(12) -- expression 39 operands: lhs = Counter(17), rhs = Counter(12) -- expression 40 operands: lhs = Expression(41, Sub), rhs = Counter(13) -- expression 41 operands: lhs = Counter(17), rhs = Counter(12) -- expression 42 operands: lhs = Expression(46, Sub), rhs = Counter(15) -- expression 43 operands: lhs = Counter(19), rhs = Counter(14) -- expression 44 operands: lhs = Counter(19), rhs = Counter(14) -- expression 45 operands: lhs = Expression(46, Sub), rhs = Counter(15) -- expression 46 operands: lhs = Counter(19), rhs = Counter(14) -- expression 47 operands: lhs = Expression(48, Add), rhs = Counter(3) -- expression 48 operands: lhs = Expression(49, Add), rhs = Expression(54, Add) -- expression 49 operands: lhs = Expression(50, Add), rhs = Expression(51, Add) -- expression 50 operands: lhs = Counter(4), rhs = Counter(5) -- expression 51 operands: lhs = Expression(52, Add), rhs = Expression(53, Add) -- expression 52 operands: lhs = Counter(6), rhs = Counter(7) -- expression 53 operands: lhs = Counter(8), rhs = Counter(9) -- expression 54 operands: lhs = Expression(55, Add), rhs = Expression(56, Add) -- expression 55 operands: lhs = Counter(10), rhs = Counter(11) -- expression 56 operands: lhs = Expression(57, Add), rhs = Expression(58, Add) -- expression 57 operands: lhs = Counter(12), rhs = Counter(13) -- expression 58 operands: lhs = Counter(14), rhs = Counter(15) +- expression 6 operands: lhs = Expression(10, Sub), rhs = Counter(5) +- expression 7 operands: lhs = Counter(16), rhs = Counter(4) +- expression 8 operands: lhs = Expression(9, Sub), rhs = Counter(6) +- expression 9 operands: lhs = Expression(10, Sub), rhs = Counter(5) +- expression 10 operands: lhs = Counter(16), rhs = Counter(4) +- expression 11 operands: lhs = Expression(21, Sub), rhs = Zero +- expression 12 operands: lhs = Expression(22, Sub), rhs = Counter(10) +- expression 13 operands: lhs = Expression(23, Sub), rhs = Counter(16) +- expression 14 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 15 operands: lhs = Expression(23, Sub), rhs = Counter(16) +- expression 16 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 17 operands: lhs = Expression(22, Sub), rhs = Counter(10) +- expression 18 operands: lhs = Expression(23, Sub), rhs = Counter(16) +- expression 19 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 20 operands: lhs = Expression(21, Sub), rhs = Zero +- expression 21 operands: lhs = Expression(22, Sub), rhs = Counter(10) +- expression 22 operands: lhs = Expression(23, Sub), rhs = Counter(16) +- expression 23 operands: lhs = Expression(0, Add), rhs = Counter(3) +- expression 24 operands: lhs = Expression(28, Sub), rhs = Counter(13) +- expression 25 operands: lhs = Counter(17), rhs = Counter(12) +- expression 26 operands: lhs = Counter(17), rhs = Counter(12) +- expression 27 operands: lhs = Expression(28, Sub), rhs = Counter(13) +- expression 28 operands: lhs = Counter(17), rhs = Counter(12) +- expression 29 operands: lhs = Expression(33, Sub), rhs = Counter(15) +- expression 30 operands: lhs = Counter(19), rhs = Counter(14) +- expression 31 operands: lhs = Counter(19), rhs = Counter(14) +- expression 32 operands: lhs = Expression(33, Sub), rhs = Counter(15) +- expression 33 operands: lhs = Counter(19), rhs = Counter(14) +- expression 34 operands: lhs = Expression(35, Add), rhs = Counter(3) +- expression 35 operands: lhs = Expression(36, Add), rhs = Expression(40, Add) +- expression 36 operands: lhs = Expression(37, Add), rhs = Expression(38, Add) +- expression 37 operands: lhs = Counter(4), rhs = Counter(5) +- expression 38 operands: lhs = Expression(39, Add), rhs = Zero +- expression 39 operands: lhs = Counter(6), rhs = Counter(7) +- expression 40 operands: lhs = Expression(41, Add), rhs = Expression(42, Add) +- expression 41 operands: lhs = Counter(10), rhs = Zero +- expression 42 operands: lhs = Expression(43, Add), rhs = Expression(44, Add) +- expression 43 operands: lhs = Counter(12), rhs = Counter(13) +- expression 44 operands: lhs = Counter(14), rhs = Counter(15) Number of file 0 mappings: 40 - Code(Counter(0)) at (prev + 61, 1) to (start + 3, 23) - Code(Expression(0, Add)) at (prev + 8, 9) to (start + 0, 14) - = (c0 + (c1 + c2)) -- Code(Expression(36, Sub)) at (prev + 2, 9) to (start + 4, 26) - = ((c0 + (c1 + c2)) - c3) + = (c0 + (Zero + c2)) +- Code(Expression(23, Sub)) at (prev + 2, 9) to (start + 4, 26) + = ((c0 + (Zero + c2)) - c3) - Code(Counter(16)) at (prev + 6, 13) to (start + 0, 47) - Code(Counter(4)) at (prev + 0, 47) to (start + 0, 48) -- Code(Expression(18, Sub)) at (prev + 0, 49) to (start + 3, 53) +- Code(Expression(10, Sub)) at (prev + 0, 49) to (start + 3, 53) = (c16 - c4) - Code(Counter(5)) at (prev + 4, 17) to (start + 0, 18) -- Code(Expression(17, Sub)) at (prev + 2, 17) to (start + 4, 18) +- Code(Expression(9, Sub)) at (prev + 2, 17) to (start + 4, 18) = ((c16 - c4) - c5) -- Code(Expression(15, Sub)) at (prev + 5, 17) to (start + 0, 20) - = ((((c16 - c4) - c5) - c6) - c7) -- Code(Expression(17, Sub)) at (prev + 0, 23) to (start + 0, 65) +- Code(Zero) at (prev + 5, 17) to (start + 0, 20) +- Code(Expression(9, Sub)) at (prev + 0, 23) to (start + 0, 65) = ((c16 - c4) - c5) - Code(Counter(6)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(16, Sub)) at (prev + 0, 67) to (start + 0, 95) +- Code(Expression(8, Sub)) at (prev + 0, 67) to (start + 0, 95) = (((c16 - c4) - c5) - c6) - Code(Counter(7)) at (prev + 0, 95) to (start + 0, 96) -- Code(Expression(15, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((((c16 - c4) - c5) - c6) - c7) -- Code(Expression(22, Sub)) at (prev + 1, 17) to (start + 0, 20) - = ((c18 - c8) - c9) -- Code(Counter(18)) at (prev + 0, 23) to (start + 0, 65) -- Code(Counter(8)) at (prev + 0, 65) to (start + 0, 66) -- Code(Expression(23, Sub)) at (prev + 0, 67) to (start + 0, 96) - = (c18 - c8) -- Code(Counter(9)) at (prev + 0, 96) to (start + 0, 97) -- Code(Expression(22, Sub)) at (prev + 1, 13) to (start + 0, 32) - = ((c18 - c8) - c9) -- Code(Expression(33, Sub)) at (prev + 4, 17) to (start + 0, 20) - = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) -- Code(Expression(35, Sub)) at (prev + 0, 23) to (start + 0, 66) - = (((c0 + (c1 + c2)) - c3) - c16) +- Code(Zero) at (prev + 1, 13) to (start + 0, 32) +- Code(Zero) at (prev + 1, 17) to (start + 0, 20) +- Code(Zero) at (prev + 0, 23) to (start + 0, 65) +- Code(Zero) at (prev + 0, 65) to (start + 0, 66) +- Code(Zero) at (prev + 0, 67) to (start + 0, 96) +- Code(Zero) at (prev + 0, 96) to (start + 0, 97) +- Code(Zero) at (prev + 1, 13) to (start + 0, 32) +- Code(Expression(20, Sub)) at (prev + 4, 17) to (start + 0, 20) + = (((((c0 + (Zero + c2)) - c3) - c16) - c10) - Zero) +- Code(Expression(22, Sub)) at (prev + 0, 23) to (start + 0, 66) + = (((c0 + (Zero + c2)) - c3) - c16) - Code(Counter(10)) at (prev + 0, 66) to (start + 0, 67) -- Code(Expression(34, Sub)) at (prev + 0, 68) to (start + 0, 97) - = ((((c0 + (c1 + c2)) - c3) - c16) - c10) -- Code(Counter(11)) at (prev + 0, 97) to (start + 0, 98) -- Code(Expression(33, Sub)) at (prev + 1, 13) to (start + 0, 32) - = (((((c0 + (c1 + c2)) - c3) - c16) - c10) - c11) -- Code(Expression(40, Sub)) at (prev + 1, 17) to (start + 0, 20) +- Code(Expression(21, Sub)) at (prev + 0, 68) to (start + 0, 97) + = ((((c0 + (Zero + c2)) - c3) - c16) - c10) +- Code(Zero) at (prev + 0, 97) to (start + 0, 98) +- Code(Expression(20, Sub)) at (prev + 1, 13) to (start + 0, 32) + = (((((c0 + (Zero + c2)) - c3) - c16) - c10) - Zero) +- Code(Expression(27, Sub)) at (prev + 1, 17) to (start + 0, 20) = ((c17 - c12) - c13) - Code(Counter(17)) at (prev + 0, 23) to (start + 1, 54) - Code(Counter(12)) at (prev + 1, 54) to (start + 0, 55) -- Code(Expression(41, Sub)) at (prev + 1, 18) to (start + 0, 47) +- Code(Expression(28, Sub)) at (prev + 1, 18) to (start + 0, 47) = (c17 - c12) - Code(Counter(13)) at (prev + 0, 47) to (start + 0, 48) -- Code(Expression(40, Sub)) at (prev + 1, 13) to (start + 0, 32) +- Code(Expression(27, Sub)) at (prev + 1, 13) to (start + 0, 32) = ((c17 - c12) - c13) -- Code(Expression(45, Sub)) at (prev + 1, 17) to (start + 0, 20) +- Code(Expression(32, Sub)) at (prev + 1, 17) to (start + 0, 20) = ((c19 - c14) - c15) - Code(Counter(19)) at (prev + 0, 23) to (start + 1, 54) - Code(Counter(14)) at (prev + 2, 17) to (start + 0, 18) -- Code(Expression(46, Sub)) at (prev + 1, 18) to (start + 0, 47) +- Code(Expression(33, Sub)) at (prev + 1, 18) to (start + 0, 47) = (c19 - c14) - Code(Counter(15)) at (prev + 1, 17) to (start + 0, 18) -- Code(Expression(45, Sub)) at (prev + 2, 13) to (start + 0, 32) +- Code(Expression(32, Sub)) at (prev + 2, 13) to (start + 0, 32) = ((c19 - c14) - c15) - Code(Counter(3)) at (prev + 3, 5) to (start + 0, 11) -- Code(Expression(47, Add)) at (prev + 1, 1) to (start + 0, 2) - = ((((c4 + c5) + ((c6 + c7) + (c8 + c9))) + ((c10 + c11) + ((c12 + c13) + (c14 + c15)))) + c3) +- Code(Expression(34, Add)) at (prev + 1, 1) to (start + 0, 2) + = ((((c4 + c5) + ((c6 + c7) + Zero)) + ((c10 + Zero) + ((c12 + c13) + (c14 + c15)))) + c3) Highest counter ID seen: c19 diff --git a/tests/crashes/129372.rs b/tests/crashes/129372.rs deleted file mode 100644 index 43be01b35df29..0000000000000 --- a/tests/crashes/129372.rs +++ /dev/null @@ -1,52 +0,0 @@ -//@ known-bug: #129372 -//@ compile-flags: -Cdebuginfo=2 -Copt-level=0 - -pub struct Wrapper(T); -struct Struct; - -pub trait TraitA { - type AssocA<'t>; -} -pub trait TraitB { - type AssocB; -} - -pub fn helper(v: impl MethodTrait) { - let _local_that_causes_ice = v.method(); -} - -pub fn main() { - helper(Wrapper(Struct)); -} - -pub trait MethodTrait { - type Assoc<'a>; - - fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a>; -} - -impl MethodTrait for T -where - ::AssocB: TraitA, -{ - type Assoc<'a> = ::AssocA<'a>; - - fn method(self) -> impl for<'a> FnMut(&'a ()) -> Self::Assoc<'a> { - move |_| loop {} - } -} - -impl TraitB for Wrapper -where - B: TraitB, -{ - type AssocB = T; -} - -impl TraitB for Struct { - type AssocB = Struct; -} - -impl TraitA for Struct { - type AssocA<'t> = Self; -} diff --git a/tests/crashes/131342-2.rs b/tests/crashes/131342-2.rs deleted file mode 100644 index 79b6a837a49fb..0000000000000 --- a/tests/crashes/131342-2.rs +++ /dev/null @@ -1,40 +0,0 @@ -//@ known-bug: #131342 -// see also: 131342.rs - -fn main() { - problem_thingy(Once); -} - -struct Once; - -impl Iterator for Once { - type Item = (); -} - -fn problem_thingy(items: impl Iterator) { - let peeker = items.peekable(); - problem_thingy(&peeker); -} - -trait Iterator { - type Item; - - fn peekable(self) -> Peekable - where - Self: Sized, - { - loop {} - } -} - -struct Peekable { - _peeked: I::Item, -} - -impl Iterator for Peekable { - type Item = I::Item; -} - -impl Iterator for &I { - type Item = I::Item; -} diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index 2de68d3fee9e0..8bf73468643b3 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -1,61 +1,21 @@ error[E0080]: evaluation of ` as Foo<()>>::BAR` failed - --> $DIR/issue-50814-2.rs:16:24 + --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr index 4a7dfb1930443..6272a7cb10fdf 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.normal.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.normal.stderr @@ -1,31 +1,23 @@ error[E0080]: evaluation of ` as Foo<()>>::BAR` failed - --> $DIR/issue-50814-2.rs:16:24 + --> $DIR/issue-50814-2.rs:17:24 | LL | const BAR: usize = [5, 6, 7][T::BOO]; | ^^^^^^^^^^^^^^^^^ index out of bounds: the length is 3 but the index is 42 note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 + --> $DIR/issue-50814-2.rs:21:6 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 + --> $DIR/issue-50814-2.rs:21:5 | LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:6 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - note: the above error was encountered while instantiating `fn foo::<()>` - --> $DIR/issue-50814-2.rs:32:22 + --> $DIR/issue-50814-2.rs:33:22 | LL | println!("{:x}", foo::<()>() as *const usize as usize); | ^^^^^^^^^^^ diff --git a/tests/ui/consts/const-eval/issue-50814-2.rs b/tests/ui/consts/const-eval/issue-50814-2.rs index c2e2de67a6517..cc5464df10cbd 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.rs +++ b/tests/ui/consts/const-eval/issue-50814-2.rs @@ -1,6 +1,7 @@ //@ build-fail //@ revisions: normal mir-opt //@ [mir-opt]compile-flags: -Zmir-opt-level=4 +//@ compile-flags: -Zdeduplicate-diagnostics=yes trait C { const BOO: usize; diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index fe0e25b820f58..a30f0c072b13f 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -10,6 +10,14 @@ note: erroneous constant encountered LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^^ +note: erroneous constant encountered + --> $DIR/issue-50814.rs:21:6 + | +LL | &Sum::::MAX + | ^^^^^^^^^^^^^^^^^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0080]: evaluation of ` as Unsigned>::MAX` failed --> $DIR/issue-50814.rs:15:21 | diff --git a/tests/ui/consts/mono-reachable-invalid-const.rs b/tests/ui/consts/mono-reachable-invalid-const.rs index aabdb071bc9fb..4e0bd6b4ddbee 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.rs +++ b/tests/ui/consts/mono-reachable-invalid-const.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ compile-flags: -Zdeduplicate-diagnostics=yes struct Bar; diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index 6b7b25b59b821..72abf5a482832 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -1,25 +1,23 @@ error[E0080]: evaluation of `Bar::<0>::ASSERT` failed - --> $DIR/mono-reachable-invalid-const.rs:8:9 + --> $DIR/mono-reachable-invalid-const.rs:9:9 | LL | ["oops"][b]; | ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 note: erroneous constant encountered - --> $DIR/mono-reachable-invalid-const.rs:13:19 + --> $DIR/mono-reachable-invalid-const.rs:9:9 | -LL | let val = Self::ASSERT; - | ^^^^^^^^^^^^ +LL | ["oops"][b]; + | ^^^^^^^^^^^ note: erroneous constant encountered - --> $DIR/mono-reachable-invalid-const.rs:13:19 + --> $DIR/mono-reachable-invalid-const.rs:14:19 | LL | let val = Self::ASSERT; | ^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn Bar::<0>::assert` - --> $DIR/mono-reachable-invalid-const.rs:22:5 + --> $DIR/mono-reachable-invalid-const.rs:23:5 | LL | Bar::<0>::assert(); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/inline-const/const-expr-generic-err.rs b/tests/ui/inline-const/const-expr-generic-err.rs index 3249e826a96be..c38e8a13291cb 100644 --- a/tests/ui/inline-const/const-expr-generic-err.rs +++ b/tests/ui/inline-const/const-expr-generic-err.rs @@ -1,4 +1,5 @@ //@ build-fail +//@ compile-flags: -Zdeduplicate-diagnostics=yes fn foo() { const { assert!(std::mem::size_of::() == 0); } //~ ERROR E0080 diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index dcd6b62bbfc1d..385f92ac57d71 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -1,45 +1,43 @@ error[E0080]: evaluation of `foo::::{constant#0}` failed - --> $DIR/const-expr-generic-err.rs:4:13 + --> $DIR/const-expr-generic-err.rs:5:13 | LL | const { assert!(std::mem::size_of::() == 0); } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::() == 0', $DIR/const-expr-generic-err.rs:4:13 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'assertion failed: std::mem::size_of::() == 0', $DIR/const-expr-generic-err.rs:5:13 | = note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant encountered - --> $DIR/const-expr-generic-err.rs:4:5 + --> $DIR/const-expr-generic-err.rs:5:5 | LL | const { assert!(std::mem::size_of::() == 0); } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: the above error was encountered while instantiating `fn foo::` - --> $DIR/const-expr-generic-err.rs:12:5 + --> $DIR/const-expr-generic-err.rs:13:5 | LL | foo::(); | ^^^^^^^^^^^^ error[E0080]: evaluation of `bar::<0>::{constant#0}` failed - --> $DIR/const-expr-generic-err.rs:8:13 + --> $DIR/const-expr-generic-err.rs:9:13 | LL | const { N - 1 } | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow note: erroneous constant encountered - --> $DIR/const-expr-generic-err.rs:8:5 + --> $DIR/const-expr-generic-err.rs:9:13 | LL | const { N - 1 } - | ^^^^^^^^^^^^^^^ + | ^^^^^ note: erroneous constant encountered - --> $DIR/const-expr-generic-err.rs:8:5 + --> $DIR/const-expr-generic-err.rs:9:5 | LL | const { N - 1 } | ^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` note: the above error was encountered while instantiating `fn bar::<0>` - --> $DIR/const-expr-generic-err.rs:13:5 + --> $DIR/const-expr-generic-err.rs:14:5 | LL | bar::<0>(); | ^^^^^^^^^^ diff --git a/tests/ui/layout/layout-cycle.rs b/tests/ui/layout/layout-cycle.rs index 3c930def43b2b..846ce0882cad1 100644 --- a/tests/ui/layout/layout-cycle.rs +++ b/tests/ui/layout/layout-cycle.rs @@ -1,6 +1,5 @@ //@ build-fail -//~^ ERROR: a cycle occurred during layout computation -//~| ERROR: cycle detected when computing layout of +//~^ ERROR: cycle detected when computing layout of // Issue #111176 -- ensure that we do not emit ICE on layout cycles diff --git a/tests/ui/layout/layout-cycle.stderr b/tests/ui/layout/layout-cycle.stderr index a3cdb7edcc232..148adf3361a64 100644 --- a/tests/ui/layout/layout-cycle.stderr +++ b/tests/ui/layout/layout-cycle.stderr @@ -2,10 +2,16 @@ error[E0391]: cycle detected when computing layout of `S>` | = note: ...which requires computing layout of ` as Tr>::I`... = note: ...which again requires computing layout of `S>`, completing the cycle +note: cycle used when finalizing codegen MIR for `core::mem::size_of::>>` + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: failed to get layout for S>: a cycle occurred during layout computation +note: the above error was encountered while instantiating `fn std::mem::size_of::>>` + --> $DIR/layout-cycle.rs:25:5 + | +LL | mem::size_of::>() + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/layout/post-mono-layout-cycle.rs b/tests/ui/layout/post-mono-layout-cycle.rs index 8d136190c0052..6753c01267ecd 100644 --- a/tests/ui/layout/post-mono-layout-cycle.rs +++ b/tests/ui/layout/post-mono-layout-cycle.rs @@ -14,7 +14,6 @@ struct Wrapper { } fn abi(_: Option>) {} -//~^ ERROR a cycle occurred during layout computation fn indirect() { abi::(None); diff --git a/tests/ui/layout/post-mono-layout-cycle.stderr b/tests/ui/layout/post-mono-layout-cycle.stderr index 47f7f30b1cb4c..e2f6ac595d006 100644 --- a/tests/ui/layout/post-mono-layout-cycle.stderr +++ b/tests/ui/layout/post-mono-layout-cycle.stderr @@ -5,12 +5,12 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>` = note: cycle used when computing layout of `core::option::Option>` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -error: a cycle occurred during layout computation - --> $DIR/post-mono-layout-cycle.rs:16:1 +note: the above error was encountered while instantiating `fn indirect::<()>` + --> $DIR/post-mono-layout-cycle.rs:23:5 | -LL | fn abi(_: Option>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | indirect::<()>(); + | ^^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/lint/large_assignments/copy_into_fn.stderr b/tests/ui/lint/large_assignments/copy_into_fn.stderr index f05fc33e17e14..2cc5eb97a4bdf 100644 --- a/tests/ui/lint/large_assignments/copy_into_fn.stderr +++ b/tests/ui/lint/large_assignments/copy_into_fn.stderr @@ -12,18 +12,18 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 9999 bytes - --> $DIR/copy_into_fn.rs:17:15 + --> $DIR/copy_into_fn.rs:17:20 | LL | many_args(Data([0; 9999]), true, Data([0; 9999])); - | ^^^^^^^^^^^^^^^ value moved from here + | ^^^^^^^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 9999 bytes - --> $DIR/copy_into_fn.rs:17:38 + --> $DIR/copy_into_fn.rs:17:43 | LL | many_args(Data([0; 9999]), true, Data([0; 9999])); - | ^^^^^^^^^^^^^^^ value moved from here + | ^^^^^^^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` diff --git a/tests/ui/mir/validate/critical-edge.rs b/tests/ui/mir/validate/critical-edge.rs index 9048d08a22a73..9ed8cc1015869 100644 --- a/tests/ui/mir/validate/critical-edge.rs +++ b/tests/ui/mir/validate/critical-edge.rs @@ -7,10 +7,10 @@ //@ dont-check-compiler-stderr //@ error-pattern: encountered critical edge in `Call` terminator #![feature(custom_mir, core_intrinsics)] -use core::intrinsics::mir::*; +use std::intrinsics::mir::*; -#[custom_mir(dialect = "runtime", phase = "optimized")] -#[inline(always)] +#[custom_mir(dialect = "runtime", phase = "codegen")] +#[inline] pub fn f(a: u32) -> u32 { mir! { { @@ -29,3 +29,5 @@ pub fn f(a: u32) -> u32 { } } } + +pub static F: fn(u32) -> u32 = f; diff --git a/tests/ui/recursion_limit/zero-overflow.rs b/tests/ui/recursion_limit/zero-overflow.rs index 3887972a51623..a6b94c72e3510 100644 --- a/tests/ui/recursion_limit/zero-overflow.rs +++ b/tests/ui/recursion_limit/zero-overflow.rs @@ -1,4 +1,4 @@ -//~ ERROR overflow evaluating the requirement `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome> +//~ ERROR overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze` //~| HELP consider increasing the recursion limit //@ build-fail diff --git a/tests/ui/recursion_limit/zero-overflow.stderr b/tests/ui/recursion_limit/zero-overflow.stderr index fc03cc5b604b7..c7dfb01664f0b 100644 --- a/tests/ui/recursion_limit/zero-overflow.stderr +++ b/tests/ui/recursion_limit/zero-overflow.stderr @@ -1,4 +1,4 @@ -error[E0275]: overflow evaluating the requirement `&mut Self: DispatchFromDyn<&mut RustaceansAreAwesome>` +error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`zero_overflow`) From 1b2f8b2fa9ffa06a85b1690154795b1bceb83130 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 13 Oct 2024 12:47:47 -0400 Subject: [PATCH 2/5] fix more tests --- compiler/rustc_mir_transform/src/pass_manager.rs | 5 ++++- ...oxed_slice.main.DataflowConstProp.32bit.panic-abort.diff | 4 ++-- ...xed_slice.main.DataflowConstProp.32bit.panic-unwind.diff | 4 ++-- ...oxed_slice.main.DataflowConstProp.64bit.panic-abort.diff | 4 ++-- ...xed_slice.main.DataflowConstProp.64bit.panic-unwind.diff | 4 ++-- .../default_boxed_slice.main.GVN.32bit.panic-abort.diff | 6 ++++-- .../default_boxed_slice.main.GVN.32bit.panic-unwind.diff | 6 ++++-- .../default_boxed_slice.main.GVN.64bit.panic-abort.diff | 6 ++++-- .../default_boxed_slice.main.GVN.64bit.panic-unwind.diff | 6 ++++-- tests/ui/mir/validate/critical-edge.rs | 4 +--- tests/ui/polymorphization/issue-74614.stderr | 4 ++++ tests/ui/polymorphization/issue-74636.stderr | 4 ++++ 12 files changed, 37 insertions(+), 20 deletions(-) create mode 100644 tests/ui/polymorphization/issue-74614.stderr create mode 100644 tests/ui/polymorphization/issue-74636.stderr diff --git a/compiler/rustc_mir_transform/src/pass_manager.rs b/compiler/rustc_mir_transform/src/pass_manager.rs index ca0f28b8fbfb0..309bf27fdd28f 100644 --- a/compiler/rustc_mir_transform/src/pass_manager.rs +++ b/compiler/rustc_mir_transform/src/pass_manager.rs @@ -252,7 +252,10 @@ fn run_passes_inner<'tcx>( let validate = (validate_each & tcx.sess.opts.unstable_opts.validate_mir & !body.should_skip()) - || new_phase == MirPhase::Runtime(RuntimePhase::Optimized); + || matches!( + new_phase, + MirPhase::Runtime(RuntimePhase::Optimized | RuntimePhase::Codegen) + ); let lint = tcx.sess.opts.unstable_opts.lint_mir & !body.should_skip(); if validate { validate_body(tcx, body, format!("after phase change to {}", new_phase.name())); diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index 4097e060f4d47..57c99813b50c5 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -54,8 +54,8 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; + _8 = const false; + switchInt(const false) -> [0: bb4, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index ff44d0df5e3e9..c2cd8b9b3f734 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -54,8 +54,8 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; + _8 = const false; + switchInt(const false) -> [0: bb5, otherwise: bb3]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index 3662c3b59d271..b9d264df38088 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -54,8 +54,8 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; + _8 = const false; + switchInt(const false) -> [0: bb4, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 68dee57dee9e0..822306c6162b8 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -54,8 +54,8 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; + _8 = const false; + switchInt(const false) -> [0: bb5, otherwise: bb3]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index e62fcb66e3a6d..0ef1a2a31fdb3 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -56,8 +56,10 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; +- _8 = UbChecks(); +- switchInt(move _8) -> [0: bb4, otherwise: bb2]; ++ _8 = const false; ++ switchInt(const false) -> [0: bb4, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 8183abd315ae5..8b362ecb93f08 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -56,8 +56,10 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; +- _8 = UbChecks(); +- switchInt(move _8) -> [0: bb5, otherwise: bb3]; ++ _8 = const false; ++ switchInt(const false) -> [0: bb5, otherwise: bb3]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 4fa6ef29e0697..7af7f5b145327 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -56,8 +56,10 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb4, otherwise: bb2]; +- _8 = UbChecks(); +- switchInt(move _8) -> [0: bb4, otherwise: bb2]; ++ _8 = const false; ++ switchInt(const false) -> [0: bb4, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 753292045632f..e9bcc6a01fb22 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -56,8 +56,10 @@ StorageDead(_7); StorageLive(_11); StorageLive(_8); - _8 = UbChecks(); - switchInt(move _8) -> [0: bb5, otherwise: bb3]; +- _8 = UbChecks(); +- switchInt(move _8) -> [0: bb5, otherwise: bb3]; ++ _8 = const false; ++ switchInt(const false) -> [0: bb5, otherwise: bb3]; } bb1: { diff --git a/tests/ui/mir/validate/critical-edge.rs b/tests/ui/mir/validate/critical-edge.rs index 9ed8cc1015869..36b9779bc9d18 100644 --- a/tests/ui/mir/validate/critical-edge.rs +++ b/tests/ui/mir/validate/critical-edge.rs @@ -10,7 +10,7 @@ use std::intrinsics::mir::*; #[custom_mir(dialect = "runtime", phase = "codegen")] -#[inline] +#[inline(never)] // Force codegen so we go through codegen MIR validation pub fn f(a: u32) -> u32 { mir! { { @@ -29,5 +29,3 @@ pub fn f(a: u32) -> u32 { } } } - -pub static F: fn(u32) -> u32 = f; diff --git a/tests/ui/polymorphization/issue-74614.stderr b/tests/ui/polymorphization/issue-74614.stderr new file mode 100644 index 0000000000000..592ebc076a946 --- /dev/null +++ b/tests/ui/polymorphization/issue-74614.stderr @@ -0,0 +1,4 @@ + WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: + expected Closure(DefId(0:9 ~ issue_74614[b919]::outer::{closure#0}), [Closure(DefId(0:9 ~ issue_74614[b919]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), + found Closure(DefId(0:9 ~ issue_74614[b919]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]). + See . diff --git a/tests/ui/polymorphization/issue-74636.stderr b/tests/ui/polymorphization/issue-74636.stderr new file mode 100644 index 0000000000000..b58d189bfdfc3 --- /dev/null +++ b/tests/ui/polymorphization/issue-74636.stderr @@ -0,0 +1,4 @@ + WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: + expected Closure(DefId(0:8 ~ issue_74636[7d87]::outer::{closure#0}), [Closure(DefId(0:8 ~ issue_74636[7d87]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), + found Closure(DefId(0:8 ~ issue_74636[7d87]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]). + See . From b40930e9db05abaa4088894cf1dee94b64adb058 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 13 Oct 2024 13:26:57 -0400 Subject: [PATCH 3/5] Fix codegen tests --- .../sanitizer/kcfi/emit-type-metadata-trait-objects.rs | 4 ++-- tests/codegen/try_question_mark_nop.rs | 5 ++++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index c1967e55e75b4..81104a39024cf 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -156,7 +156,7 @@ pub fn foo5(a: &dyn Trait5) { let b = &[Type5; 32]; a.quux(&b); // CHECK-LABEL: define{{.*}}4foo5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] } pub fn bar5() { @@ -165,7 +165,7 @@ pub fn bar5() { let b = &a as &dyn Trait5; b.quux(&a); // CHECK-LABEL: define{{.*}}4bar5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] } // CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]} diff --git a/tests/codegen/try_question_mark_nop.rs b/tests/codegen/try_question_mark_nop.rs index 65167f5c5af97..fc20907fff7fd 100644 --- a/tests/codegen/try_question_mark_nop.rs +++ b/tests/codegen/try_question_mark_nop.rs @@ -32,7 +32,10 @@ pub fn option_nop_match_32(x: Option) -> Option { #[no_mangle] pub fn option_nop_traits_32(x: Option) -> Option { // CHECK: start: - // CHECK-NEXT: insertvalue { i32, i32 } + // NINETEEN-NEXT: [[TRUNC:%.*]] = trunc nuw i32 %0 to i1 + // NINETEEN-NEXT: [[FIRST:%.*]] = select i1 [[TRUNC]], i32 %0 + // NINETEEN-NEXT: insertvalue { i32, i32 } poison, i32 [[FIRST]], 0 + // TWENTY-NEXT: insertvalue { i32, i32 } poison, i32 %0, 0 // CHECK-NEXT: insertvalue { i32, i32 } // CHECK-NEXT: ret { i32, i32 } try { x? } From a2118124dea299f6f2bb682cbf04b55f26e6653b Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 13 Oct 2024 14:49:24 -0400 Subject: [PATCH 4/5] Ignore warnings from polymorphization tests --- tests/ui/polymorphization/issue-74614.rs | 1 + tests/ui/polymorphization/issue-74614.stderr | 4 ---- tests/ui/polymorphization/issue-74636.rs | 1 + tests/ui/polymorphization/issue-74636.stderr | 4 ---- 4 files changed, 2 insertions(+), 8 deletions(-) delete mode 100644 tests/ui/polymorphization/issue-74614.stderr delete mode 100644 tests/ui/polymorphization/issue-74636.stderr diff --git a/tests/ui/polymorphization/issue-74614.rs b/tests/ui/polymorphization/issue-74614.rs index 3ed030b5778ce..e2ce5fa2736a2 100644 --- a/tests/ui/polymorphization/issue-74614.rs +++ b/tests/ui/polymorphization/issue-74614.rs @@ -1,5 +1,6 @@ //@ compile-flags:-Zpolymorphize=on //@ build-pass +//@ dont-check-compiler-stderr fn test() { std::mem::size_of::(); diff --git a/tests/ui/polymorphization/issue-74614.stderr b/tests/ui/polymorphization/issue-74614.stderr deleted file mode 100644 index 592ebc076a946..0000000000000 --- a/tests/ui/polymorphization/issue-74614.stderr +++ /dev/null @@ -1,4 +0,0 @@ - WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: - expected Closure(DefId(0:9 ~ issue_74614[b919]::outer::{closure#0}), [Closure(DefId(0:9 ~ issue_74614[b919]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), - found Closure(DefId(0:9 ~ issue_74614[b919]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]). - See . diff --git a/tests/ui/polymorphization/issue-74636.rs b/tests/ui/polymorphization/issue-74636.rs index b06b5fdb004ee..0288cffe5672f 100644 --- a/tests/ui/polymorphization/issue-74636.rs +++ b/tests/ui/polymorphization/issue-74636.rs @@ -1,5 +1,6 @@ //@ compile-flags:-Zpolymorphize=on //@ build-pass +//@ dont-check-compiler-stderr use std::any::TypeId; diff --git a/tests/ui/polymorphization/issue-74636.stderr b/tests/ui/polymorphization/issue-74636.stderr deleted file mode 100644 index b58d189bfdfc3..0000000000000 --- a/tests/ui/polymorphization/issue-74636.stderr +++ /dev/null @@ -1,4 +0,0 @@ - WARN rustc_codegen_ssa::mir::locals Unexpected initial operand type: - expected Closure(DefId(0:8 ~ issue_74636[7d87]::outer::{closure#0}), [Closure(DefId(0:8 ~ issue_74636[7d87]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]), - found Closure(DefId(0:8 ~ issue_74636[7d87]::outer::{closure#0}), [T/#0, i8, Binder { value: extern "RustCall" fn(()), bound_vars: [] }, ()]). - See . From 6f6737a71c4b9d1c95403c4f720a1be31f72f6c6 Mon Sep 17 00:00:00 2001 From: Ben Kimock Date: Sun, 13 Oct 2024 23:21:38 -0400 Subject: [PATCH 5/5] Try to improve compile times --- compiler/rustc_middle/src/query/mod.rs | 2 ++ compiler/rustc_mir_transform/src/lib.rs | 8 ++++---- .../sanitizer/kcfi/emit-type-metadata-trait-objects.rs | 4 ++-- tests/ui/consts/const-eval/issue-50814.stderr | 8 -------- tests/ui/consts/mono-reachable-invalid-const.stderr | 6 ------ tests/ui/inline-const/const-expr-generic-err.stderr | 6 ------ tests/ui/layout/layout-cycle.rs | 3 ++- tests/ui/layout/layout-cycle.stderr | 10 ++-------- tests/ui/layout/post-mono-layout-cycle.rs | 1 + tests/ui/layout/post-mono-layout-cycle.stderr | 10 +++++----- tests/ui/lint/large_assignments/copy_into_fn.stderr | 8 ++++---- tests/ui/recursion_limit/zero-overflow.rs | 2 +- tests/ui/recursion_limit/zero-overflow.stderr | 2 +- 13 files changed, 24 insertions(+), 46 deletions(-) diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs index 155d8f3a03589..9331082b76633 100644 --- a/compiler/rustc_middle/src/query/mod.rs +++ b/compiler/rustc_middle/src/query/mod.rs @@ -566,6 +566,8 @@ rustc_queries! { /// and with extra transforms applied. query build_codegen_mir(key: ty::Instance<'tcx>) -> &'tcx mir::Body<'tcx> { desc { |tcx| "finalizing codegen MIR for `{}`", tcx.def_path_str_with_args(key.def_id(), key.args) } + cache_on_disk_if { true } + arena_cache } /// Checks for the nearest `#[coverage(off)]` or `#[coverage(on)]` on diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index acb9c425c8937..86fda2e6cacb2 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -688,7 +688,7 @@ fn inner_optimized_mir(tcx: TyCtxt<'_>, did: LocalDefId) -> Body<'_> { body } -pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> &'tcx Body<'tcx> { +pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> Body<'tcx> { let body = tcx.instance_mir(instance.def); let mut body = instance.instantiate_mir_and_normalize_erasing_regions( tcx, @@ -705,19 +705,19 @@ pub fn build_codegen_mir<'tcx>(tcx: TyCtxt<'tcx>, instance: Instance<'tcx>) -> & // failures. So we rely on the fact that validation only runs after passes? It's // probably better to just delete that validation check. &abort_unwinding_calls::AbortUnwindingCalls, - &o1(gvn::GVN::PostMono), + &gvn::GVN::PostMono, // FIXME: Enabling this InstSimplify is required to fix the MIR from the // unreachable_unchecked precondition check that UnreachablePropagation creates, but // also enabling it breaks tests/codegen/issues/issue-122600-ptr-discriminant-update.rs // LLVM appears to handle switches on i64 better than it handles icmp eq + br. - &o1(instsimplify::InstSimplify::PostMono), + &instsimplify::InstSimplify::PostMono, &o1(simplify_branches::SimplifyConstCondition::PostMono), &o1(simplify::SimplifyCfg::PostMono), &add_call_guards::CriticalCallEdges, ], Some(MirPhase::Runtime(RuntimePhase::Codegen)), ); - tcx.arena.alloc(body) + body } /// Fetch all the promoteds of an item and prepare their MIR bodies to be ready for diff --git a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs index 81104a39024cf..c1967e55e75b4 100644 --- a/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen/sanitizer/kcfi/emit-type-metadata-trait-objects.rs @@ -156,7 +156,7 @@ pub fn foo5(a: &dyn Trait5) { let b = &[Type5; 32]; a.quux(&b); // CHECK-LABEL: define{{.*}}4foo5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] } pub fn bar5() { @@ -165,7 +165,7 @@ pub fn bar5() { let b = &a as &dyn Trait5; b.quux(&a); // CHECK-LABEL: define{{.*}}4bar5{{.*}}!{{|kcfi_type}} !{{[0-9]+}} - // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] + // CHECK: call void %{{[0-9]}}(ptr align 1 {{%[a-z](\.0)*|%_[0-9]+]}}, ptr align 1 {{%[a-z](\.0)*|%_[0-9]+}}){{.*}}[ "kcfi"(i32 [[TYPE5:[[:print:]]+]]) ] } // CHECK: !{{[0-9]+}} = !{i32 [[TYPE1]]} diff --git a/tests/ui/consts/const-eval/issue-50814.stderr b/tests/ui/consts/const-eval/issue-50814.stderr index a30f0c072b13f..fe0e25b820f58 100644 --- a/tests/ui/consts/const-eval/issue-50814.stderr +++ b/tests/ui/consts/const-eval/issue-50814.stderr @@ -10,14 +10,6 @@ note: erroneous constant encountered LL | &Sum::::MAX | ^^^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/issue-50814.rs:21:6 - | -LL | &Sum::::MAX - | ^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - error[E0080]: evaluation of ` as Unsigned>::MAX` failed --> $DIR/issue-50814.rs:15:21 | diff --git a/tests/ui/consts/mono-reachable-invalid-const.stderr b/tests/ui/consts/mono-reachable-invalid-const.stderr index 72abf5a482832..7d3223b5c32e1 100644 --- a/tests/ui/consts/mono-reachable-invalid-const.stderr +++ b/tests/ui/consts/mono-reachable-invalid-const.stderr @@ -4,12 +4,6 @@ error[E0080]: evaluation of `Bar::<0>::ASSERT` failed LL | ["oops"][b]; | ^^^^^^^^^^^ index out of bounds: the length is 1 but the index is 1 -note: erroneous constant encountered - --> $DIR/mono-reachable-invalid-const.rs:9:9 - | -LL | ["oops"][b]; - | ^^^^^^^^^^^ - note: erroneous constant encountered --> $DIR/mono-reachable-invalid-const.rs:14:19 | diff --git a/tests/ui/inline-const/const-expr-generic-err.stderr b/tests/ui/inline-const/const-expr-generic-err.stderr index 385f92ac57d71..bdbffe630bef4 100644 --- a/tests/ui/inline-const/const-expr-generic-err.stderr +++ b/tests/ui/inline-const/const-expr-generic-err.stderr @@ -24,12 +24,6 @@ error[E0080]: evaluation of `bar::<0>::{constant#0}` failed LL | const { N - 1 } | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow -note: erroneous constant encountered - --> $DIR/const-expr-generic-err.rs:9:13 - | -LL | const { N - 1 } - | ^^^^^ - note: erroneous constant encountered --> $DIR/const-expr-generic-err.rs:9:5 | diff --git a/tests/ui/layout/layout-cycle.rs b/tests/ui/layout/layout-cycle.rs index 846ce0882cad1..3c930def43b2b 100644 --- a/tests/ui/layout/layout-cycle.rs +++ b/tests/ui/layout/layout-cycle.rs @@ -1,5 +1,6 @@ //@ build-fail -//~^ ERROR: cycle detected when computing layout of +//~^ ERROR: a cycle occurred during layout computation +//~| ERROR: cycle detected when computing layout of // Issue #111176 -- ensure that we do not emit ICE on layout cycles diff --git a/tests/ui/layout/layout-cycle.stderr b/tests/ui/layout/layout-cycle.stderr index 148adf3361a64..a3cdb7edcc232 100644 --- a/tests/ui/layout/layout-cycle.stderr +++ b/tests/ui/layout/layout-cycle.stderr @@ -2,16 +2,10 @@ error[E0391]: cycle detected when computing layout of `S>` | = note: ...which requires computing layout of ` as Tr>::I`... = note: ...which again requires computing layout of `S>`, completing the cycle -note: cycle used when finalizing codegen MIR for `core::mem::size_of::>>` - --> $SRC_DIR/core/src/mem/mod.rs:LL:COL = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -note: the above error was encountered while instantiating `fn std::mem::size_of::>>` - --> $DIR/layout-cycle.rs:25:5 - | -LL | mem::size_of::>() - | ^^^^^^^^^^^^^^^^^^^^^^ +error: failed to get layout for S>: a cycle occurred during layout computation -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/layout/post-mono-layout-cycle.rs b/tests/ui/layout/post-mono-layout-cycle.rs index 6753c01267ecd..8d136190c0052 100644 --- a/tests/ui/layout/post-mono-layout-cycle.rs +++ b/tests/ui/layout/post-mono-layout-cycle.rs @@ -14,6 +14,7 @@ struct Wrapper { } fn abi(_: Option>) {} +//~^ ERROR a cycle occurred during layout computation fn indirect() { abi::(None); diff --git a/tests/ui/layout/post-mono-layout-cycle.stderr b/tests/ui/layout/post-mono-layout-cycle.stderr index e2f6ac595d006..47f7f30b1cb4c 100644 --- a/tests/ui/layout/post-mono-layout-cycle.stderr +++ b/tests/ui/layout/post-mono-layout-cycle.stderr @@ -5,12 +5,12 @@ error[E0391]: cycle detected when computing layout of `Wrapper<()>` = note: cycle used when computing layout of `core::option::Option>` = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information -note: the above error was encountered while instantiating `fn indirect::<()>` - --> $DIR/post-mono-layout-cycle.rs:23:5 +error: a cycle occurred during layout computation + --> $DIR/post-mono-layout-cycle.rs:16:1 | -LL | indirect::<()>(); - | ^^^^^^^^^^^^^^^^ +LL | fn abi(_: Option>) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/lint/large_assignments/copy_into_fn.stderr b/tests/ui/lint/large_assignments/copy_into_fn.stderr index 2cc5eb97a4bdf..f05fc33e17e14 100644 --- a/tests/ui/lint/large_assignments/copy_into_fn.stderr +++ b/tests/ui/lint/large_assignments/copy_into_fn.stderr @@ -12,18 +12,18 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 9999 bytes - --> $DIR/copy_into_fn.rs:17:20 + --> $DIR/copy_into_fn.rs:17:15 | LL | many_args(Data([0; 9999]), true, Data([0; 9999])); - | ^^^^^^^^^ value moved from here + | ^^^^^^^^^^^^^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` error: moving 9999 bytes - --> $DIR/copy_into_fn.rs:17:43 + --> $DIR/copy_into_fn.rs:17:38 | LL | many_args(Data([0; 9999]), true, Data([0; 9999])); - | ^^^^^^^^^ value moved from here + | ^^^^^^^^^^^^^^^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` diff --git a/tests/ui/recursion_limit/zero-overflow.rs b/tests/ui/recursion_limit/zero-overflow.rs index a6b94c72e3510..6b9ed5b2c5ee7 100644 --- a/tests/ui/recursion_limit/zero-overflow.rs +++ b/tests/ui/recursion_limit/zero-overflow.rs @@ -1,4 +1,4 @@ -//~ ERROR overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze` +//~ ERROR overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Unsize i32 + Sync + RefUnwindSafe>` //~| HELP consider increasing the recursion limit //@ build-fail diff --git a/tests/ui/recursion_limit/zero-overflow.stderr b/tests/ui/recursion_limit/zero-overflow.stderr index c7dfb01664f0b..913803a8b34cf 100644 --- a/tests/ui/recursion_limit/zero-overflow.stderr +++ b/tests/ui/recursion_limit/zero-overflow.stderr @@ -1,4 +1,4 @@ -error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Freeze` +error[E0275]: overflow evaluating the requirement `{closure@rt::lang_start<()>::{closure#0}}: Unsize i32 + Sync + RefUnwindSafe>` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "2"]` attribute to your crate (`zero_overflow`)