On 23/06/2021 10:47, Philip Herron wrote:
> 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
>
Small update, I think part of this issue is that the support for
unit-structs is not there yet in the compiler, so if you remove the unit
tuple struct and move the other struct definitions outside of the block
the test case works: https://godbolt.org/z/nb84sEaE4

It might be enough to help with testing your tuple index fixes.

Thanks

--Phil


Attachment: OpenPGP_signature
Description: OpenPGP digital signature

-- 
Gcc-rust mailing list
Gcc-rust@gcc.gnu.org
https://gcc.gnu.org/mailman/listinfo/gcc-rust

Reply via email to