Support for Unknown Fields (Rebase of #574) - #1340
Conversation
Does not compile, incomplete.
- Rename UnknownFieldSet to UnknownFieldList, as requested by maintainer
caspermeijn
- Change fixed32 and fixed64 representation to be consistent with C++
implementation, as requested by caspermeijn
- start resolving build-time errors
- Currently failing with reexported crate issues
- TODO: What endianness is protobuf?
This section should be added back (and/or modified to fit new standards), but commenting out for now to reduce points of failure to resolve creating bad Copy derives
Instead of checking against empty, which can fail differently. Attempting to force fields with unknown to not have a derived Copy.
While this is a change made by rustfmt/clippy, it's outside the scope of this PR, so it's been removed
Seems like local clippy check runs in rust edition 2021, CI runs in 2024
|
@caspermeijn Unfortunately, Github doesn't have a clear way to request reviews on a PR for someone outside the org and/or not a direct developer on the project, otherwise I would have done so. Apologies for the ping if that isn't the right channel. |
|
@blizzardfinnegan AFAIK you could remove or comment out the ignored tests here in order to verify the implementation: https://github.com/blizzardfinnegan/prost/blob/feature/unknown_fields_support/conformance/failing_tests.txt |
|
@alebar42 Thank you for the correction and clarification! Either way, the tests do in fact pass Edit: Unclear what was the issue, but said changes are now in the PR, which is the important part. |
|
@caspermeijn |
|
Ran into an issue using pbjson_build with this. Because when you generate unknown fields, pbjson_build doesn't know what to do with them and it errors: |
caspermeijn
left a comment
There was a problem hiding this comment.
Thank you for taking this forward. It is a large PR, so it takes some time for me to respond.
I miss user facing documentation. Could you add a section to the README that describes this new functionality?
|
Thank you for the review! I pretty much did as clean of a direct uplift as I could with the original MR, without changing too much. I'll go through and add docs and resolve the issues you pointed out. Apologies for the repeated pings. It's definitely a bear of a PR, I wasn't sure if you had seen it or not. |
- Remove Option wrapper on unknown fields - Actually utilise custom iterator instead of nested for loops - use Iterator.sum() instead of manual counter - use Buf.get_u64_le() and Buf.get_u32_le() instead of manual copies - Update conformance to not require failing_tests.txt - remove empty failing_tests.txt
|
Random thought. Protobuf naming guide recommends not using underscores as the initial character. Although it's not enforced, suggesting or using a default struct field name with a underscore prefix would be much more unlikely to have naming conflicts. |
This makes sense; Protobuf is language-agnostic, and some languages use underscores to denote private fields (python(?)), so useful to encourage people to not use it. Thank you for the information! I've updated accordingly. |
caspermeijn
left a comment
There was a problem hiding this comment.
I like the progress. I would like to see some small changes.
|
@caspermeijn Just checking in on the status of this MR; I know the past however long has been holidays, so projects and whatnot have probably taken a bit of a break, wanted to make sure it's still on the radar. |
Yes, I see your progress. Thank you for that. It is difficult for me to find the time to review this large PR, as it needs a long block of time to fully understand the context. Please hang in there! I did move one of your fixes of the bench to a seperate small PR ;-) #1404 |
|
Entirely understandable! Big, fundamental PRs like this take a ton of energy. Thank you for catching that unrelated-to-this-PR change, I can make changes to pull that out of this specific PR in the next week or so; I think Apologies for the repeated pings; this PR is the biggest hold-up for a decently-sized RIIR effort at work, and other devs at work are eager to play with it instead of using the google rust wrapper crate thingy. Please don't take that as a request for urgency though, I want to make sure it's done right (even if it is a first pass that needs more refinement and/or additional features added later). |
Moved to tokio-rs#1404 by maintainer
Make clear the name of the unknown fields field in the generated code _must_ be chosen. Resolve poor wording in prost-build docs.
Underscore at end of name is more idiomatic for Rust; approved by original suggestor of prepended underscore as acceptable alternative
- Fix failing test due to incomplete conversion - revert change to prost-derive/src/field/unknown.rs that resulted in failing tests
|
CI failures seem to be largely due to Github internal issues; will force a rerun tomorrow, hoping they (Github/Microslop) get their issues resolved. |
|
@caspermeijn |
For more information see Issue #2
This PR is largely similar to #574 , rebased to main, and with edits suggested by the maintainer on said PR implemented to the best of my ability.