Trait with associated type bounds cannot be made into an object because it uses Self
as a type parameter
#80256
Labels
A-associated-items
Area: Associated items (types, constants & functions)
A-dyn-compatibility
Area: Dyn compatibility (formerly: object safety)
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-types
Relevant to the types team, which will review and decide on the PR/issue.
A simplified example where this shows up is the following trait.
(Full code)
If you try to make a trait object, say
&dyn Conversion<Source = String, Target = Box<str>>
, then Rust errors:If the bound was something like
Source: Into<Self>
this error would make sense, but instead the bound references another associated type, which all must be fully specified when making a trait object type anyway.This problem does not seem to occur when associated types are used to define functions in the trait, as creating a
&dyn Deref<Target = ...>
trait object works.The text was updated successfully, but these errors were encountered: