Skip to content

Commit 5a569b1

Browse files
committed
coverage: Don't track curr_original_span explicitly
Now that we never mutate `curr.span`, we don't need to store its original span separately.
1 parent 412c86c commit 5a569b1

File tree

1 file changed

+2
-11
lines changed
  • compiler/rustc_mir_transform/src/coverage

1 file changed

+2
-11
lines changed

compiler/rustc_mir_transform/src/coverage/spans.rs

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -155,16 +155,11 @@ struct SpansRefiner<'a> {
155155
/// iteration.
156156
some_curr: Option<CoverageSpan>,
157157

158-
/// The original `span` for `curr`, in case `curr.span()` is modified. The `curr_original_span`
159-
/// **must not be mutated** (except when advancing to the next `curr`), even if `curr.span()`
160-
/// is mutated.
161-
curr_original_span: Span,
162-
163158
/// The CoverageSpan from a prior iteration; typically assigned from that iteration's `curr`.
164159
/// If that `curr` was discarded, `prev` retains its value from the previous iteration.
165160
some_prev: Option<CoverageSpan>,
166161

167-
/// Assigned from `curr_original_span` from the previous iteration. The `prev_original_span`
162+
/// Assigned from `curr.span` from the previous iteration. The `prev_original_span`
168163
/// **must not be mutated** (except when advancing to the next `prev`), even if `prev.span()`
169164
/// is mutated.
170165
prev_original_span: Span,
@@ -196,7 +191,6 @@ impl<'a> SpansRefiner<'a> {
196191
basic_coverage_blocks,
197192
sorted_spans_iter: sorted_spans.into_iter(),
198193
some_curr: None,
199-
curr_original_span: DUMMY_SP,
200194
some_prev: None,
201195
prev_original_span: DUMMY_SP,
202196
pending_dups: Vec::new(),
@@ -340,8 +334,8 @@ impl<'a> SpansRefiner<'a> {
340334
/// Advance `prev` to `curr` (if any), and `curr` to the next `CoverageSpan` in sorted order.
341335
fn next_coverage_span(&mut self) -> bool {
342336
if let Some(curr) = self.some_curr.take() {
337+
self.prev_original_span = curr.span;
343338
self.some_prev = Some(curr);
344-
self.prev_original_span = self.curr_original_span;
345339
}
346340
while let Some(curr) = self.sorted_spans_iter.next() {
347341
debug!("FOR curr={:?}", curr);
@@ -356,9 +350,6 @@ impl<'a> SpansRefiner<'a> {
356350
closure?); prev={prev:?}",
357351
);
358352
} else {
359-
// Save a copy of the original span for `curr` in case the `CoverageSpan` is changed
360-
// by `self.curr_mut().merge_from(prev)`.
361-
self.curr_original_span = curr.span;
362353
self.some_curr.replace(curr);
363354
self.maybe_flush_pending_dups();
364355
return true;

0 commit comments

Comments
 (0)