Skip to content

Commit d7d0765

Browse files
committed
rustc_span: Make hygiene debug printing reproducible
1 parent ded08e4 commit d7d0765

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

compiler/rustc_span/src/hygiene.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,10 @@ pub fn debug_hygiene_data(verbose: bool) -> String {
601601
let expn_data = expn_data.as_ref().expect("no expansion data for an expansion ID");
602602
debug_expn_data((&id.to_expn_id(), expn_data))
603603
});
604-
data.foreign_expn_data.iter().for_each(debug_expn_data);
604+
// Sort the hash map for more reproducible output.
605+
let mut foreign_expn_data: Vec<_> = data.foreign_expn_data.iter().collect();
606+
foreign_expn_data.sort_by_key(|(id, _)| (id.krate, id.local_id));
607+
foreign_expn_data.into_iter().for_each(debug_expn_data);
605608
s.push_str("\n\nSyntaxContexts:");
606609
data.syntax_context_data.iter().enumerate().for_each(|(id, ctxt)| {
607610
s.push_str(&format!(

0 commit comments

Comments
 (0)