Skip to content

Commit f9d6cb5

Browse files
authored
Rollup merge of #150036 - Urgau:filenames-coverage-150020, r=Zalathar
Use the embeddable filename for coverage artifacts Like debuginfo, coverage artifacts should use the embeddable path (aka absolute path). Unfortunately due to `coverage-run` and `compiletest`, I'm unable to create a reproducer in our test-suite, but when manually invoking `rustc` with the reproducer (#150020 (comment)) I think the issue is fixed. Fixes #150020 r? Zalathar
2 parents 3687a78 + f05ed90 commit f9d6cb5

File tree

1 file changed

+14
-2
lines changed
  • compiler/rustc_codegen_llvm/src/coverageinfo

1 file changed

+14
-2
lines changed

compiler/rustc_codegen_llvm/src/coverageinfo/mapgen.rs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use rustc_codegen_ssa::traits::{BaseTypeCodegenMethods, ConstCodegenMethods};
77
use rustc_data_structures::fx::FxIndexMap;
88
use rustc_index::IndexVec;
99
use rustc_middle::ty::TyCtxt;
10-
use rustc_span::{RemapPathScopeComponents, SourceFile, StableSourceFileId};
10+
use rustc_span::{FileName, RemapPathScopeComponents, SourceFile, StableSourceFileId};
1111
use tracing::debug;
1212

1313
use crate::common::CodegenCx;
@@ -125,7 +125,19 @@ impl GlobalFileTable {
125125

126126
for file in all_files {
127127
raw_file_table.entry(file.stable_id).or_insert_with(|| {
128-
file.name.display(RemapPathScopeComponents::COVERAGE).to_string_lossy().into_owned()
128+
// Prefer using the embeddable filename as this filename is going to
129+
// end-up in the coverage artifacts (see rust-lang/rust#150020).
130+
if let FileName::Real(real) = &file.name {
131+
let (_work_dir, abs_name) =
132+
real.embeddable_name(RemapPathScopeComponents::COVERAGE);
133+
134+
abs_name.to_string_lossy().into_owned()
135+
} else {
136+
file.name
137+
.display(RemapPathScopeComponents::COVERAGE)
138+
.to_string_lossy()
139+
.into_owned()
140+
}
129141
});
130142
}
131143

0 commit comments

Comments
 (0)