Rollup merge of #113402 - nnethercote:diagnose-unsorted-CGUs, r=lqd

Diagnose unsorted CGUs.

An assertion failure was reported in #112946. This extra information will help diagnose the problem.

r? `@lqd`
This commit is contained in:
Matthias Krüger 2023-07-06 12:12:12 +02:00 committed by GitHub
commit a7532d9278
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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
}