I’m posting this because it has several features which are exciting not just from a language perspective but also from an engineering and practices perspective. TL;DR:
There’s other stuff, including lots of stabilized APIs, but this is really the core of what excites me here.
I’m probably dense, but I don’t get it. I read the Rust release notes, I google the clang feature. Code coverage of what? Test coverage?
It’s in the linked docs, but “coverage” here means “the code is executed.” It tells you where your dead code is, and can be summarized into four useful high-level statistics:
Specifically to the question: it’s quite easy to record coverage in a binary (i.e. which instructions were executed), you add some instrumentation on each branch to record what the target was and you can then generate a list of the basic blocks that were executed. You need some extra tooling to map these back to locations in the source code. This is what source-based code coverage mean. Often, it’s implemented by inserting the instrumentation in the front end (which has more relevant information for the coverage), though it’s also possible to use source locations in debug info to map from pure binary coverage info back to the source code. The latter approach is nice if you can make it work because it can be non-disruptive: if your CPU and OS support modern tracing functionality then they can generate basic-block-level traces for arbitrary binaries and you can then map this back to the source code for the exact version that was executed.
Thanks!
Stabilized Not for !.
Interesting that any trait with only methods and no functions can be implemented for the
never
type since they can’t be called: Primitive Type never.In other contexts, that is called the bottom type, because it sits at the bottom of the type lattice, and is therefore a subtype of every other type. So I find this fairly unsurprising.
Isn’t that the initial type? I thought the bottom type was () since we can always reach it
No. ‘bottom’ refers to subtyping relationships, not compositional relationships. It’s true you can make anything from (), |, and *. But () isn’t a subtype of ()|().
E: this is general nomenclature. It’s possible rust has its own vocabulary I don’t know about.