aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/resolve
diff options
context:
space:
mode:
authorPhilip Herron <philip.herron@embecosm.com>2022-02-02 14:06:25 +0000
committerPhilip Herron <philip.herron@embecosm.com>2022-02-02 14:06:25 +0000
commit46ee20dbdbb02b40ae199293dfa774fafad72c0e (patch)
tree7a9abfd0b49074b315715fa1b2cef51951cabdca /gcc/rust/resolve
parent6e5f8f76cbe47880ceae1bcf0bf7f07f601517ec (diff)
downloadgcc-46ee20dbdbb02b40ae199293dfa774fafad72c0e.zip
gcc-46ee20dbdbb02b40ae199293dfa774fafad72c0e.tar.gz
gcc-46ee20dbdbb02b40ae199293dfa774fafad72c0e.tar.bz2
Fix enum variant discriminant values
Enum discriminants before this patch were either: - The hir-id of the tuple/struct variant - The expression of the specified discriminant - Computed int64 of the dataless variant Each of these had tree ways of computing the qualifier this patch changes this to be more in line with rust to compute the values unless its a specified discriminant value. In order to compile this we now create an implicit HIR::LiteralExpr and feed this into our constexpr code so it reuses the same path as the variants with a specified constant discriminant.
Diffstat (limited to 'gcc/rust/resolve')
-rw-r--r--gcc/rust/resolve/rust-ast-resolve-item.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/gcc/rust/resolve/rust-ast-resolve-item.h b/gcc/rust/resolve/rust-ast-resolve-item.h
index 234d865..cff3dbb 100644
--- a/gcc/rust/resolve/rust-ast-resolve-item.h
+++ b/gcc/rust/resolve/rust-ast-resolve-item.h
@@ -340,6 +340,15 @@ public:
}
/* EnumItem doesn't need to be handled, no fields. */
+ void visit (AST::EnumItem &item) override
+ {
+ auto decl
+ = CanonicalPath::new_seg (item.get_node_id (), item.get_identifier ());
+ auto path = prefix.append (decl);
+ auto cpath = canonical_prefix.append (decl);
+ mappings->insert_canonical_path (mappings->get_current_crate (),
+ item.get_node_id (), cpath);
+ }
void visit (AST::EnumItemTuple &item) override
{