taiki-e / cargo-llvm-cov

Cargo subcommand to easily use LLVM source-based code coverage (-C instrument-coverage).
Apache License 2.0
933 stars 57 forks source link

Missing lines on async functions with tracing::instrument macro #282

Closed dnaka91 closed 1 year ago

dnaka91 commented 1 year ago

I noticed that some of my functions are missing line information when they're processed with the tracing::instrument macro. When I look at the HTML report, the source code is there of course, but most of the lines are neither detected as covered nor uncovered.

As soon as I remove the macro, they're detected properly again. I understand macros are always tricky to handle, and I wonder whether this is something that's better reported on the tracing repo's issue tracker?

For now, I can work around it as follows:

#[cfg_attr(not(coverage), instrument(skip_all, level = "trace"))]
async fn something() {}
taiki-e commented 1 year ago

upstream bug report: https://github.com/rust-lang/rust/issues/110486

This sounds like a bug in the way the compiler handles macros, but action may be needed on the tracing or cargo-llvm-cov side to finally work around the problem. (Or maybe some llvm-cov flags already handles this, something like -show-expansions=false -- we currently set that flag to true)

dnaka91 commented 1 year ago

Thank you for the quick reply.

Tried playing with a few flags to rust-cov but none of them had an effect. But well, I'm not really sure what I'm doing there, as I don't know much about the llvm-cov tools.

I'll follow the bug report for any progress on this. Should I close this issue or leave it open?

taiki-e commented 1 year ago

I also confirmed that -show-expansions=false doesn't fix this.

Closing in favor of upstream bug report for now.