Skip to content

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

smalis-msft
Copy link
Contributor

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.

@smalis-msft smalis-msft requested a review from a team as a code owner August 7, 2025 17:24
@mattkur
Copy link
Contributor

mattkur commented Aug 8, 2025

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)?

@smalis-msft
Copy link
Contributor Author

I'm not sure if this is involved in save state, but it will be covered by our existing servicing tests.

Copy link
Member

@chris-oo chris-oo left a 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

@chris-oo chris-oo requested a review from jstarks August 18, 2025 21:42
@@ -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));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

@smalis-msft smalis-msft Aug 19, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants