Skip to content

Commit d334059

Browse files
authored
Rollup merge of #77992 - nagisa:thaw-coverage-instrumentation, r=wesleywiser
instrument-coverage: try our best to not ICE instrument-coverage was ICEing for me on some code, in particular code that had devirtualized paths from standard library. Instrument coverage probably has no bussiness dictating which paths are valid and which aren't so just feed it everything and whatever and let tooling deal with other stuff. For example, with this commit we can generate coverage hitpoints for these interesting paths: * `/rustc/.../library/core/lib.rs` – non-devirtualized path for libcore * `/home/.../src/library/core/lib.rs` – devirtualized version of above * `<inline asm>`, `<anon>` and many similar synthetic paths Even if those paths somehow get to the instrumentation pass, I'd much rather get hits for these weird paths and hope some of them work (as would be the case for devirtualized path to libcore), rather than have compilation fail entirely.
2 parents b4282b3 + 8436cfe commit d334059

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

compiler/rustc_mir/src/transform/instrument_coverage.rs

+2-10
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,7 @@ use rustc_middle::ty::query::Providers;
2222
use rustc_middle::ty::TyCtxt;
2323
use rustc_span::def_id::DefId;
2424
use rustc_span::source_map::original_sp;
25-
use rustc_span::{
26-
BytePos, CharPos, FileName, Pos, RealFileName, SourceFile, Span, Symbol, SyntaxContext,
27-
};
25+
use rustc_span::{BytePos, CharPos, Pos, SourceFile, Span, Symbol, SyntaxContext};
2826

2927
use std::cmp::Ordering;
3028

@@ -549,13 +547,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
549547
let mir_body = &self.mir_body;
550548
let body_span = self.body_span();
551549
let source_file = source_map.lookup_source_file(body_span.lo());
552-
let file_name = match &source_file.name {
553-
FileName::Real(RealFileName::Named(path)) => Symbol::intern(&path.to_string_lossy()),
554-
_ => bug!(
555-
"source_file.name should be a RealFileName, but it was: {:?}",
556-
source_file.name
557-
),
558-
};
550+
let file_name = Symbol::intern(&source_file.name.to_string());
559551

560552
debug!("instrumenting {:?}, span: {}", def_id, source_map.span_to_string(body_span));
561553

0 commit comments

Comments
 (0)