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

#[no_coverage] didn't exclude internal functions and closures inside a function #113564

Closed
mhfan opened this issue Jul 11, 2023 · 6 comments
Closed
Labels
A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) requires-nightly This issue requires a nightly compiler in some way.

Comments

@mhfan
Copy link

mhfan commented Jul 11, 2023

Thus, require "#[cfg_attr(coverage_nightly, no_coverage)]" prepend before each internal functions/closures for coverage exclusion, e.g.:

https://github.com/mhfan/inrust/blob/d4bd798028b9d06709b1c65ef92993af805ba4a4/src/calc24.rs#L737C1-L762C6

taiki-e/cargo-llvm-cov#291

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 11, 2023
@taiki-e
Copy link
Member

taiki-e commented Jul 12, 2023

@rustbot label +A-code-coverage +requires-nightly

@rustbot rustbot added A-code-coverage Area: Source-based code coverage (-Cinstrument-coverage) requires-nightly This issue requires a nightly compiler in some way. labels Jul 12, 2023
@Zalathar
Copy link
Contributor

Yeah, the current implementation of #[no_coverage] is pretty crude, since it only applies to the item it's directly attached to.

From the instrumentation pass's point of view, every internal function/closure is treated as a completely separate function, and there's no logic to detect no-coverage attributes on enclosing items.

I imagine this would be relatively straightforward to fix, by scanning all enclosing functions for the attribute (instead of just checking the current function), though I'm currently not familiar enough with MIR APIs to do it myself.

@Noratrieb Noratrieb removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 13, 2023
@Zalathar
Copy link
Contributor

I've filed #126625 to be the canonical version of this issue.

@ranger-ross
Copy link
Contributor

@rustbot close

@rustbot
Copy link
Collaborator

rustbot commented Sep 9, 2024

Error: The feature close is not enabled in this repository.
To enable it add its section in the triagebot.toml in the root of the repository.

Please file an issue on GitHub at triagebot if there's a problem with this bot, or reach out on #t-infra on Zulip.

@ranger-ross
Copy link
Contributor

Oops, I thought I could close this.

I think we are good to close this now that #126625 has been closed

@Zalathar Zalathar closed this as completed Sep 9, 2024
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) requires-nightly This issue requires a nightly compiler in some way.
Projects
None yet
Development

No branches or pull requests

6 participants