Repository navigation
Conversation
|
All contributors have signed the CLA ✍️ ✅ |
With lazy_views(true) and repeated_type_custom, the lazy to_owned_message built a repeated message field in a Vec and returned it where the owned struct holds the custom collection, so the generated crate failed with E0308. Pass the Vec through the collection's From<Vec<T>>, which ProtoList already requires. The default Vec path emits the same code as before, so it does not trip clippy::useless_conversion. The repeated_type fixture in buffa-test now also builds lazy views, with a decode_lazy to to_owned_message round trip, and a codegen test pins that only the custom collection gets the conversion.
v0ropaev
force-pushed
the
fix/lazy-view-custom-repeated
branch
from
October 28, 2026 10:16
57d3dfd to
66b25e6
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
With
lazy_views(true)andrepeated_type_custom, a crate with a repeated message field does not compile. The lazyto_owned_messagecollects the decoded elements into aVecand returns it as the field value, but the owned struct holds the custom collection.I hit it with a small crate that compiles one proto with
repeated_type_custom("crate::CustomList<*>")and turns codegen options on one at a time. With onlylazy_views(true)added it fails as above. The eager view path already collects into the custom type, so only the lazy path was missing it.The fix sends the
Vecthrough the collection'sFrom<Vec<T>>, whichProtoListalready requires. For the defaultVecthe generated code stays exactly as it was, so it doesn't tripclippy::useless_conversionin user crates, and no checked-in generated code changes.The existing
repeated_typefixture in buffa-test now also builds lazy views, andlazy_view_to_owned_round_tripdoes adecode_lazythento_owned_messageround trip on the sample message. A codegen test,lazy_to_owned_converts_vec_only_for_custom_collection, checks that the conversion is emitted for a custom collection and not forVec. On main the fixture fails with the E0308 above and the codegen test fails its assertion.fmt and clippy with
-D warningsare clean on buffa-codegen and buffa-test (and on buffa-test with--features arbitrary), and both test suites pass on 1.95.0.While testing this I also noticed
repeated_type_custombreaks text generation. That one is #802.