From dev-return-58042-archive-asf-public=cust-asf.ponee.io@thrift.apache.org Sun Mar 29 15:20:02 2020 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 [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 2E520180644 for ; Sun, 29 Mar 2020 17:20:02 +0200 (CEST) Received: (qmail 75293 invoked by uid 500); 29 Mar 2020 15:20:01 -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 75218 invoked by uid 99); 29 Mar 2020 15:20:01 -0000 Received: from mailrelay1-us-west.apache.org (HELO mailrelay1-us-west.apache.org) (209.188.14.139) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 29 Mar 2020 15:20:01 +0000 Received: from jira-he-de.apache.org (static.172.67.40.188.clients.your-server.de [188.40.67.172]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 8D837E2CAC for ; Sun, 29 Mar 2020 15:20:00 +0000 (UTC) Received: from jira-he-de.apache.org (localhost.localdomain [127.0.0.1]) by jira-he-de.apache.org (ASF Mail Server at jira-he-de.apache.org) with ESMTP id 0E91D7804C6 for ; Sun, 29 Mar 2020 15:20:00 +0000 (UTC) Date: Sun, 29 Mar 2020 15:20:00 +0000 (UTC) From: "Allen George (Jira)" To: dev@thrift.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Comment Edited] (THRIFT-5071) Rust: rust tutorial can not be compiled with rust edition 2018 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-5071?page=3Dcom.atlassia= n.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D170= 70383#comment-17070383 ]=20 Allen George edited comment on THRIFT-5071 at 3/29/20, 3:19 PM: ---------------------------------------------------------------- [frowns] If I understand correctly, there are two problems: # under {{edition =3D "2018"}} the rules for generating relative paths have= changed. It used to be that you didn't have to specify a root for a relati= ve path. Now one *has* to use {{self}}, {{super}} or {{crate}} # one can't place thrift files that are dependent on each other in an arbit= rary directory structure, because the generated {{use ...}} declarations as= sume that all thrift files are in the same location For the first situation, we can indeed solve it by adding {{crate}} to the = {{use}} declaration; for example: {{use crate::MODULE_NAME}}, assuming that= all generated files are in one level. For the second situation, I *think* the problem is as follows. Consider: {noformat} root +- common.thrift +- dir1 +- dependent_1_on_common.thrift +- ... +- dir2 +- dependent_2_on_common.thrift +- ... {noformat} The problem here is that the generated {{dependent_1_on_common.rs}} and {{d= ependent_2_on_common.rs}} all would have declarations like: {noformat} // Autogenerated by Thrift Compiler (0.14.0) // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING #![allow(unused_imports)] #![allow(unused_extern_crates)] #![cfg_attr(feature =3D "cargo-clippy", allow(too_many_arguments, type_comp= lexity))] #![cfg_attr(rustfmt, rustfmt_skip)] use crate::common; <---- PROBLEMATIC LINE ... {noformat} that would obviously break because their location in the rust/filesystem mo= dule hierarchy is not reflected in the thrift-generated code. Assuming the = compiler has the information, I *think* this would be solved by including t= he Thrift namespace of the *dependent* file in the generated {{use}} expres= sions in the *dependee*. At any rate, this should be two tickets that are dealt with separately, and= I'll create a separate ticket around the directory-structure issue. was (Author: allengeorge): [frowns] If I understand correctly, there are two problems: # under {{edition =3D "2018"}} the rules for generating relative paths have= changed. It used to be that you didn't have to specify a root for a relati= ve path. Now one *has* to use {{self}},{{super}} or {{crate}} # one can't place thrift files that are dependent on each other in an arbit= rary directory structure, because the generated {{use ...}} declarations as= sume that all thrift files are in the same location For the first situation, we can indeed solve it by adding {{crate}} to the = {{use}} declaration; for example: {{use crate::MODULE_NAME}}, assuming that= all generated files are in one level. For the second situation, I *think* the problem is as follows. Consider: {noformat} root +- common.thrift +- dir1 +- dependent_1_on_common.thrift +- ... +- dir2 +- dependent_2_on_common.thrift +- ... {noformat} The problem here is that the generated {{dependent_1_on_common.rs}} and {{d= ependent_2_on_common.rs}} all would have declarations like: {noformat} // Autogenerated by Thrift Compiler (0.14.0) // DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING #![allow(unused_imports)] #![allow(unused_extern_crates)] #![cfg_attr(feature =3D "cargo-clippy", allow(too_many_arguments, type_comp= lexity))] #![cfg_attr(rustfmt, rustfmt_skip)] use crate::common; <---- PROBLEMATIC LINE ... {noformat} that would obviously break because their location in the rust/filesystem mo= dule hierarchy is not reflected in the thrift-generated code. Assuming the = compiler has the information, I *think* this would be solved by including t= he Thrift namespace of the *dependent* file in the generated {{use}} expres= sions in the *dependee*. At any rate, this should be two tickets that are dealt with separately, and= I'll create a separate ticket around the directory-structure issue. > Rust: rust tutorial can not be compiled with rust edition 2018 > -------------------------------------------------------------- > > Key: THRIFT-5071 > URL: https://issues.apache.org/jira/browse/THRIFT-5071 > Project: Thrift > Issue Type: Bug > Components: Rust - Compiler, Tutorial > Affects Versions: 0.13.0 > Environment: cargo 1.40.0 (bc8e4c8be 2019-11-22) > rustc 1.40.0 (73528e339 2019-12-16) > Reporter: fan liwen > Assignee: Allen George > Priority: Major > > The rust compiler is broken for rust edition 2018. If we change the tutor= ial cargo (tutorial/rs/Cargo.toml) to edition =3D "2018", the following err= or would occur: > {code:java} > // code placeholder > error[E0432]: unresolved import `shared` > --> src/tutorial.rs:30:5 > | > 30 | use shared; > | ^^^^^^ no `shared` external crateerror: aborting due to previous= error > {code} > =C2=A0The compiler might need to generate *use=C2=A0crate::shared* instea= d.=C2=A0 -- This message was sent by Atlassian Jira (v8.3.4#803005)