[ 
https://issues.apache.org/jira/browse/THRIFT-4661?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16682038#comment-16682038
 ] 

ASF GitHub Bot commented on THRIFT-4661:
----------------------------------------

jeking3 closed pull request #1623: THRIFT-4661: Rust enum name wrong case in 
generated structs
URL: https://github.com/apache/thrift/pull/1623
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/compiler/cpp/src/thrift/generate/t_rs_generator.cc 
b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
index dc11fd3ee2..5cd67f6755 100644
--- a/compiler/cpp/src/thrift/generate/t_rs_generator.cc
+++ b/compiler/cpp/src/thrift/generate/t_rs_generator.cc
@@ -3022,7 +3022,7 @@ string t_rs_generator::to_rust_type(t_type* ttype, bool 
ordered_float) {
     rust_type =  ttypedef->is_forward_typedef() ? "Box<" + rust_type + ">" : 
rust_type;
     return rust_type;
   } else if (ttype->is_enum()) {
-    return rust_namespace(ttype) + ttype->get_name();
+    return rust_namespace(ttype) + rust_camel_case(ttype->get_name());
   } else if (ttype->is_struct() || ttype->is_xception()) {
     return rust_namespace(ttype) + rust_camel_case(ttype->get_name());
   } else if (ttype->is_map()) {
diff --git a/lib/rs/test/src/bin/kitchen_sink_server.rs 
b/lib/rs/test/src/bin/kitchen_sink_server.rs
index 15ceb29dc4..ae7026288c 100644
--- a/lib/rs/test/src/bin/kitchen_sink_server.rs
+++ b/lib/rs/test/src/bin/kitchen_sink_server.rs
@@ -22,7 +22,7 @@ extern crate kitchen_sink;
 extern crate thrift;
 
 use kitchen_sink::base_one::Noodle;
-use kitchen_sink::base_two::{Napkin, NapkinServiceSyncHandler, Ramen, 
RamenServiceSyncHandler};
+use kitchen_sink::base_two::{BrothType, Napkin, NapkinServiceSyncHandler, 
Ramen, RamenServiceSyncHandler};
 use kitchen_sink::midlayer::{Dessert, Meal, MealServiceSyncHandler, 
MealServiceSyncProcessor};
 use kitchen_sink::recursive;
 use kitchen_sink::ultimate::{Drink, FullMeal, FullMealAndDrinks,
@@ -252,7 +252,7 @@ fn noodle() -> Noodle {
 }
 
 fn ramen() -> Ramen {
-    Ramen::new("Mr Ramen".to_owned(), 72)
+    Ramen::new("Mr Ramen".to_owned(), 72, BrothType::MISO)
 }
 
 fn napkin() -> Napkin {
diff --git a/lib/rs/test/thrifts/Base_Two.thrift 
b/lib/rs/test/thrifts/Base_Two.thrift
index b4b4ea1a5f..caa6acb86b 100644
--- a/lib/rs/test/thrifts/Base_Two.thrift
+++ b/lib/rs/test/thrifts/Base_Two.thrift
@@ -23,9 +23,15 @@
 
 const i32 WaterWeight = 200
 
+enum brothType {
+  Miso,
+  shouyu,
+}
+
 struct Ramen {
   1: optional string ramenType
   2: required i32 noodleCount
+  3: brothType broth
 }
 
 struct Napkin {


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> Rust enum name wrong case in generated structs
> ----------------------------------------------
>
>                 Key: THRIFT-4661
>                 URL: https://issues.apache.org/jira/browse/THRIFT-4661
>             Project: Thrift
>          Issue Type: Bug
>          Components: Rust - Compiler
>    Affects Versions: 0.11.0
>         Environment: C:\Users\jake>rustup show
> Default host: x86_64-pc-windows-msvc
> stable-x86_64-pc-windows-msvc (default)
> rustc 1.30.0 (da5f414c2 2018-10-24)
>            Reporter: J W
>            Assignee: Allen George
>            Priority: Major
>             Fix For: 1.0
>
>
> *For this thrift (note lowercase "e" at beginning of enum name):*
> enum ePlatform
> { None = 0 }
> struct SettingItem
> { 1: ePlatform platform }
> *Generated with:*
> thrift -gen rs -out ../rust/thrift/src enum_lowercase_prefix.thrift
> *Generated Rust fails to compile:*
> error[E0412]: cannot find type `ePlatform` in this scope
>  --> src\enum_lowercase_prefix.rs:71:24
>  
> 71 | pub platform: Option<ePlatform>,
> |^^^^^^^^^ did you mean `EPlatform`?|
>  
> *In t_rs_generator.cc line 3025:*
> return rust_namespace(ttype) + ttype->get_name();
> *To match behavior in generate_enum(), probably needs to be:*
> return rust_namespace(ttype) + rust_camel_case(ttype->get_name());



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to