Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#[coverage(..)] attribute should apply recursively to nested functions/methods/closures #126625

Closed
Zalathar opened this issue Jun 18, 2024 · 1 comment · Fixed by #126721
Closed
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@Zalathar
Copy link
Contributor

As discussed at the main tracking issue, #84605 (comment), there is a desire for #[coverage(off)] (and #[coverage(on)]) to apply recursively to all functions/methods/closures inside the one being annotated.

The current behaviour is that the attribute only affects the function that it is directly attached to.

@rustbot label +A-code-coverage

@rustbot rustbot added needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) labels Jun 18, 2024
@jieyouxu jieyouxu added C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jun 18, 2024
@Zalathar
Copy link
Contributor Author

Previously filed as #93319.

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 26, 2024
coverage: Make `#[coverage(..)]` apply recursively to nested functions

This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to.

Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value.

---

Fixes rust-lang#126625.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Jun 26, 2024
coverage: Make `#[coverage(..)]` apply recursively to nested functions

This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to.

Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value.

---

Fixes rust-lang#126625.
@bors bors closed this as completed in 70b69a2 Jun 27, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Jun 27, 2024
Rollup merge of rust-lang#126721 - Zalathar:nested-cov-attr, r=oli-obk

coverage: Make `#[coverage(..)]` apply recursively to nested functions

This PR makes the (currently-unstable) `#[coverage(off)]` and `#[coverage(on)]` attributes apply recursively to all nested functions/closures, instead of just the function they are directly attached to.

Those attributes can now also be applied to modules and to impl/impl-trait blocks, where they have no direct effect, but will be inherited by all enclosed functions/closures/methods that don't override the inherited value.

---

Fixes rust-lang#126625.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) C-enhancement Category: An issue proposing an enhancement or a PR with one. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants