[ 
https://issues.apache.org/jira/browse/THRIFT-6064?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Jens Geyer resolved THRIFT-6064.
--------------------------------
    Fix Version/s: 0.24.0
       Resolution: Fixed

> 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
>            Priority: Major
>             Fix For: 0.24.0
>
>          Time Spent: 20m
>  Remaining Estimate: 0h
>
> 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)

Reply via email to