about summary refs log tree commit diff
path: root/compiler/rustc_mir_transform/src/coverage
AgeCommit message (Collapse)AuthorLines
2025-09-05remove couple of clonesMatthias Krüger-1/+1
2025-08-24coverage: Build an "expansion tree" and use it to unexpand raw spansZalathar-141/+211
2025-08-22Uplift rustc_mir_transform::coverage::counters::union_find to ↵Camille Gillot-131/+1
rustc_data_structures.
2025-08-14coverage: Remove intermediate data structures from mapping creationZalathar-77/+31
2025-08-08coverage: Remove obsolete comment about hashing HIRZalathar-2/+5
This code does not hash HIR manually (and has not done so for some time); it merely obtains a hash returned as part of `hir_owner_nodes`.
2025-08-08coverage: Extract HIR-related helper code out of the main moduleZalathar-136/+139
2025-08-06coverage: Remove all unstable support for MC/DC instrumentationZalathar-365/+5
2025-08-04coverage: Push async special case down into `extract_refined_covspans`Zalathar-14/+16
2025-08-04coverage: Remove `-Zcoverage-options=no-mir-spans`Zalathar-5/+1
This flag turned out to be less useful than anticipated, and interferes with work towards expansion support.
2025-07-31remove rustc_attr_data_structuresJana Dönszelmann-1/+2
2025-07-30coverage: Re-land "Enlarge empty spans during MIR instrumentation"Zalathar-2/+36
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-07-29coverage: Treat `#[automatically_derived]` as `#[coverage(off)]`Zalathar-10/+9
2025-07-29coverage: Rename `CoverageStatus` to `CoverageAttrKind`Zalathar-13/+16
This patch also prepares the affected code in `coverage_attr_on` for some subsequent changes.
2025-07-28Rename impl_of_method -> impl_of_assocCameron Steffen-1/+1
2025-07-26Revert "coverage: Enlarge empty spans during MIR instrumentation, not codegen"Zalathar-36/+2
This reverts commit f877aa7d14916f71a2f88c6d4c009e7ded7684c4.
2025-07-22coverage: Enlarge empty spans during MIR instrumentation, not codegenZalathar-2/+36
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-07-16Port `#[coverage]` to the new attribute systemSasha Pourcelot-19/+13
2025-06-29mir: Use the `new` method for `BasicBlockData`dianqk-5/+4
2025-06-29mir: Add a `new` method to `statement`dianqk-1/+1
Avoid introducing a large number of changes when adding optional initialization fields.
2025-05-27coverage: Revert "unused local file IDs" due to empty function namesZalathar-36/+2
This reverts commit 3b22c21dd8c30f499051fe7a758ca0e5d81eb638, reversing changes made to 5f292eea6d63abbd26f1e6e00a0b8cf21d828d7d.
2025-05-10coverage: Enlarge empty spans during MIR instrumentation, not codegenZalathar-2/+36
This allows us to assume that coverage spans will only be discarded during codegen in very unusual situations.
2025-05-06coverage: Handle hole spans without dividing spans into bucketsZalathar-59/+33
Because we no longer merge non-adjacent spans, there is no need to use buckets to prevent merging across hole spans.
2025-05-06coverage: Only merge adjacent coverage spansZalathar-34/+26
This also removes some manipulation of the function signature span that only made sense in the context of merging non-adjacent spans.
2025-04-26Auto merge of #140288 - Zalathar:new-executor, r=jieyouxubors-1/+1
compiletest: Re-land using the new non-libtest executor by default This PR re-lands #139998, which had the misfortune of triggering download-rustc in its CI jobs, so we didn't get proper test metrics for comparison with the old implementation. So that was PR was reverted in #140233, with the intention of re-landing it alongside a dummy compiler change to inhibit download-rustc. --- Original PR description for #139998: >The new executor was implemented in #139660, but required a manual opt-in. This PR activates the new executor by default, but leaves the old libtest-based executor in place (temporarily) to make reverting easier if something unexpectedly goes horribly wrong. > >Currently the new executor can be explicitly disabled by passing the `-N` flag to compiletest (e.g. `./x test ui -- -N`), but eventually that flag will be removed, alongside the removal of the libtest dependency. The flag is mostly there to make manual comparative testing easier if something does go wrong. > >As before, there *should* be no user-visible difference between the old executor and the new executor. --- r? jieyouxu
2025-04-25Trivial compiler change to inhibit download-rustc in CIZalathar-1/+1
2025-04-24Trivial compiler change to inhibit download-rustc in CIZalathar-2/+1
2025-04-01coverage: Don't split bang-macro spans, just truncate themZalathar-32/+15
2025-04-01coverage: Instead of splitting, just discard any span that overlaps a holeZalathar-46/+16
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: Defer the filtering of hole spansZalathar-15/+15
2025-03-21coverage: Separate span-extraction from unexpansionZalathar-75/+66
2025-03-18coverage: Don't store a body span in `FunctionCoverageInfo`Zalathar-1/+0
2025-02-24Auto merge of #135726 - jdonszelmann:attr-parsing, r=oli-obkbors-1/+1
New attribute parsing infrastructure Another step in the plan outlined in https://github.com/rust-lang/rust/issues/131229 introduces infrastructure for structured parsers for attributes, as well as converting a couple of complex attributes to have such structured parsers. This PR may prove too large to review. I left some of my own comments to guide it a little. Some general notes: - The first commit is basically standalone. It just preps some mostly unrelated sources for the rest of the PR to work. It might not have enormous merit on its own, but not negative merit either. Could be merged alone, but also doesn't make the review a whole lot easier. (but it's only +274 -209) - The second commit is the one that introduces new infrastructure. It's the important one to review. - The 3rd commit uses the new infrastructure showing how some of the more complex attributes can be parsed using it. Theoretically can be split up, though the parsers in this commit are the ones that really test the new infrastructure and show that it all works. - The 4th commit fixes up rustdoc and clippy. In the previous 2 they didn't compile yet while the compiler does. Separated them out to separate concerns and make the rest more palatable. - The 5th commit blesses some test outputs. Sometimes that's just because a diagnostic happens slightly earlier than before, which I'd say is acceptable. Sometimes a diagnostic is now only emitted once where it would've been twice before (yay! fixed some bugs). One test I actually moved from crashes to fixed, because it simply doesn't crash anymore. That's why this PR Closes #132391. I think most choices I made here are generally reasonable, but let me know if you disagree anywhere. - The 6th commit adds a derive to pretty print attributes - The 7th removes smir apis for attributes, for the time being. The api will at some point be replaced by one based on `rustc_ast_data_structures::AttributeKind` In general, a lot of the additions here are comments. I've found it very important to document new things in the 2nd commit well so other people can start using it. Closes #132391 Closes #136717
2025-02-24Change span field accesses to method callsJana Dönszelmann-1/+1
2025-02-24Rollup merge of #136610 - Jarcho:range_idx, r=NoratriebJacob Pratt-2/+2
Allow `IndexSlice` to be indexed by ranges. This comes with some annoyances as the index type can no longer inferred from indexing expressions. The biggest offender for this is `IndexVec::from_fn_n(|idx| ..., n)` where the index type won't be inferred from the call site or any index expressions inside the closure. My main use case for this is mapping a `Place` to `Range<Idx>` for value tracking where the range represents all the values the place contains.
2025-02-22Greatly simplify lifetime captures in edition 2024Michael Goulet-6/+3
2025-02-21Allow SliceIndex to be indexed by ranges.Jason Newcomb-2/+2
2025-02-19coverage: Make `HolesVisitor::visit_hole_span` a regular methodZalathar-18/+18
2025-02-19coverage: Get hole spans from nested items without fully visiting themZalathar-8/+9
It turns out that this visitor doesn't actually need `nested_filter::All` to handle nested items; it just needs to override `visit_nested_item` and look up the item's span.
2025-02-17Overhaul the `intravisit::Map` trait.Nicholas Nethercote-5/+4
First of all, note that `Map` has three different relevant meanings. - The `intravisit::Map` trait. - The `map::Map` struct. - The `NestedFilter::Map` associated type. The `intravisit::Map` trait is impl'd twice. - For `!`, where the methods are all unreachable. - For `map::Map`, which gets HIR stuff from the `TyCtxt`. As part of getting rid of `map::Map`, this commit changes `impl intravisit::Map for map::Map` to `impl intravisit::Map for TyCtxt`. It's fairly straightforward except various things are renamed, because the existing names would no longer have made sense. - `trait intravisit::Map` becomes `trait intravisit::HirTyCtxt`, so named because it gets some HIR stuff from a `TyCtxt`. - `NestedFilter::Map` assoc type becomes `NestedFilter::MaybeTyCtxt`, because it's always `!` or `TyCtxt`. - `Visitor::nested_visit_map` becomes `Visitor::maybe_tcx`. I deliberately made the new trait and associated type names different to avoid the old `type Map: Map` situation, which I found confusing. We now have `type MaybeTyCtxt: HirTyCtxt`.
2025-02-17Move some `Map` methods onto `TyCtxt`.Nicholas Nethercote-1/+1
The end goal is to eliminate `Map` altogether. I added a `hir_` prefix to all of them, that seemed simplest. The exceptions are `module_items` which became `hir_module_free_items` because there was already a `hir_module_items`, and `items` which became `hir_free_items` for consistency with `hir_module_free_items`.
2025-02-13coverage: Eliminate more counters by giving them to unreachable nodesZalathar-11/+16
When preparing a function's coverage counters and metadata during codegen, any part of the original coverage graph that was removed by MIR optimizations can be treated as having an execution count of zero. Somewhat counter-intuitively, if we give those unreachable nodes a _higher_ priority for receiving physical counters (instead of counter expressions), that ends up reducing the total number of physical counters needed. This works because if a node is unreachable, we don't actually create a physical counter for it. Instead that node gets a fixed zero counter, and any other node that would have relied on that physical counter in its counter expression can just ignore that term completely.
2025-02-10Rollup merge of #136053 - Zalathar:defer-counters, r=saethlinJubilee-365/+116
coverage: Defer part of counter-creation until codegen Follow-up to #135481 and #135873. One of the pleasant properties of the new counter-assignment algorithm is that we can stop partway through the process, store the intermediate state in MIR, and then resume the rest of the algorithm during codegen. This lets it take into account which parts of the control-flow graph were eliminated by MIR opts, resulting in fewer physical counters and simpler counter expressions. Those improvements end up completely obsoleting much larger chunks of code that were previously responsible for cleaning up the coverage metadata after MIR opts, while also doing a more thorough cleanup job. (That change also unlocks some further simplifications that I've kept out of this PR to limit its scope.)
2025-02-08Rustfmtbjorn3-28/+27
2025-02-06coverage: Remove the old code for simplifying counters after MIR optsZalathar-133/+6
2025-02-06coverage: Don't create counters for code that was removed by MIR optsZalathar-13/+19
2025-02-06coverage: Defer part of counter-creation until codegenZalathar-214/+108
2025-02-06coverage: Store BCB node IDs in mappings, and resolve them in codegenZalathar-44/+22
Even though the coverage graph itself is no longer available during codegen, its nodes can still be used as opaque IDs.
2025-02-03Remove hook calling via `TyCtxtAt`.Nicholas Nethercote-3/+1
All hooks receive a `TyCtxtAt` argument. Currently hooks can be called through `TyCtxtAt` or `TyCtxt`. In the latter case, a `TyCtxtAt` is constructed with a dummy span and passed to the hook. However, in practice hooks are never called through `TyCtxtAt`, and always receive a dummy span. (I confirmed this via code inspection, and double-checked it by temporarily making the `TyCtxtAt` code path panic and running all the tests.) This commit removes all the `TyCtxtAt` machinery for hooks. All hooks now receive `TyCtxt` instead of `TyCtxtAt`. There are two existing hooks that use `TyCtxtAt::span`: `const_caller_location_provider` and `try_destructure_mir_constant_for_user_output`. For both hooks the span is always a dummy span, probably unintentionally. This dummy span use is now explicit. If a non-dummy span is needed for these two hooks it would be easy to add it as an extra argument because hooks are less constrained than queries.
2025-01-26Incorporate `iter_nodes` into `graph::DirectedGraph`Zalathar-21/+0
This assumes that the set of valid node IDs is exactly `0..num_nodes`. In practice, we have a lot of graph-algorithm code that already assumes that nodes are densely numbered, by using `num_nodes` to allocate per-node indexed data structures.