-
Notifications
You must be signed in to change notification settings - Fork 137
mesh_protobuf: Only deduplicate descriptors by package and name #1821
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for making this change! Do we validate somewhere that the saved state is stable in light of this change? (Does this change touch any of the machinery that we use to generate save state)? |
I'm not sure if this is involved in save state, but it will be covered by our existing servicing tests. |
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.
seems reasonable to me, but should also get review from john
@@ -44,8 +44,6 @@ impl<'a> DescriptorWriter<'a> { | |||
|
|||
// Sort the descriptors to get a consistent order from run to run and build to build. | |||
descriptors.sort_by_key(|desc| (desc.package, desc.message.name)); | |||
// Deduplicate by package and name. TODO: ensure duplicates match. | |||
descriptors.dedup_by_key(|desc| (desc.package, desc.message.name)); |
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.
Why?
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.
We're already doing it now in the earlier step, this one wouldn't add anything. referenced_descriptors won't return any duplicates anymore.
As a new warning in Rust 1.89 points out, comparisons of function pointers are unreliable (https://doc.rust-lang.org/nightly/core/ptr/fn.fn_addr_eq.html). The derive of PartialEq on a type containing a function pointer will produce such a comparison, triggering this warning. Instead of deriving the trait and inserting MessageDescriptors into a HashMap, just use their package and name as a deduplication key, under the assumption that nobody would declare two different types with the same package and name.