I\'ve tried to use kcov to get code coverage for a Rust library. I\'ve followed this tutorial to build and use kcov. The coverage seems to work, however I\'m facing a strang
There is a workaround: the RUSTFLAGS='-C link-dead-code'
environment variable. Use it while building and the Rust compiler will link dead code as well:
RUSTFLAGS='-C link-dead-code' cargo test
You're correct: totally unused functions are stripped at the moment, so coverage tools like kcov are only good for branch coverage within used functions (at least, the summary functionality of such tools). There is some discussion about making this not happen by default for test/debug builds.