Trait objects, auto trait subtyping?

After all, all that subtyping does is provide a set of coercions (subtyping coercion)

Not really. Subtypings and coercions are very different from type inference perspective. Rust coercions happen at language-specified coercions sites. We don't say "subtyping coercion“ at all in Rust.

Basically coercions means that there're (at least) two difference type variables and coercion rule relationship be established between them, and subtyping means that the same type variable needs to be able to be "interpreted" as different types (with variance and maybe other aspects). So you can see it's very obvious that huge complexity resides within the later approach. Basically in Rust from my understanding subtypings are only used on lifetime-related things. (And from implementation perspective, the fact that lifetime subtyping inference system (a.k.a borrow checker) is separate is already source of many historic bugs (even unsoundness issues) within rustc.)

I'm not saying the issue in OP isn't worth solving. In fact i think it is, and i think it's best solved with carefully redesigned coercion rules. This might imply some tweaking around the existing CoerceUnsized-centered coercion rules.

3 Likes