-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fix receiver lifetimes in AttributeTypeAndValue
.
#141
Conversation
Note that this PR depends on rusticata/asn1-rs#22, so we expect tests to fail until that PR is merged and dependencies are updated as needed. |
Checking on this. Can we get this merged? We still need a release of |
Checking in again. |
@@ -115,7 +115,7 @@ impl<'a> AttributeTypeAndValue<'a> { | |||
|
|||
/// Get the content as a slice. | |||
#[inline] | |||
pub fn as_slice(&'a self) -> &'a [u8] { | |||
pub fn as_slice(&self) -> &'a [u8] { |
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.
This does not look correct. By forcing only the return to satisfy 'a
, the compiler assigns an unnamed lifetime to self
, and they do not match. Removing the return lifetime fixes that.
I'll add some commits.
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.
This is not the way lifetimes work, and your reversal of this change partially obviates the intended consequences of this PR. Please see my comment in rusticata/asn1-rs#22 (comment) where I address your misconceptions about lifetimes.
By forcing only the return to satisfy 'a, the compiler assigns an unnamed lifetime to self, and they do not match.
You seem think that "they do not match" is a problematic statement, but in fact, that's quite literally the point here: we want the receiver's lifetime (&self
) to differ from the returned lifetime (&[u8]
). Otherwise, we ask for unification, which means that the receiver must live as long as the return value and vice-versa, even when no such relationship is needed.
Your commit has obviated the meaningful change here and resulted in a strictly worse situation wherein the content of the struct is typed to a particular reference (the receiver, created exactly when the method is called - it doesn't exist otherwise) to the struct. This only makes sense when the struct owns the data, which is not the case here.
Please revert 853d7ee and any other such changes and publish a new breaking release. |
This builds off rusticata/asn1-rs#22.