Skip to content
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

Propagate oneofs_nonexhaustive value to descendant contexts #748

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

akonradi-signal
Copy link
Contributor

Copy the value of Customize::oneofs_non_exhaustive to the context for fields so that it actually works as expected. Change the code to make it harder to introduce this sort of bug in the future.

Fixes #747

This ensures that if a new field is added in the future, this code will
be updated to handle it (one way or another), because not doing so will
lead to a compilation error. This will prevent issues like what happened
with oneof_nonexhaustive, where the field was added but its value was
not propagated.
When constructing Customize instances for fields and inner messages,
propagate the oneofs_non_exhaustive value.
@akonradi-signal
Copy link
Contributor Author

It's worth noting that #726 added a test that didn't actually catch this bug; the test is in theory supposed to fail to compile if the #[non_exhaustive] attribute is present but the author (me) forgot that the attribute only affects usages outside the crate, and the test includes the generated protobuf code as a module, not an external crate. I'd be happy to add a more robust test here, though I'd appreciate some guidance on how to lay that out in the test-crates directory since it requires code that spans at least two crates.

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.

Setting Customize::oneofs_non_exhaustive to false doesn't work
1 participant