Associated types in object-safe method signatures don't always come from supertraits #126079
Labels
A-trait-objects
Area: trait objects, vtable layout
C-bug
Category: This is a bug.
I-unsound
Issue: A soundness hole (worst kind of bug), see: https://en.wikipedia.org/wiki/Soundness
P-high
High priority
T-types
Relevant to the types team, which will review and decide on the PR/issue.
One of the requirements for a trait to be object-safe is that the associated types that show up in signatures of methods come from the supertraits of the object. We don't currently implement this correctly -- we currently ignore the substitutions of the associated type 😿.
This is unsound:
Specifically,
fn transmute(&self, t: T) -> <Self as Super<NotActuallySuper>>::Assoc;
should only be sound if the return type was<Self as Super<ActuallySuper>>::Assoc
, or if we addedSuper<NotActuallySuper>
as a supertrait.We should probably deeply normalize these supertraits and actually consider the associated types' substs match modulo regions.
The text was updated successfully, but these errors were encountered: