Closed mhfan closed 1 month ago
@rustbot label +A-code-coverage +requires-nightly
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.
I've filed #126625 to be the canonical version of this issue.
@rustbot close
Oops, I thought I could close this.
I think we are good to close this now that #126625 has been closed
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
https://github.com/taiki-e/cargo-llvm-cov/issues/291