Struct rustc_mir_transform::coverage::spans::SpansRefiner
source · struct SpansRefiner {
sorted_spans_iter: IntoIter<SpanFromMir>,
some_curr: Option<CurrCovspan>,
some_prev: Option<PrevCovspan>,
refined_spans: Vec<RefinedCovspan>,
}Expand description
Converts the initial set of coverage spans (one per MIR Statement or Terminator) into a
minimal set of coverage spans, using the BCB CFG to determine where it is safe and useful to:
- Remove duplicate source code coverage regions
- Merge spans that represent continuous (both in source code and control flow), non-branching execution
- Carve out (leave uncovered) any “hole” spans that need to be left blank (e.g. closures that will be counted by their own MIR body)
Fields§
§sorted_spans_iter: IntoIter<SpanFromMir>The initial set of coverage spans, sorted by Span (lo and hi) and by relative
dominance between the BasicCoverageBlocks of equal Spans.
some_curr: Option<CurrCovspan>The current coverage span to compare to its prev, to possibly merge, discard,
or cause prev to be modified or discarded.
If curr is not discarded or merged, it becomes prev for the next iteration.
some_prev: Option<PrevCovspan>The coverage span from a prior iteration; typically assigned from that iteration’s curr.
If that curr was discarded, prev retains its value from the previous iteration.
refined_spans: Vec<RefinedCovspan>The final coverage spans to add to the coverage map. A Counter or Expression
will also be injected into the MIR for each BCB that has associated spans.
Implementations§
source§impl SpansRefiner
impl SpansRefiner
sourcefn refine_sorted_spans(sorted_spans: Vec<SpanFromMir>) -> Vec<RefinedCovspan>
fn refine_sorted_spans(sorted_spans: Vec<SpanFromMir>) -> Vec<RefinedCovspan>
Takes the initial list of (sorted) spans extracted from MIR, and “refines” them by merging compatible adjacent spans, removing redundant spans, and carving holes in spans when they overlap in unwanted ways.
sourcefn to_refined_spans(self) -> Vec<RefinedCovspan>
fn to_refined_spans(self) -> Vec<RefinedCovspan>
Iterate through the sorted coverage spans, and return the refined list of merged and de-duplicated spans.
fn curr(&self) -> &CurrCovspan
sourcefn take_curr(&mut self) -> CurrCovspan
fn take_curr(&mut self) -> CurrCovspan
If called, then the next call to next_coverage_span() will not update prev with the
curr coverage span.
fn prev(&self) -> &PrevCovspan
fn prev_mut(&mut self) -> &mut PrevCovspan
fn take_prev(&mut self) -> PrevCovspan
sourcefn next_coverage_span(&mut self) -> bool
fn next_coverage_span(&mut self) -> bool
Advance prev to curr (if any), and curr to the next coverage span in sorted order.
sourcefn carve_out_span_for_hole(&mut self)
fn carve_out_span_for_hole(&mut self)
If prevs span extends left of the hole (curr), carve out the hole’s span from
prev’s span. Add the portion of the span to the left of the hole; and if the span
extends to the right of the hole, update prev to that portion of the span.
sourcefn cutoff_prev_at_overlapping_curr(&mut self)
fn cutoff_prev_at_overlapping_curr(&mut self)
curr overlaps prev. If prevs span extends left of currs span, keep only
statements that end before curr.lo() (if any), and add the portion of the
combined span for those statements. Any other statements have overlapping spans
that can be ignored because curr and/or other upcoming statements/spans inside
the overlap area will produce their own counters. This disambiguation process
avoids injecting multiple counters for overlapping spans, and the potential for
double-counting.
Auto Trait Implementations§
impl !DynSend for SpansRefiner
impl !DynSync for SpansRefiner
impl Freeze for SpansRefiner
impl RefUnwindSafe for SpansRefiner
impl Send for SpansRefiner
impl Sync for SpansRefiner
impl Unpin for SpansRefiner
impl UnwindSafe for SpansRefiner
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§impl<T> Filterable for T
impl<T> Filterable for T
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<P> IntoQueryParam<P> for P
impl<P> IntoQueryParam<P> for P
fn into_query_param(self) -> P
source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<'tcx, T> ToPredicate<'tcx, T> for T
impl<'tcx, T> ToPredicate<'tcx, T> for T
fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T
source§impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
impl<Tcx, T> Value<Tcx> for Twhere
Tcx: DepContext,
default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed ) -> T
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<'a, T> Captures<'a> for Twhere
T: ?Sized,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 112 bytes