about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage/spans
AgeCommit message (Collapse)AuthorLines
2025-08-24coverage: Build an "expansion tree" and use it to unexpand raw spansZalathar-32/+2
2025-08-06coverage: Remove all unstable support for MC/DC instrumentationZalathar-5/+1
2025-04-01coverage: Shrink call spans to just the function nameZalathar-11/+7
This is a way to shrink call spans that doesn't involve mixing different spans, and avoids overlap with argument spans. This patch also removes some low-value comments that were causing rustfmt to ignore the match arms.
2025-03-21coverage: Separate span-extraction from unexpansionZalathar-70/+35
2025-02-06coverage: Defer part of counter-creation until codegenZalathar-2/+1
2024-12-20coverage: Rename `basic_coverage_blocks` to just `graph`Zalathar-2/+2
During coverage instrumentation, this variable always holds the coverage graph, which is a simplified view of the MIR control-flow graph. The new name is clearer in context, and also shorter.
2024-11-20reduce false positives of tail-expr-drop-order from consumed valuesDing Xiang Fei-0/+1
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <nikomat@amazon.com> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
2024-09-22Reformat using the new identifier sorting from rustfmtMichael Goulet-1/+1
2024-09-06coverage: Treat await similar to a macroJonathan Conder-11/+11
Currently `await` is only counted towards coverage if the containing function is suspended and resumed at least once. This is because it expands to code which contains a branch on the discriminant of `Poll`. By treating it like a branching macro (e.g. `assert!`), these implementation details will be hidden from the coverage results.
2024-07-08coverage: Extract hole spans from HIR instead of MIRZalathar-35/+6
This makes it possible to treat more kinds of nested item/code as holes, instead of being restricted to closures.
2024-07-07Support tail calls in mir via `TerminatorKind::TailCall`Maybe Waffle-1/+2
2024-06-30coverage: Move span unexpansion into its own submoduleZalathar-54/+2
2024-06-16coverage: Eagerly convert coverage spans to a simpler formZalathar-14/+4
2024-06-16coverage: Move most span processing back into `coverage::spans`Zalathar-151/+17
2024-06-16coverage: More consistent variable names for span processingZalathar-21/+21
2024-06-04coverage: Use hole spans to carve up coverage spans into separate bucketsZalathar-54/+145
This performs the same task as the hole-carving code in the main span refiner, but in a separate earlier pass.
2024-06-04coverage: Build up initial spans by appending to a vectorZalathar-18/+21
This is less elegant than returning an iterator, but more flexible.
2024-06-04coverage: Return a nested vector from initial span extractionZalathar-2/+2
This will allow the span extractor to produce multiple separate buckets, instead of just one flat list of spans.
2024-05-13Remove `extern crate rustc_middle` from `rustc_mir_transform`.Nicholas Nethercote-0/+1
2024-04-30coverage: Split off `mappings.rs` from `spans.rs` and `from_mir.rs`Zalathar-144/+2
2024-04-30coverage: Prepare to split `spans.rs` into two filesZalathar-1/+1
2024-04-29mcdc-coverage: Add decision_depth field in structsDorian Péron-8/+19
Add decision_depth field to TVBitmapUpdate/CondBitmapUpdate statements Add decision_depth field to BcbMappingKinds MCDCBranch and MCDCDecision Add decision_depth field to MCDCBranchSpan and MCDCDecisionSpan
2024-04-22coverage: Separate branch pairs from other mapping kindsZalathar-5/+5
This clears the way for larger changes to how branches are handled by the coverage instrumentor, in order to support branch coverage for more language constructs.
2024-04-22coverage: Detach MC/DC branch spans from regular branch spansZalathar-18/+56
MC/DC's reliance on the existing branch coverage types is making it much harder to improve branch coverage.
2024-04-19coverage. Generate Mappings of decisions and conditions for MC/DCzhuyunxing-10/+59
2024-03-23Unbox and unwrap the contents of `StatementKind::Coverage`Zalathar-20/+14
The payload of coverage statements was historically a structure with several fields, so it was boxed to avoid bloating `StatementKind`. Now that the payload is a single relatively-small enum, we can replace `Box<Coverage>` with just `CoverageKind`. This patch also adds a size assertion for `StatementKind`, to avoid accidentally bloating it in the future.
2024-03-17some minor code simplificationsMatthias Krüger-3/+2
2024-03-14coverage: Include recorded branch info in coverage instrumentationZalathar-3/+52
2024-03-13coverage: Add `CoverageKind::BlockMarker`Zalathar-0/+5
2024-02-23coverage: Rename `is_closure` to `is_hole`Zalathar-11/+16
When refining covspans, we don't specifically care which ones represent closures; we just want to know which ones represent "holes" that should be carved out of other spans and then discarded. (Closures are currently the only source of hole spans, but in the future we might want to also create hole spans for nested items and inactive `#[cfg(..)]` regions.)
2024-02-21coverage: Eagerly deduplicate covspans with the same spanZalathar-5/+10
2024-02-16coverage: Discard spans that fill the entire function bodyZalathar-4/+9
When we try to extract coverage-relevant spans from MIR, sometimes we see MIR statements/terminators whose spans cover the entire function body. Those spans tend to be unhelpful for coverage purposes, because they often represent compiler-inserted code, e.g. the implicit return value of `()`.
2024-02-13coverage: Split `CoverageSpan` into several distinct structsZalathar-15/+9
This requires some extra boilerplate, but in exchange it becomes much easier to see how each field and method is actually used.
2024-02-11is_closure_likeMichael Goulet-2/+2
2024-02-06Teach typeck/borrowck/solvers how to deal with async closuresMichael Goulet-1/+3
2024-02-05coverage: Make `fn_sig_span` optional, and note its quirksZalathar-1/+5
2024-02-05coverage: Hoist special handling of async function spansZalathar-18/+10
This sidesteps the normal span refinement code in cases where we know that we are only dealing with the special signature span that represents having called an async function.
2024-01-24coverage: Flatten the functions for extracting/refining coverage spansZalathar-0/+6
Consolidating this code into flatter functions reduces the amount of pointer-chasing required to read and modify it.
2024-01-05coverage: Split out `SpanFromMir` from `CoverageSpan`Zalathar-10/+47
This draws a clear distinction between the fields/methods that are needed by initial span extraction and preprocessing, and those that are needed by the main "refinement" loop.
2024-01-05coverage: Hoist the splitting of visible macro invocationsZalathar-0/+36
2024-01-05coverage: Hoist the removal of unwanted macro expansion spansZalathar-0/+24
2024-01-05coverage: Overhaul how "visible macros" are determinedZalathar-8/+51
2024-01-05coverage: Avoid early returns from `mir_to_initial_sorted_coverage_spans`Zalathar-15/+14
2023-12-30is_coroutine -> is_coroutine_or_closureMichael Goulet-2/+2
2023-12-28Remove movability from TyKind::CoroutineMichael Goulet-1/+1
2023-12-27coverage: Unexpand spans with `find_ancestor_inside_same_ctxt`Zalathar-6/+1
2023-12-20coverage: Check for `async fn` explicitly, without needing a heuristicZalathar-11/+8
The old code used a heuristic to detect async functions and adjust their coverage spans to produce better output. But there's no need to resort to a heuristic when we can just check whether the current function is actually an `async fn`.
2023-12-20coverage: Pass around `&ExtractedHirInfo` instead of individual fieldsZalathar-2/+4
This reduces the risk of mixing up `fn_source_span` and `body_span`, and makes it easier to pass along additional fields as needed.
2023-12-09Rollup merge of #118666 - Zalathar:body-closure, r=cjgillotJubilee-0/+10
coverage: Simplify the heuristic for ignoring `async fn` return spans The code for extracting coverage spans from MIR has a special heuristic for dealing with `async fn`, so that the function's closing brace does not have a confusing double count. The code implementing that heuristic is currently mixed in with the code for flushing remaining spans after the main refinement loop, making the refinement code harder to understand. We can solve that by hoisting the heuristic to an earlier stage, after the spans have been extracted and sorted but before they have been processed by the refinement loop. The coverage tests verify that the heuristic is still effective, so coverage mappings/reports for `async fn` have not changed. --- This PR also has the side-effect of fixing the `None some_prev` panic that started appearing after #118525. The old code assumed that `prev` would always be present after the refinement loop. That was only true if the list of collected spans was non-empty, but prior to #118525 that didn't seem to come up in practice. After that change, the list of collected spans could be empty in some specific circumstances, leading to panics. The new code uses an `if let` to inspect `prev`, which correctly does nothing if there is no span present.
2023-12-08coverage: Simplify the heuristic for ignoring `async fn` return spansZalathar-0/+10