Auto-generate crate-agnostic anonoymous sub-traits for `dyn Foo + ...`

We'd need to make vtable generation deterministic between compilation runs when the function pointers are the same and come from exactly the same traits. This is not currently guaranteed, but it is not that difficult to build some sort of deterministic, perfect function pointer sorter that would have every vtable be the same when the function pointers it implements are the same. The Rust ABI isn't stable, but we can still get away with this; if we were to link code generated on different compiler versions or runs, it'd still produce UB if it linked in the first place. I'm not talking about ABI stability, this is deterministic code generation.

To illustrate what I'm saying:

A vtable of functions

  • clone()
  • drop()
  • foo()
  • bar()

that comes from the specific traits (no less, no more) Clone + Drop + Foo + Bar, will produce the same vtable across all crates, by having a deterministic, perfect function pointer sorter.

Is this viable, or am I being stupid?