2 ms·
This is trivially solved by putting code coverage and Miri into the same project, however.
by mmastrac 3y ago
This is trivially solved by putting code coverage and Miri into the same project, however.
- IshKebab 3y agoIt's trivial to measure code coverage. It's definitely not trivial to achieve 100% code coverage. This is the sort of "just do things perfectly" nonsense we get from C programmers. I'm surprised to see it from Rust devs, given the whole ethos of Rust is that it acknowledges that programmers are not perfect and helping them avoid bugs as much as possible is a good thing.
- remram 3y agoI agree in general, but if you have unsafe code you should definitely make sure it is covered.
- mmastrac 3y agoIt's not nonsense. It's really not difficult to structure code for 100% coverage of unsafe code if you're thinking about it from the start. You're also perfectly fine to write code that is free of `unsafe`, freeing you from this onerous task. We're pulling out Miri _because_ we're going outside the normal guardrails. You also don't _need_ to get 100% coverage of all your unsafe code if you can be confident of the usage of unsafe. The most complex unsafe code should almost certainly be covered, but there are a lot of trivial uses of unsafe that can be shown to be correct through reasoning. Where possible I prefer to split code into safe and unsafe portions, and test the unsafe portions under Miri with as much coverage as gives me confidence in the code. I've made UB mistakes before with unsafe, but since adding Miri and code coverage, the numbers of mistakes I've made has dropped dramatically. No programmer is perfect, but one would be pretty foolish to ignore the tools at one's disposal.