Skip to content

Commit 1662a75

Browse files
committed
Also dump coverage info
1 parent 7b13a50 commit 1662a75

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

compiler/rustc_mir_build/src/builder/coverageinfo.rs

Lines changed: 16 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> {
@@ -208,6 +223,7 @@ impl<'tcx> Builder<'_, 'tcx> {
208223
mir::TerminatorKind::if_(mir::Operand::Copy(place), true_block, false_block),
209224
);
210225

226+
// Separate path for handling branches when MC/DC is enabled.
211227
coverage_info.register_two_way_branch(&mut self.cfg, source_info, true_block, false_block);
212228

213229
let join_block = self.cfg.start_new_block();

compiler/rustc_mir_build/src/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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.clone().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)