-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Don’t insert coverage counters for unreachable!() code #80549
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
Comments
Perhaps what we want here is some attribute or something of that sort that prevents insertion of counters in a more general manner... |
I agree that unreachable!() shouldn't itself be special, but I do think if such an attribute were introduced it should be added to unreachable, as to me the same reasons for marking code as unreachable apply to whether or not you want to collect coverage on it. |
This would be very useful, a generic way to disable coverage for |
Coverage instrumentation already has “special handling” of I was playing around with having the coverage graph ignore MIR blocks that end with (I don't have a PR because my quick experiments clearly needed a lot more polish before they could ever be merged, but it does seem like a viable approach.) |
Just poking through some old coverage issues, but this feels like a good use case for the Effectively, it would be nice to be able to mark areas of code as "I don't expect this to be covered," where they would still have coverage instrumentation but wouldn't count toward overall coverage metrics. |
A while back I was thinking about implementing my own Rust-specific tool for parsing coverage data and presenting coverage reports, as an alternative to the LLVM-provided tool that we use now ( (I didn't make much progress because I ended up shifting my focus to instrumentation, but it's an idea I'd like to return to some day.) Supporting |
Very fair! I do wonder if it'd be possible to inject arbitrary metadata into the LLVM coverage data, though, so that at least any potential tool wouldn't have to manually generate everything on their own, and could still use the same instrumentation. That way, we could mark certain lines/points as being "ignored" in such a way that a tool like llvm-cov would ignore them, but other tools could make use of them. |
With the introduction of source based code coverage, I ran into this quirk:
This seems like it should be a fully covered function but an unreachable counter has been placed on the invocation of the unreachable!() macro.
Would it be possible to make calls to unreachable skip the insert of the counter?
The text was updated successfully, but these errors were encountered: