Skip to content

Commit 12cab51

Browse files
author
zhuyunxing
committed
coverage. Refactor MCDCInfoBuilder for pattern matching implementation
1 parent 50298a8 commit 12cab51

File tree

3 files changed

+307
-133
lines changed

3 files changed

+307
-133
lines changed

compiler/rustc_middle/src/mir/coverage.rs

+8
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ rustc_index::newtype_index! {
5151
pub struct ExpressionId {}
5252
}
5353

54+
rustc_index::newtype_index! {
55+
/// ID of a mcdc decision. Used to identify decision in a function.
56+
#[derive(HashStable)]
57+
#[encodable]
58+
#[debug_format = "DecisionId({})"]
59+
pub struct DecisionId {}
60+
}
61+
5462
rustc_index::newtype_index! {
5563
/// ID of a mcdc condition. Used by llvm to check mcdc coverage.
5664
///

compiler/rustc_mir_build/src/build/coverageinfo.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,11 @@ impl<'tcx> Builder<'_, 'tcx> {
238238

239239
// Separate path for handling branches when MC/DC is enabled.
240240
if let Some(mcdc_info) = branch_info.mcdc_info.as_mut() {
241-
let inject_block_marker = |source_info, block| {
242-
branch_info.markers.inject_block_marker(&mut self.cfg, source_info, block)
243-
};
241+
let inject_block_marker =
242+
|block| branch_info.markers.inject_block_marker(&mut self.cfg, source_info, block);
244243
mcdc_info.visit_evaluated_condition(
245244
self.tcx,
246-
source_info,
245+
source_info.span,
247246
then_block,
248247
else_block,
249248
inject_block_marker,

0 commit comments

Comments
 (0)