Skip to content

Commit 44c8262

Browse files
committed
Don't consume CoverageInfoBuilder when building
1 parent 4c7749e commit 44c8262

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

compiler/rustc_mir_build/src/builder/coverageinfo.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,15 @@ impl CoverageInfoBuilder {
147147
});
148148
}
149149

150-
pub(crate) fn into_done(self) -> Box<CoverageInfoHi> {
151-
let Self { nots: _, markers: BlockMarkerGen { num_block_markers }, branch_info } = self;
152-
153-
let branch_spans =
154-
branch_info.map(|branch_info| branch_info.branch_spans).unwrap_or_default();
150+
pub(crate) fn build(&self) -> Box<CoverageInfoHi> {
151+
let &Self { nots: _, markers: BlockMarkerGen { num_block_markers }, ref branch_info } =
152+
self;
153+
154+
let branch_spans = branch_info
155+
.as_ref()
156+
.map(|branch_info| branch_info.branch_spans.as_slice())
157+
.unwrap_or_default()
158+
.to_owned();
155159

156160
// For simplicity, always return an info struct (without Option), even
157161
// if there's nothing interesting in it.

compiler/rustc_mir_build/src/builder/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -802,7 +802,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
802802
self.coroutine,
803803
None,
804804
);
805-
body.coverage_info_hi = self.coverage_info.map(|b| b.into_done());
805+
body.coverage_info_hi = self.coverage_info.as_ref().map(|b| b.build());
806806

807807
for (index, block) in body.basic_blocks.iter().enumerate() {
808808
if block.terminator.is_none() {

0 commit comments

Comments
 (0)