From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (wildebeest.demon.nl [212.238.236.112]) by sourceware.org (Postfix) with ESMTPS id 883453955432 for ; Tue, 22 Jun 2021 22:51:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 883453955432 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from reform (deer0x10.wildebeest.org [172.31.17.146]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id C5D543000252 for ; Wed, 23 Jun 2021 00:51:34 +0200 (CEST) Received: by reform (Postfix, from userid 1000) id 57C042E808D2; Wed, 23 Jun 2021 00:51:34 +0200 (CEST) Date: Wed, 23 Jun 2021 00:51:34 +0200 From: Mark Wielaard To: gcc-rust@gcc.gnu.org Subject: tuple indexes Message-ID: MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="EEFvBaThdUIQhgNF" Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: gcc-rust@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: gcc-rust mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 22 Jun 2021 22:51:38 -0000 --EEFvBaThdUIQhgNF Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Hi, I was looking into https://github.com/Rust-GCC/gccrs/issues/511 "rust has two kinds of integer literal" Which explains that integer literals used for a tuple index are not general integer literals. First I wanted to write some tests, and started with some constructs that should pass. But some don't. In particular the empty tuple struct isn't recognized, and the struct name path lookup doesn't work when initializing the tuple struct. tuple_index.rs:16:12: error: unrecognised token ‘)’ in type 16 | struct E(); | ^ tuple_index.rs:16:12: error: could not parse type in tuple struct field tuple_index.rs:20:12: error: unknown root segment in path O lookup O 20 | let so = O(0); | ^ tuple_index.rs:24:12: error: unknown root segment in path T lookup T 24 | let st = T(0,1); | ^ tuple_index.rs:28:12: error: unknown root segment in path M lookup M 28 | let sm = M(0,1,2,3,4,5,6,7,8,9,10); | ^ I haven't had time to try to resolve these issues, but wanted to report them. Finally, the The Rust Reference says "A tuple index is used to refer to the fields of tuples, tuple structs, and tuple variants." I don't understand how this would work for tuple variants. Does anybody have an example of how to refer to a tuple variant so a tuple index can be used on it? Cheers, Mark --EEFvBaThdUIQhgNF Content-Type: application/rls-services+xml Content-Disposition: attachment; filename="tuple_index.rs" Content-Transfer-Encoding: quoted-printable fn main()=0A{=0A // tuples=0A let z =3D ();=0A=0A let o =3D (0,);=0A le= t f =3D o.0;=0A=0A let t =3D (0,1);=0A let s =3D t.1;=0A=0A let m =3D (0= ,1,2,3,4,5,6,7,8,9,10);=0A let l =3D m.10;=0A=0A // tuple structs=0A str= uct E();=0A let e =3D E();=0A=0A struct O(i32);=0A let so =3D O(0);=0A = let sf =3D so.0;=0A=0A struct T(i32,i32);=0A let st =3D T(0,1);=0A let f= s =3D st.1;=0A=0A struct M(i32,i32,i32,i32,i32,i32,i32,i32,i32,i32,i32);= =0A let sm =3D M(0,1,2,3,4,5,6,7,8,9,10);=0A let sl =3D sm.10;=0A=0A z= =0A}=0A --EEFvBaThdUIQhgNF--