-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Enforce object-safety when coercing to an object #255
Conversation
Restrict which objects can be coerced to trait objects, rather than which methods can be called on a trait object.
It would be nice to allow |
@sfackler do you have an example? I had not considered having different rules for different kinds of trait objects, I fear that would be too much complexity unless there is a really important use case. |
There's some discussion at rust-lang/rust#10672. Most notably, @pcwalton points out that it's required to allow |
It'd also seem to me that you couldn't allow |
@sfackler thanks for the link! I need to check, but I think that the Box case is OK - Why do you think |
… rather than restricting value to reference types.
I remember @glaebhoerl arguing that the diffculties around DSTs are signs that we indeed need full-on existential types. I am not sure if this particular problem applies, but here is his (somewhat random) thought about existential types. And I'll leave it here just in case this is relevant. :) |
Oops, I misinterpreted the proposal wrt |
In general, the rules around |
Perhaps a more accurate rule would be to say "modified rules around |
This also intersects the proposed |
@CloudiDust That's a pretty interesting set of notes. I hadn't thought much about existential types as they apply to Rust, but it seems like it could be a really fantastic fit. |
The introduction of object-safety for coercion to trait objects (see rust-lang/rfcs#255) affects the previous implementation of BoxIter. It turns out trait objects are not actually necessary to deal with this situation, so the implementation was changed to be generic over the type of iterator instead of the type iterated over.
Make join_all() concurrent.
Restrict which objects can be coerced to trait objects, rather than which methods can be called on a trait object.