Comment by dminik
6 hours ago
A really dumb 1 AM question. If there is a lot of work thrown away because stuff is compiled even if not needed, would making every function generic and delaying compilation until instantiation help here?
Note that it's not a serious suggestion, but I wonder what effect it would have on build times.
Yes, and there is some compiler flag to do this, even though it's not 100% intended for this use (I think it's something like mir-inline-trheshold=0).
There's also -Zhint-mostly-unused flag.
The tradeoff is that these functions then have to be encoded in metadata for downstream crates, so it's not necessarily faster.
I mean, the core thing is like, you have to have a compiler codebase (and language semantics) that's designed around being able to delay in the first place to be able to even try this, and once you've gotten that in place, well, it's not really about this specific idea anymore.