Note that it's not a serious suggestion, but I wonder what effect it would have on build times.
Note that it's not a serious suggestion, but I wonder what effect it would have on build times.
As always this could be avoided with some extra complexity, but that require lot of work and testing that hasn't been done.
So for now this is useful only in crates that have a lot of unused functions, so even if one function is codegenned multiple times you still save time overall.
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.
That would mean generics in shared libraries are possible without hacks but you can always choose to statically link and monomorphize for speed. Libraries could even ship both the vtable based catch all code and specializations for common types as a fast path (but that would probably need a custom dynamic linker).