Skip to content

Commit 8fa294c

Browse files
committed
coverage: Update comments/logs that referred to CoverageSpan
The concrete type `CoverageSpan` is no longer used outside of the `spans` module. This is a separate patch to avoid noise in the preceding patch that actually encapsulates coverage spans.
1 parent 7a50256 commit 8fa294c

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

compiler/rustc_mir_transform/src/coverage/counters.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ impl CoverageCounters {
9191
}
9292

9393
/// Makes [`BcbCounter`] `Counter`s and `Expressions` for the `BasicCoverageBlock`s directly or
94-
/// indirectly associated with `CoverageSpans`, and accumulates additional `Expression`s
94+
/// indirectly associated with coverage spans, and accumulates additional `Expression`s
9595
/// representing intermediate values.
9696
pub fn make_bcb_counters(
9797
&mut self,
@@ -206,7 +206,7 @@ impl CoverageCounters {
206206
}
207207

208208
/// Traverse the `CoverageGraph` and add either a `Counter` or `Expression` to every BCB, to be
209-
/// injected with `CoverageSpan`s. `Expressions` have no runtime overhead, so if a viable expression
209+
/// injected with coverage spans. `Expressions` have no runtime overhead, so if a viable expression
210210
/// (adding or subtracting two other counters or expressions) can compute the same result as an
211211
/// embedded counter, an `Expression` should be used.
212212
struct MakeBcbCounters<'a> {
@@ -239,7 +239,7 @@ impl<'a> MakeBcbCounters<'a> {
239239
debug!("make_bcb_counters(): adding a counter or expression to each BasicCoverageBlock");
240240

241241
// Walk the `CoverageGraph`. For each `BasicCoverageBlock` node with an associated
242-
// `CoverageSpan`, add a counter. If the `BasicCoverageBlock` branches, add a counter or
242+
// coverage span, add a counter. If the `BasicCoverageBlock` branches, add a counter or
243243
// expression to each branch `BasicCoverageBlock` (if the branch BCB has only one incoming
244244
// edge) or edge from the branching BCB to the branch BCB (if the branch BCB has multiple
245245
// incoming edges).
@@ -251,15 +251,15 @@ impl<'a> MakeBcbCounters<'a> {
251251
let mut traversal = TraverseCoverageGraphWithLoops::new(&self.basic_coverage_blocks);
252252
while let Some(bcb) = traversal.next(self.basic_coverage_blocks) {
253253
if bcb_has_coverage_spans(bcb) {
254-
debug!("{:?} has at least one `CoverageSpan`. Get or make its counter", bcb);
254+
debug!("{:?} has at least one coverage span. Get or make its counter", bcb);
255255
let branching_counter_operand = self.get_or_make_counter_operand(bcb)?;
256256

257257
if self.bcb_needs_branch_counters(bcb) {
258258
self.make_branch_counters(&mut traversal, bcb, branching_counter_operand)?;
259259
}
260260
} else {
261261
debug!(
262-
"{:?} does not have any `CoverageSpan`s. A counter will only be added if \
262+
"{:?} does not have any coverage spans. A counter will only be added if \
263263
and when a covered BCB has an expression dependency.",
264264
bcb,
265265
);

compiler/rustc_mir_transform/src/coverage/graph.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,9 +288,9 @@ rustc_index::newtype_index! {
288288
/// not relevant to coverage analysis. `FalseUnwind`, for example, can be treated the same as
289289
/// a `Goto`, and merged with its successor into the same BCB.
290290
///
291-
/// Each BCB with at least one computed `CoverageSpan` will have no more than one `Counter`.
291+
/// Each BCB with at least one computed coverage span will have no more than one `Counter`.
292292
/// In some cases, a BCB's execution count can be computed by `Expression`. Additional
293-
/// disjoint `CoverageSpan`s in a BCB can also be counted by `Expression` (by adding `ZERO`
293+
/// disjoint coverage spans in a BCB can also be counted by `Expression` (by adding `ZERO`
294294
/// to the BCB's primary counter or expression).
295295
///
296296
/// The BCB CFG is critical to simplifying the coverage analysis by ensuring graph path-based

compiler/rustc_mir_transform/src/coverage/mod.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
154154
let body_span = self.body_span;
155155

156156
////////////////////////////////////////////////////
157-
// Compute `CoverageSpan`s from the `CoverageGraph`.
157+
// Compute coverage spans from the `CoverageGraph`.
158158
let coverage_spans = CoverageSpans::generate_coverage_spans(
159159
&self.mir_body,
160160
fn_sig_span,
@@ -164,9 +164,9 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
164164

165165
////////////////////////////////////////////////////
166166
// Create an optimized mix of `Counter`s and `Expression`s for the `CoverageGraph`. Ensure
167-
// every `CoverageSpan` has a `Counter` or `Expression` assigned to its `BasicCoverageBlock`
167+
// every coverage span has a `Counter` or `Expression` assigned to its `BasicCoverageBlock`
168168
// and all `Expression` dependencies (operands) are also generated, for any other
169-
// `BasicCoverageBlock`s not already associated with a `CoverageSpan`.
169+
// `BasicCoverageBlock`s not already associated with a coverage span.
170170
//
171171
// Intermediate expressions (used to compute other `Expression` values), which have no
172172
// direct association with any `BasicCoverageBlock`, are accumulated inside `coverage_counters`.
@@ -177,20 +177,20 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
177177

178178
if let Ok(()) = result {
179179
////////////////////////////////////////////////////
180-
// Remove the counter or edge counter from of each `CoverageSpan`s associated
180+
// Remove the counter or edge counter from of each coverage cpan's associated
181181
// `BasicCoverageBlock`, and inject a `Coverage` statement into the MIR.
182182
//
183-
// `Coverage` statements injected from `CoverageSpan`s will include the code regions
183+
// `Coverage` statements injected from coverage spans will include the code regions
184184
// (source code start and end positions) to be counted by the associated counter.
185185
//
186-
// These `CoverageSpan`-associated counters are removed from their associated
186+
// These coverage-span-associated counters are removed from their associated
187187
// `BasicCoverageBlock`s so that the only remaining counters in the `CoverageGraph`
188188
// are indirect counters (to be injected next, without associated code regions).
189189
self.inject_coverage_span_counters(&coverage_spans);
190190

191191
////////////////////////////////////////////////////
192192
// For any remaining `BasicCoverageBlock` counters (that were not associated with
193-
// any `CoverageSpan`), inject `Coverage` statements (_without_ code region `Span`s)
193+
// any coverage span), inject `Coverage` statements (_without_ code region spans)
194194
// to ensure `BasicCoverageBlock` counters that other `Expression`s may depend on
195195
// are in fact counted, even though they don't directly contribute to counting
196196
// their own independent code region's coverage.
@@ -215,9 +215,9 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
215215
}
216216
}
217217

218-
/// Inject a counter for each `CoverageSpan`. There can be multiple `CoverageSpan`s for a given
219-
/// BCB, but only one actual counter needs to be incremented per BCB. `bb_counters` maps each
220-
/// `bcb` to its `Counter`, when injected. Subsequent `CoverageSpan`s for a BCB that already has
218+
/// Inject a counter for each coverage span. There can be multiple coverage spans for a given
219+
/// BCB, but only one actual counter needs to be incremented per BCB. `bcb_counters` maps each
220+
/// `bcb` to its `Counter`, when injected. Subsequent coverage spans for a BCB that already has
221221
/// a `Counter` will inject an `Expression` instead, and compute its value by adding `ZERO` to
222222
/// the BCB `Counter` value.
223223
fn inject_coverage_span_counters(&mut self, coverage_spans: &CoverageSpans) {
@@ -248,12 +248,12 @@ impl<'a, 'tcx> Instrumentor<'a, 'tcx> {
248248
}
249249
}
250250

251-
/// `inject_coverage_span_counters()` looped through the `CoverageSpan`s and injected the
252-
/// counter from the `CoverageSpan`s `BasicCoverageBlock`, removing it from the BCB in the
251+
/// `inject_coverage_span_counters()` looped through the coverage spans and injected the
252+
/// counter from the coverage span's `BasicCoverageBlock`, removing it from the BCB in the
253253
/// process (via `take_counter()`).
254254
///
255255
/// Any other counter associated with a `BasicCoverageBlock`, or its incoming edge, but not
256-
/// associated with a `CoverageSpan`, should only exist if the counter is an `Expression`
256+
/// associated with a coverage span, should only exist if the counter is an `Expression`
257257
/// dependency (one of the expression operands). Collect them, and inject the additional
258258
/// counters into the MIR, without a reportable coverage span.
259259
fn inject_indirect_counters(&mut self) {

0 commit comments

Comments
 (0)