-
Notifications
You must be signed in to change notification settings - Fork 506
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
proto3
doesn't pack repeated fields by default
#976
Comments
Just realised this is only the case where the field has other attributes and hence |
I don't understand what your request is. Can you describe your observed behavior and your expected behavior? An example file or project will help with reproducing your problem. |
We're hitting the same bug. Consider a field like this: repeated uint64 user_ids = 2 [
(buf.validate.field).repeated.min_items = 1,
(buf.validate.field).repeated.max_items = 25
]; This generates the following from prost: #[prost(uint64, repeated, packed="false", tag="2")]
pub user_ids: ::prost::alloc::vec::Vec<u64>, However if I remove the options, like this: repeated uint64 user_ids = 2; Then the generated code looks like this: #[prost(uint64, repeated, tag="2")]
pub user_ids: ::prost::alloc::vec::Vec<u64>, As @daniel-sherwood correctly identified, this is a bug at prost/prost-build/src/code_generator.rs Lines 431 to 438 in 63c0024
In my first example, there are options on the field so |
Thanks, now I understand your problem better. Are you willing to open a PR to fix this? |
Maybe! It'd be my first time trying Rust, so it'd probably take a while. |
The code here
prost/prost-build/src/code_generator.rs
Line 435 in 63c0024
proto3
to be packed, however becauseoptions.packed()
returnsfalse
unless[packed = true]
is set on the field, this fails.The text was updated successfully, but these errors were encountered: