[PATCH 2/2] WIP union hir-lowering and type support

2021-07-22 Thread Mark Wielaard
Treat a union as a Struct variant like a tuple struct. Add an iterator and get_identifier functions to the AST Union class. Same for the HIR Union class, plus a get_generics_params method. Add a get_is_union method tot the ADTType. --- gcc/rust/ast/rust-item.h | 11 gcc

[PATCH 1/2] Better union support in the parser

2021-07-22 Thread Mark Wielaard
union is a weak keyword which means it isn't reserved and can be used as a generic identifier. When we see an identifier where a union could be declared we check whether the identifier is "union", but only when the next token is also an identifier. In parse_union we shouldn't skip the first identif

union support

2021-07-22 Thread Mark Wielaard
Hi, I have been playing with union support which was mostly missing. union is slightly odd because it is a weak keyword, so it can be used as a "normal" identifier and is only special when defining a union type. Which means you can have programs like: union union { union: u32, funion: f32 } pub f