Open compiler-errors opened 4 days ago
The reason this fails is because we store object types as fully elaborated lists of projections, but deduplicate them after substitution when they come identical.
Think of dyn Dyn<(), ()>
as [Sup<(), Assoc = ()>, Sup<(), Assoc = ()>]
which gets deduplicated as [Sup<(), Assoc = ()>]
and dyn Dyn<A, B>
which in coherence gets replaced with inference vars to [Sup<?A, Assoc = ?A>, Sup<?B, Assoc = ?B>]
.
We then check that these lists are the same length, and if they're not, we return a "type mismatch". In effect, we consider the types to be not equal, which also means that we consider two impls to not overlap.
I'm actually somewhat afraid that a general solution to matching up the projections in various states of substitution and deduplication is impossible to solve; however, I think I have in mind a set of restrictions that we may be able to impose that is both not too restrictive but prevents this issue in general.
I'll noodle a bit on this... @rustbot claim
I tried this code:
I expected to see this happen: It does not work.
Instead, this happened: Segfault
Meta
rustc --version --verbose
: