Skip to content

Commit 695473a

Browse files
committed
Also dump coverage info
1 parent 7b13a50 commit 695473a

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

compiler/rustc_mir_build/src/builder/coverageinfo.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,21 @@ impl CoverageInfoBuilder {
157157
// if there's nothing interesting in it.
158158
Box::new(CoverageInfoHi { num_block_markers, branch_spans })
159159
}
160+
161+
pub(crate) fn as_done(&self) -> Box<CoverageInfoHi> {
162+
let &Self { nots: _, markers: BlockMarkerGen { num_block_markers }, ref branch_info } =
163+
self;
164+
165+
let branch_spans = branch_info
166+
.as_ref()
167+
.map(|branch_info| branch_info.branch_spans.as_slice())
168+
.unwrap_or_default()
169+
.to_owned();
170+
171+
// For simplicity, always return an info struct (without Option), even
172+
// if there's nothing interesting in it.
173+
Box::new(CoverageInfoHi { num_block_markers, branch_spans })
174+
}
160175
}
161176

162177
impl<'tcx> Builder<'_, 'tcx> {

compiler/rustc_mir_build/src/builder/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
791791

792792
#[allow(dead_code)]
793793
fn dump_for_debugging(&self) {
794-
let body = Body::new(
794+
let mut body = Body::new(
795795
MirSource::item(self.def_id.to_def_id()),
796796
self.cfg.basic_blocks.clone(),
797797
self.source_scopes.clone(),
@@ -803,7 +803,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
803803
self.coroutine.clone(),
804804
None,
805805
);
806-
//body.coverage_info_hi = self.coverage_info.clone().map(|b| b.into_done());
806+
body.coverage_info_hi = self.coverage_info.as_ref().map(|b| b.as_done());
807807

808808
use rustc_middle::mir::pretty;
809809
let options = pretty::PrettyPrintMirOptions::from_cli(self.tcx);

0 commit comments

Comments
 (0)