Skip to content

Commit c131063

Browse files
committed
Added a unit test for BcbCounters
Restructured the code a little, to allow getting both the mir::Body and coverage graph.
1 parent eb9f2bb commit c131063

File tree

3 files changed

+188
-102
lines changed

3 files changed

+188
-102
lines changed

compiler/rustc_mir/src/transform/coverage/counters.rs

-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ struct BcbCounters<'a> {
120120
basic_coverage_blocks: &'a mut CoverageGraph,
121121
}
122122

123-
// FIXME(richkadel): Add unit tests for `BcbCounters` functions/algorithms.
124123
impl<'a> BcbCounters<'a> {
125124
fn new(
126125
coverage_counters: &'a mut CoverageCounters,

compiler/rustc_mir/src/transform/coverage/spans.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -645,7 +645,10 @@ impl<'a, 'tcx> CoverageSpans<'a, 'tcx> {
645645
}
646646
}
647647

648-
fn filtered_statement_span(statement: &'a Statement<'tcx>, body_span: Span) -> Option<Span> {
648+
pub(super) fn filtered_statement_span(
649+
statement: &'a Statement<'tcx>,
650+
body_span: Span,
651+
) -> Option<Span> {
649652
match statement.kind {
650653
// These statements have spans that are often outside the scope of the executed source code
651654
// for their parent `BasicBlock`.
@@ -686,7 +689,10 @@ fn filtered_statement_span(statement: &'a Statement<'tcx>, body_span: Span) -> O
686689
}
687690
}
688691

689-
fn filtered_terminator_span(terminator: &'a Terminator<'tcx>, body_span: Span) -> Option<Span> {
692+
pub(super) fn filtered_terminator_span(
693+
terminator: &'a Terminator<'tcx>,
694+
body_span: Span,
695+
) -> Option<Span> {
690696
match terminator.kind {
691697
// These terminators have spans that don't positively contribute to computing a reasonable
692698
// span of actually executed source code. (For example, SwitchInt terminators extracted from

0 commit comments

Comments
 (0)