Diagnose unsorted CGUs.

An assertion failure was reported in #112946. This extra information
will help diagnose the problem.
This commit is contained in:
Nicholas Nethercote 2023-07-06 17:51:18 +10:00
parent d9c13cd453
commit fc8536669c

View File

@ -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
}