Rust compiler generates invalid code when using typedef with union
Client: rs
Patch: guanjialin <1406147701@qq.com>
This closes #2228
diff --git a/compiler/cpp/src/thrift/generate/t_rs_generator.cc b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
index 4384dfe..506e090 100644
--- a/compiler/cpp/src/thrift/generate/t_rs_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
@@ -1454,6 +1454,10 @@
t_field* member = (*members_iter);
t_field::e_req member_req = t_field::T_REQUIRED;
t_type* ttype = member->get_type();
+ if (ttype->is_typedef()) {
+ // get the actual type of typedef
+ ttype = ((t_typedef*)ttype)->get_type();
+ }
string match_var((ttype->is_base_type() && !ttype->is_string()) ? "f" : "ref f");
f_gen_
<< indent()