Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rollup of 4 pull requests #124964

Closed
wants to merge 13 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
coverage: Destructure the mappings struct to make sure we don't miss any
  • Loading branch information
Zalathar committed May 6, 2024
commit 84cedbec9dc007deca85d226097624ec1bf5ee4e
17 changes: 13 additions & 4 deletions compiler/rustc_mir_transform/src/coverage/mod.rs
Original file line number Diff line number Diff line change
@@ -151,17 +151,26 @@ fn create_mappings<'tcx>(
};
let region_for_span = |span: Span| make_code_region(source_map, file_name, span, body_span);

// Fully destructure the mappings struct to make sure we don't miss any kinds.
let CoverageSpans {
code_mappings,
branch_pairs,
mcdc_bitmap_bytes: _,
mcdc_branches,
mcdc_decisions,
} = coverage_spans;
let mut mappings = Vec::new();

mappings.extend(coverage_spans.code_mappings.iter().filter_map(
mappings.extend(code_mappings.iter().filter_map(
// Ordinary code mappings are the simplest kind.
|&mappings::CodeMapping { span, bcb }| {
let code_region = region_for_span(span)?;
let kind = MappingKind::Code(term_for_bcb(bcb));
Some(Mapping { kind, code_region })
},
));

mappings.extend(coverage_spans.branch_pairs.iter().filter_map(
mappings.extend(branch_pairs.iter().filter_map(
|&mappings::BranchPair { span, true_bcb, false_bcb }| {
let true_term = term_for_bcb(true_bcb);
let false_term = term_for_bcb(false_bcb);
@@ -171,7 +180,7 @@ fn create_mappings<'tcx>(
},
));

mappings.extend(coverage_spans.mcdc_branches.iter().filter_map(
mappings.extend(mcdc_branches.iter().filter_map(
|&mappings::MCDCBranch { span, true_bcb, false_bcb, condition_info, decision_depth: _ }| {
let code_region = region_for_span(span)?;
let true_term = term_for_bcb(true_bcb);
@@ -184,7 +193,7 @@ fn create_mappings<'tcx>(
},
));

mappings.extend(coverage_spans.mcdc_decisions.iter().filter_map(
mappings.extend(mcdc_decisions.iter().filter_map(
|&mappings::MCDCDecision { span, bitmap_idx, conditions_num, .. }| {
let code_region = region_for_span(span)?;
let kind = MappingKind::MCDCDecision(DecisionInfo { bitmap_idx, conditions_num });