prost
prost copied to clipboard
support boxing large/all `oneof` fields
https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
currently, we can box a variant manually. It would be good to automatically box based on size, or just all variants
I assume this is about oneof fields.
The prost-derive macros don't have access to the size of a Rust type. So I think it is not possible to automatically box based on size.
Boxing all variants of a oneof field is interesting. Maybe that should happen when the name of the oneof is given to Config::boxed.
I don't mind working on this. We can guess the sizes of rust types based on some predefined size and alignment and #[cfg] for pointer sizes. A large enough threshold is enough to not be problematic as boxing a nested message will reduce the size of the field to just the pointer size, freeing up a lot of space to go under the threshold for the current message.