Bounds on associated types prevent a trait from being dyn-compatible #65078
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-dyn-trait
Area: trait objects, vtable layout
A-trait-system
Area: Trait system
C-bug
Category: This is a bug.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
T-lang
Relevant to the language team
Uh oh!
There was an error while loading. Please reload this page.
playground
Doesn't compile with the error,
But this doesn't make sense, because
Self
(being the type erased thing indyn Foo
) is never referenced in any bound.Self::Bar
is referenced, but this should be fine in a dyn-compatible1 trait because all associated types have to be specified to use the dyn-compatible trait (i.e. I can't dodyn Foo
in this case). This can be seen inIterator
which is dyn-compatible.I think this should work and allow these sorts of bounds.
Note that moving the bound to a function is perfectly fine as seen here, but not on associated types or the trait itself.
I think this may be related to #27675
Footnotes
Formerly known as "object safe". ↩
The text was updated successfully, but these errors were encountered: