public inbox for gcc-rust@gcc.gnu.org
 help / color / mirror / Atom feed
* tuple indexes
@ 2021-06-22 22:51 Mark Wielaard
  2021-06-23  9:47 ` Philip Herron
  2021-06-23 20:15 ` Mark Wielaard
  0 siblings, 2 replies; 7+ messages in thread
From: Mark Wielaard @ 2021-06-22 22:51 UTC (permalink / raw)
  To: gcc-rust

[-- 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 --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-06-24 10:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-06-22 22:51 tuple indexes Mark Wielaard
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

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).