From fc8536669ca9b1a3820da9f29dc01d87a44ee151 Mon Sep 17 00:00:00 2001 From: Nicholas Nethercote Date: Thu, 6 Jul 2023 17:51:18 +1000 Subject: [PATCH] Diagnose unsorted CGUs. An assertion failure was reported in #112946. This extra information will help diagnose the problem. --- compiler/rustc_monomorphize/src/partitioning.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/compiler/rustc_monomorphize/src/partitioning.rs b/compiler/rustc_monomorphize/src/partitioning.rs index e663f4486f7..f4535fbd58f 100644 --- a/compiler/rustc_monomorphize/src/partitioning.rs +++ b/compiler/rustc_monomorphize/src/partitioning.rs @@ -187,7 +187,13 @@ where } // Ensure CGUs are sorted by name, so that we get deterministic results. - assert!(codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str())))); + if !codegen_units.is_sorted_by(|a, b| Some(a.name().as_str().cmp(b.name().as_str()))) { + let mut names = String::new(); + for cgu in codegen_units.iter() { + names += &format!("- {}\n", cgu.name()); + } + bug!("unsorted CGUs:\n{names}"); + } codegen_units }