Jens Geyer created THRIFT-6064:
----------------------------------
Summary: Rust generator does not box recursive union variant on
read
Key: THRIFT-6064
URL: https://issues.apache.org/jira/browse/THRIFT-6064
Project: Thrift
Issue Type: Bug
Components: Rust - Compiler
Reporter: Jens Geyer
The Rust code generator emits a recursive (forward-referenced) union variant as
Box<T>, but the generated read code constructs the variant from the *unboxed*
value when the variant's type is itself a union:
{code}
ret = Some(CoUnion::Other(val)); // val is CoUnion2, but the variant is
Box<CoUnion2>
{code}
This does not type-check (error[E0308]: mismatched types, expected Box<...>,
found ...). render_union_sync_read does not apply the Box::new(...) wrapping
that render_struct_sync_read already performs for forward-typedef fields.
Reproduced via test/Recursive.thrift once it gained a recursive union
(CoUnion/CoUnion2): the lib-rust kitchen-sink crate fails to compile.
Fix: in render_union_sync_read, detect the forward typedef and wrap the read
value in Box::new(...), mirroring render_struct_sync_read.
--
This message was sent by Atlassian Jira
(v8.20.10#820010)