-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
dyn Upcasting for unsized generics #119360
Comments
MotivationEnable |
The correct bound is |
Thanks |
This fails:
with:
Dyn upcasting adds support for upcasting trait objects
dyn A
whereA: Any
todyn Any
, but not just any type (e.g.str
cannot be cast todyn Any
).For whatever reason, the bound
T: Any + ?Sized
is not enough to support the cast:[i32]
implementsAny
(strange) yet cannot be cast todyn Any
(if it could this would break memory safety since the impl ofAny
returns a singleTypeId
for all[i32]
regardless of length).The additional
T: CoerceUnsized<dyn Any>
looks like it should be enough to satisfy the coercion in the method, yet it is not. It should be?I guess this should be categorised as a bug in #18598, but it could be a bug in #65991 or even a feature request.
The text was updated successfully, but these errors were encountered: