From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by sourceware.org (Postfix) with ESMTPS id B6B0E39450ED for ; Thu, 24 Jun 2021 10:22:18 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org B6B0E39450ED Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=embecosm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=embecosm.com Received: by mail-wm1-x32a.google.com with SMTP id w13so3587037wmc.3 for ; Thu, 24 Jun 2021 03:22:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=embecosm.com; s=google; h=to:references:from:subject:message-id:date:user-agent:mime-version :in-reply-to; bh=5OU3sUaHrB9vqKphM5VZ8hprvIADBjPMVjX/a0DF98w=; b=Z6Vkxg0Uaa/52SWs0ywUEnwwUb2kIqAXCJr/C5wUH5+0BAY7/vsyl24AT/8u81LKJH HorzvQyaFO0OojAjVNM/GTABngyoh6phmWGZ+emfF2hikjqVkrCHpQWxa0BhS3Jf7FLd 5DsvZ97IkFDNXvSaRvZuUtibppfHzxDeQt6cR53Hma2zYd0LLL/5qeq42xdpA4a4Q2FF MVRFwlUcHn90lZhUeMEpG8FZlUaIG9K5bNGWtiO+YwbUSfSHG/+ccettfwFvtmN87R34 OEHWlAFMsRiPtSlQBdMZIVN+SXyim+tTOvDGE2RaBlC57DsNUNSxqE29ekgBHD6VBA0P UNBg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:references:from:subject:message-id:date :user-agent:mime-version:in-reply-to; bh=5OU3sUaHrB9vqKphM5VZ8hprvIADBjPMVjX/a0DF98w=; b=p/abzkqxFe4hytHjaT2yYpAPEwI8kKUuo5Vgi4Q0POskspNIeWEPyJO/h+fMwWgKkN AfRZ636WcA7ZtzAwY9Rg/Km0Ab50Up0182S5MYkOjJy91O28peC2EqHu2zcbJiX/GkOm PSzTFI6QqiHRcJgfh+HqXmV7nyLUzXrPTZGczxoNjy7GK4bdSb2bpQbsH2tw2yMc9qRv XH8XNF+yGq2Q/xNR5EdGO5aZP/5zT3u9m8v6CyIqMTuXVkUiJMSl1k/w4VQd3PvgGpw0 UjzrLExYwmYvkbvX+5eS32Z4B4RTYhWV/KzRg/aPjltQbVRMk/8O//0vIdeOearyebPy GJ5g== X-Gm-Message-State: AOAM531TbkD8FXTKL/g+etnXyIQxMCbt/0TfUD8lywcCTRUSi5Ra1YtU 6QPBynrc/cX8+6zi3uvtpYNC+iSzAtzpGA== X-Google-Smtp-Source: ABdhPJw5V/nUZb+wlarLR48WxzxFrhD5kzs6OMpkgVwDqoDAWzZinLMyXbgJJ8J1E0eLgngY7rCplw== X-Received: by 2002:a1c:1b10:: with SMTP id b16mr3470708wmb.130.1624530137584; Thu, 24 Jun 2021 03:22:17 -0700 (PDT) Received: from [192.168.0.40] ([86.14.124.218]) by smtp.gmail.com with ESMTPSA id y66sm2543198wmy.39.2021.06.24.03.22.16 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 24 Jun 2021 03:22:17 -0700 (PDT) To: gcc-rust@gcc.gnu.org References: From: Philip Herron Subject: Re: tuple indexes Message-ID: <242b4b89-eab2-eb3d-b440-bb58130f3e9d@embecosm.com> Date: Thu, 24 Jun 2021 11:22:16 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.8.1 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2ZpfUrYvVetEQIIvL9bjWqDTNDrPmywHE" X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_NONE, 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: Thu, 24 Jun 2021 10:22:20 -0000 This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2ZpfUrYvVetEQIIvL9bjWqDTNDrPmywHE Content-Type: multipart/mixed; boundary="iwLMa2fGkAx90LPfkB4sFtmIqEZrBTtuD"; protected-headers="v1" From: Philip Herron To: gcc-rust@gcc.gnu.org Message-ID: <242b4b89-eab2-eb3d-b440-bb58130f3e9d@embecosm.com> Subject: Re: tuple indexes References: In-Reply-To: --iwLMa2fGkAx90LPfkB4sFtmIqEZrBTtuD Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Content-Language: en-US On 23/06/2021 21:15, Mark Wielaard wrote: > On Wed, Jun 23, 2021 at 12:51:34AM +0200, Mark Wielaard wrote: >> 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? > Tom pointed out on irc that it doesn't seem possible to access enum > variant types except through a matching expression. The Rust Reference > also seems to be inconsistent. As mentioned above it mentions you can > use a tuple index to refer to a field of a enum tuple variant. But it > also says "A tuple indexing expression accesses fields of tuples and > tuple structs." So it probably really isn't possible to use a tuple > index on enum tuple variants. > > I did notice the same issue as for unit tuple struct types. The empty > tuple wasn't accepted in the parser. The attached patch, also at > https://code.wildebeest.org/git/user/mjw/gccrs/commit/?h=3Dtuple_enum_v= ariant_unit > fixes this. > > It does include a test case, but most of it is commented out because > actually resolving enum types isn't implemented yet. If you uncomment > the rest of the testcase you get: > > tuple_enum_variants.rs:3:31: error: failed to resolve TypePath: E > 3 | fn f(e0: E, e1: E, e2: E) -> (E,E,E,()) > | ^ > tuple_enum_variants.rs:3:31: error: unresolved type > tuple_enum_variants.rs:3:33: error: failed to resolve TypePath: E > 3 | fn f(e0: E, e1: E, e2: E) -> (E,E,E,()) > | ^ > tuple_enum_variants.rs:3:33: error: unresolved type > tuple_enum_variants.rs:3:35: error: failed to resolve TypePath: E > 3 | fn f(e0: E, e1: E, e2: E) -> (E,E,E,()) > | ^ > tuple_enum_variants.rs:3:35: error: unresolved type > tuple_enum_variants.rs:3:10: error: failed to resolve TypePath: E > 3 | fn f(e0: E, e1: E, e2: E) -> (E,E,E,()) > | ^ > tuple_enum_variants.rs:3:10: error: unresolved type > tuple_enum_variants.rs:3:17: error: failed to resolve TypePath: E > 3 | fn f(e0: E, e1: E, e2: E) -> (E,E,E,()) > | ^ > tuple_enum_variants.rs:3:17: error: unresolved type > tuple_enum_variants.rs:3:24: error: failed to resolve TypePath: E > 3 | fn f(e0: E, e1: E, e2: E) -> (E,E,E,()) > | ^ > tuple_enum_variants.rs:3:24: error: unresolved type > tuple_enum_variants.rs:13:12: error: unknown root segment in path E::T0= lookup E > 13 | let e0 =3D E::T0(); > | ^ > tuple_enum_variants.rs:14:12: error: unknown root segment in path E::T1= lookup E > 14 | let e1 =3D E::T1(0); > | ^ > tuple_enum_variants.rs:15:12: error: unknown root segment in path E::T2= lookup E > 15 | let e2 =3D E::T2(0,1); > | ^ > > Cheers, > > Mark > Hi Mark, Thanks for the patch, its being merged: https://github.com/Rust-GCC/gccrs/pull/522 I have open issues about enums and unions they will be fixed as part of my work into traits. They are a type of algebraic data type so in theory i can reuse a lot of the existing code to implement them. Thanks --Phil --iwLMa2fGkAx90LPfkB4sFtmIqEZrBTtuD-- --2ZpfUrYvVetEQIIvL9bjWqDTNDrPmywHE Content-Type: application/pgp-signature; name="OpenPGP_signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="OpenPGP_signature" -----BEGIN PGP SIGNATURE----- wsD5BAABCAAjFiEET83ATZOayqRjyL0Cr7gxHEFOdpkFAmDUXNgFAwAAAAAACgkQr7gxHEFOdplf 3gv/SZMsQ/3wy05yOuRhWVkvhUe9jYsiEb1EjweN1/MMw9EAV0K+QnY0qGVXHvUaQMVpnK014VI6 9nQelbTRM1fBbl3yNrj1DIZq4POO23PxYJpssVkQDzPGcrJsNfvRtM3OEvtYwWk1I/i5c23ogUJy ygfLbqhrtrphiZluyHX078BG+NMU+9U7DPfmNviEL+U7+GC9Zu8nHW1UvXIy/RYmgVqop9+AW40X kDV5v1fNFDg7k4Y3nJFLuBYPx2Dlq9AhMpkzMLv0RE/snA7jSuYubVmTqWOINd0WAIZOy2WZrNlM PjO5BIycWki2uo9x+OP3pMeUevlY6R/7LyNH/9oitWwRx6XVdl/qeiZDcjX5ZiqF+MHsNrI24HY7 JTa5q/VHMflGOH0sUf+GIpXFGSysl+il54eDaB+LgX+ck/JlqqCPHBVsbPzhITmvBCVNw6nlRPZw s59zIM1UKECroF9sjIx7y/Hx3oOT69nyZCAwD97DNNxMfb+QBwxYrr1clx/e =1BaO -----END PGP SIGNATURE----- --2ZpfUrYvVetEQIIvL9bjWqDTNDrPmywHE--