-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
Explain default trait object liftime bounds. #31353
Conversation
I'm not sure if this gets at the essence of the rule. For example, it doesn't example what happens with
|
Though I think there may be some subtleties about |
@nikomatsakis updated, what do you think of this attempt? |
@steveklabnik seems better. Something still gives me pause. I feel like the way the importance of the cases is the reverse of they are listed. That is, another way to think of it is "trait objects cannot contain borrowed data unless one of these cases is met":
It's just a matter of emphasis though. Thoughts? |
Ah, I like that. |
@@ -3603,6 +3603,41 @@ fn main() { | |||
In this example, the trait `Printable` occurs as a trait object in both the | |||
type signature of `print`, and the cast expression in `main`. | |||
|
|||
Trait objects may contain references, and so those references will need a | |||
lifetime. If the trait contains some sort of lifetime bound, like this: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
feels weird to me that this sentence just... ends (and doesn't resume after the code snippet)
@nikomatsakis after a very long time, nits addressed, i think. |
Why was this closed without merging? #31137 is still open as well. |
I believe I was cleaning up my branches and may have accidentally deleted it. It was also sitting in the queue for a very, very long time... |
@steveklabnik Would it be okay if I took your changes from this PR and submitted them as a new PR? |
Fixes #31137
I feel a little weird about how short this is. It's really hard to not just say the exact rule, about
T: 'a
. It feels so arbitrary here, though.r? @aturon @nikomatsakis