You work on a feature in a branch A. You build, some files get auto-generated, everything is great, tests pass, you commit. You switch to branch B to work on another feature. But that branch is a bit older and did not yet have one file that was auto-generated, so the building system doesn’t know about it, and it leaves it out. You try to build and you get a compile error. If you’re using a mono-repo with many languages, you get it somewhere that might not even be an area of your expertise in a language that you don’t know about.
Sure, a proper building system hygiene would prevent that, but in practice, it’s “oh it’s just how things are with language-X”. Reworking company building system is practically impossible, so people learn to live with that and be constantly annoyed by the language that they don’t even use. On top if it: C and C++ , with their archaic building system don’t have that issue.
This issue is very nasty, because it hits unaware suspects, in random (to them) places, as opposed to the opposite problem: when someone forgets to reference a file that should have been used. At least then one fixes their own mistake.
That is a very concrete concern. I can only respond with two possible fixes:
#![cfg(test)] at the top
tests.rs itself, or having
#[test] work on
#[test] use test;
Personally, I find the whole
#[cfg(test)] use tests; a weird boilerplate in itself, that could use some attention in the current usability push. Especially in combination with
benches, which I typically implement as a feature flag, so everything gets even weirder.
But other than tests, is there really many places where someone puts a code in the source file and does not reference it at all by any
use statement from rest of the code?
It seems to me we get annoyed by the same thing, just with different previous experiences.