Sort scraped call locations before serializing

This commit is contained in:
Will Crichton
2021-11-04 13:57:09 -07:00
parent ce943d26f8
commit 3ad6d12827
5 changed files with 26 additions and 4 deletions

View File

@@ -240,6 +240,13 @@ crate fn run(
let mut finder = FindCalls { calls: &mut calls, tcx, map: tcx.hir(), cx, target_crates };
tcx.hir().visit_all_item_likes(&mut finder.as_deep_visitor());
// Sort call locations within a given file in document order
for fn_calls in calls.values_mut() {
for file_calls in fn_calls.values_mut() {
file_calls.locations.sort_by_key(|loc| loc.call_expr.byte_span.0);
}
}
// Save output to provided path
let mut encoder = FileEncoder::new(options.output_path).map_err(|e| e.to_string())?;
calls.encode(&mut encoder).map_err(|e| e.to_string())?;