Skip to content

Commit 9fd6d97

Browse files
committed
Improve sorting in debug_dump.
Currently it sorts by symbol name, which is a mangled name like `_ZN1a4main17hb29587cdb6db5f42E`, which leads to non-obvious orderings. This commit changes it to use the existing `items_in_deterministic_order`, which iterates in source code order.
1 parent 0a1cd5b commit 9fd6d97

File tree

1 file changed

+1
-6
lines changed

1 file changed

+1
-6
lines changed

compiler/rustc_monomorphize/src/partitioning.rs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,15 +864,10 @@ fn debug_dump<'a, 'tcx: 'a>(tcx: TyCtxt<'tcx>, label: &str, cgus: &[CodegenUnit<
864864
cgu.size_estimate()
865865
);
866866

867-
// The order of `cgu.items()` is non-deterministic; sort it by name
868-
// to give deterministic output.
869-
let mut items: Vec<_> = cgu.items().iter().collect();
870-
items.sort_by_key(|(item, _)| item.symbol_name(tcx).name);
871-
for (item, linkage) in items {
867+
for (item, linkage) in cgu.items_in_deterministic_order(tcx) {
872868
let symbol_name = item.symbol_name(tcx).name;
873869
let symbol_hash_start = symbol_name.rfind('h');
874870
let symbol_hash = symbol_hash_start.map_or("<no hash>", |i| &symbol_name[i..]);
875-
876871
let size = item.size_estimate(tcx);
877872
let _ = with_no_trimmed_paths!(writeln!(
878873
s,

0 commit comments

Comments
 (0)