about summary refs log tree commit diff
path: root/compiler/rustc_codegen_llvm/src
diff options
context:
space:
mode:
authorZalathar <Zalathar@users.noreply.github.com>2023-08-30 20:08:13 +1000
committerZalathar <Zalathar@users.noreply.github.com>2023-09-11 14:29:09 +1000
commit4f88aa0fbd71b67be4a4910d312015ddc2a654ff (patch)
treed1b1b2143dd9d654aea4c2e7ffb1b7e68f6b5e67 /compiler/rustc_codegen_llvm/src
parent525ac15b66473e63782bff4194e06f665003bd4e (diff)
downloadrust-4f88aa0fbd71b67be4a4910d312015ddc2a654ff.tar.gz
rust-4f88aa0fbd71b67be4a4910d312015ddc2a654ff.zip
coverage: Use a stable sort when grouping mapped regions by file
If two or more mappings cover exactly the same region, their relative order
will now be preserved from `get_expressions_and_counter_regions`, rather than
being disturbed by implementation details of an unstable sort.

The current order is: counter mappings, expression mappings, zero mappings.

(LLVM will also perform its own stable sort on these mappings, but that sort
only compares file ID, start location, and `RegionKind`.)
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
-rw-r--r--compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
index 5e897241cbb..1ad4b249947 100644
--- a/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
+++ b/compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs
@@ -180,7 +180,7 @@ fn write_coverage_mapping<'a>(
     // `file_id` (indexing files referenced by the current function), and construct the
     // function-specific `virtual_file_mapping` from `file_id` to its index in the module's
     // `filenames` array.
-    counter_regions.sort_unstable_by_key(|(_counter, region)| *region);
+    counter_regions.sort_by_key(|(_counter, region)| *region);
     for (counter, region) in counter_regions {
         let CodeRegion { file_name, start_line, start_col, end_line, end_col } = *region;
         let same_file = current_file_name.is_some_and(|p| p == file_name);