public inbox for gcc-rust@gcc.gnu.org
 help / color / mirror / Atom feed
From: Philip Herron <philip.herron@embecosm.com>
To: gcc-rust@gcc.gnu.org
Subject: Re: tuple indexes
Date: Wed, 23 Jun 2021 10:47:07 +0100	[thread overview]
Message-ID: <2f353271-7ee6-ab21-e862-69582a503627@embecosm.com> (raw)
In-Reply-To: <YNJpdnoSw9UOGik/@wildebeest.org>


[-- Attachment #1.1: Type: text/plain, Size: 2111 bytes --]

On 22/06/2021 23:51, Mark Wielaard wrote:
> 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
>
Hi Mark,

Good find, I have raised https://github.com/Rust-GCC/gccrs/issues/519.
From the top of my head I think there are a few issues going on.

1. The parser is not able to parse the structure definitions within a
block properly.

2. The knock on is that the name resolution and type resolution will
need updated to handle this.

I think I might take a quick look into this one today I want to double
check a few things as it may have a knock on as to what I am working on.
If i make any progress I will update the ticket and let you know here.

Thanks,

--Phil



[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 665 bytes --]

  reply	other threads:[~2021-06-23  9:47 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22 22:51 Mark Wielaard
2021-06-23  9:47 ` Philip Herron [this message]
2021-06-23  9:55   ` Philip Herron
2021-06-23 16:06     ` Mark Wielaard
2021-06-23 16:26       ` Philip Herron
2021-06-23 20:15 ` Mark Wielaard
2021-06-24 10:22   ` Philip Herron

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2f353271-7ee6-ab21-e862-69582a503627@embecosm.com \
    --to=philip.herron@embecosm.com \
    --cc=gcc-rust@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).