Dead code warnings depending on cargo features
Empirically, runing cargo check -p SOME-CRATE --all-features
very often produces dead code warnings. This is because the target crate doesn't enable all the features of its dependencies; rather, the dependencies are compiled with some arbitrary combination of feature flags.
But, usually, not everything in our codebase is properly decorated with precisely the correct combination of #[cfg]
. Hence the dead code errors.
This is a persistent problem. Whenever I am doing some development, find myself with random #[allow]
commits at the base of my branch. The precise set of #[allow]
s varies over time, as other people discover and try to fix these things.
Conversely, people doing work on some feature can merge their work without noticing that they are introducing these problems, because it's not detected in CI. The result is "bad weather" in tree, which is very distracting.
Precisely #[cfg]
-decorating everything is significant effort. IMO it is usually makework. However, if we do think it ought to be done, it ought to be actually tested in CI so that it doesn't regress.
This is closely related to #1060, but much of that ticket is about imports, which admit of some different solutions.