-
Notifications
You must be signed in to change notification settings - Fork 227
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
Avoid leaking internal pointers with 'static lifetimes #18
Conversation
This change might give the E.g., after applying this PR, the following still typechecks, even though the
To get the safety we want, I think we really need to be able to constrain the lifetime of the output by the lifetime of the input, like this:
Maddeningly, there were a few months over the summer where I could actually use this signature and it appeared to do what I wanted. But as of about a month ago, it looks like we again need to wait for a fix to rust-lang/rust#13853. :( As far as I understand, this PR would also make it impossible to seal a P.S. I do appreciate the attention you're giving this project! If nothing else, you're reinforcing the notion that I need to work on documentation. |
I'm betting the reason why we're not getting our safety is because of some transmutes must be somehow creating values with a lifetime without tying them to an actual object. Unfortunately I have to do real work so I can't look into it at the moment. yeah, there won't really be any way to make a MessageReader sendable. But to be fair, that wouldn't be safe to share references across threads. And finally, happy to help! capn proto is quite nifty :) |
No, the problem was just that you forgot some explicit lifetime parameters. I'll merge this and go ahead and add them. Thanks! |
Avoid leaking internal pointers with 'static lifetimes
I had lifetimes originally, but I removed them because theoretically lifetime inference should have inserted them. Maybe that's where a transmute broke the link between lifetimes? |
In my understanding, your signature
is equivalent to
In particular, there is no constraint between Admittedly, though, my understanding here may be incomplete, and I've been uneasy about implicit lifetimes ever since lifetime elision was introduced. |
Add documentation link to README
the
get_root
methods were tripping over the bug rust-lang/rust#13853, which is unable to handle a method likefn foo<'a, T: Bar<'a>>(...)
. This PR avoids that bug by moving the lifetime onto the trait.