From: Mark Wielaard <mark@klomp.org>
To: gcc-rust@gcc.gnu.org
Subject: tuple indexes
Date: Wed, 23 Jun 2021 00:51:34 +0200 [thread overview]
Message-ID: <YNJpdnoSw9UOGik/@wildebeest.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1375 bytes --]
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
[-- Attachment #2: tuple_index.rs --]
[-- Type: application/rls-services+xml, Size: 468 bytes --]
next reply other threads:[~2021-06-22 22:51 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-22 22:51 Mark Wielaard [this message]
2021-06-23 9:47 ` Philip Herron
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=YNJpdnoSw9UOGik/@wildebeest.org \
--to=mark@klomp.org \
--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).