From dev-return-53248-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Tue Aug 28 19:10:04 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 78A5C180674 for ; Tue, 28 Aug 2018 19:10:03 +0200 (CEST) Received: (qmail 72707 invoked by uid 500); 28 Aug 2018 17:10:02 -0000 Mailing-List: contact dev-help@thrift.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@thrift.apache.org Delivered-To: mailing list dev@thrift.apache.org Received: (qmail 72695 invoked by uid 99); 28 Aug 2018 17:10:02 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 28 Aug 2018 17:10:02 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 2DEB0C887F for ; Tue, 28 Aug 2018 17:10:02 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: -109.501 X-Spam-Level: X-Spam-Status: No, score=-109.501 tagged_above=-999 required=6.31 tests=[ENV_AND_HDR_SPF_MATCH=-0.5, KAM_ASCII_DIVIDERS=0.8, RCVD_IN_DNSWL_MED=-2.3, SPF_PASS=-0.001, USER_IN_DEF_SPF_WL=-7.5, USER_IN_WHITELIST=-100] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 6n8tlk2Hf1uS for ; Tue, 28 Aug 2018 17:10:01 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 2F7295F3EE for ; Tue, 28 Aug 2018 17:10:01 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id B239AE02ED for ; Tue, 28 Aug 2018 17:10:00 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id 5F3BA2183D for ; Tue, 28 Aug 2018 17:10:00 +0000 (UTC) Date: Tue, 28 Aug 2018 17:10:00 +0000 (UTC) From: "ASF GitHub Bot (JIRA)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (THRIFT-4617) Avoid generating conflicting struct names in Rust code MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/THRIFT-4617?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D165= 95313#comment-16595313 ]=20 ASF GitHub Bot commented on THRIFT-4617: ---------------------------------------- flavray commented on a change in pull request #1578: THRIFT-4617: Prepend s= ervice-specific struct names with service name URL: https://github.com/apache/thrift/pull/1578#discussion_r213397463 =20 =20 ########## File path: compiler/cpp/src/thrift/generate/t_rs_generator.cc ########## @@ -350,6 +350,7 @@ class t_rs_generator : public t_generator { void render_sync_handler_failed_default_exception_branch(t_function *tfu= nc); void render_sync_handler_send_exception_response(t_function *tfunc, cons= t string &err_var); void render_service_call_structs(t_service* tservice); + void render_args_struct(t_function* tfunc); =20 Review comment: `render_service_call_args_struct` sounds good to me! I'll also change `r= ender_result_value_struct` into `render_service_call_result_value_struct` t= o stay consistent =F0=9F=99=82 ---------------------------------------------------------------- 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. =20 For queries about this service, please contact Infrastructure at: users@infra.apache.org > Avoid generating conflicting struct names in Rust code > ------------------------------------------------------ > > Key: THRIFT-4617 > URL: https://issues.apache.org/jira/browse/THRIFT-4617 > Project: Thrift > Issue Type: Bug > Components: Rust - Compiler > Reporter: Flavien Raynaud > Priority: Minor > Fix For: 0.12.0 > > > If a thrift definition file contains multiple services, with functions ha= ving the same name, the generated code is not valid. There are conflicting = definitions of {{*Args}} and {{*Result}} structs. > {noformat} > service backend { > i32 send( > 1: i32 arg > ); > } > service other_backend { > string send( > 1: i32 arg > ) > } > {noformat} > Will generate the following code in the same file (I only pasted the inte= resting bits): > {noformat} > struct SendResult { > result_value: Option, > } > // ... > struct SendResult { > result_value: Option, > } > {noformat} > And rustc would complain with errors like: > {noformat} > error[E0428]: the name `SendResult` is defined multiple times > --> src/test.rs:496:1 > | > 234 | struct SendResult { > | ----------------- previous definition of the type `SendResult` here > ... > 496 | struct SendResult { > | ^^^^^^^^^^^^^^^^^ `SendResult` redefined here > | > =3D note: `SendResult` must be defined only once in the type namespac= e of this module > {noformat} > ---- > Another (very similar) issue occurs if a user-defined struct happens to b= e called (keeping the same example as before) {{SendResult}}: > {noformat} > struct SendResult { > 1: i32 resultCode, > 2: optional string errorCause, > } > service backend { > SendResult send( > 1: i32 arg > ); > } > {noformat} > Will generate the following code in the same file (I only pasted the inte= resting bits):: > {noformat} > pub struct SendResult { > pub result_code: Option, > pub error_cause: Option, > } > // ... > struct SendResult { > result_value: Option, > } > {noformat} > Again, conflicting definitions of structs and rustc would complain. > ---- > The approach taken by the Go generator (I haven't looked at other languag= es too much, some other generators probably do the same) for generating int= ernal structs related to a service call is to [prepend the service name|htt= ps://github.com/apache/thrift/blob/master/compiler/cpp/src/thrift/generate/= t_go_generator.cc#L502] to each of the structs. > Using the same mechanism would solve both the issues cited above. > I will give it a try and open a PR, but am also definitely open to any fe= edback on the idea :) -- This message was sent by Atlassian JIRA (v7.6.3#76005)