aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/rust-gcc.cc
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-01-07 18:15:37 +0000
committerArthur Cohen <arthur.cohen@embecosm.com>2025-03-21 12:56:55 +0100
commitf821a513843baabed8a39601bbc714558110b748 (patch)
treee5d4bc66d8c721905324d63be3a84b5e25363ee2 /gcc/rust/rust-gcc.cc
parent2fa9719068774ab7ec5ed4cbe95cfe30fa94dbb1 (diff)
downloadgcc-f821a513843baabed8a39601bbc714558110b748.zip
gcc-f821a513843baabed8a39601bbc714558110b748.tar.gz
gcc-f821a513843baabed8a39601bbc714558110b748.tar.bz2
gccrs: cleanup our enum type layout to be closer to rustc
This changes our enum type layout so for example: enum Foo { A, B, C(char), D { x: i32, y: i32 }, } Used to get layed out like this in gccrs: union { struct A { int RUST$ENUM$DISR; }; struct B { int RUST$ENUM$DISR; }; struct C { int RUST$ENUM$DISR; char __0; }; struct D { int RUST$ENUM$DISR; i64 x; i64 y; }; } This has some issues notably with the constexpr because this is just a giant union it means its not simple to constify what enum variant we are looking at because the discriminant is a mess. This now gets layed out as: struct { int RUST$ENUM$DISR; union { struct A { }; struct B { }; struct C { char __0; }; struct D { i64 x; i64 y; }; } payload; } This layout is much cleaner and allows for our constexpr to work properly. gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::visit): new layout * backend/rust-compile-pattern.cc (CompilePatternCheckExpr::visit): likewise (CompilePatternBindings::visit): likewise * backend/rust-compile-resolve-path.cc: likewise * backend/rust-compile-type.cc (TyTyResolveCompile::visit): implement new layout * rust-gcc.cc (constructor_expression): get rid of useless assert Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/rust-gcc.cc')
-rw-r--r--gcc/rust/rust-gcc.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/gcc/rust/rust-gcc.cc b/gcc/rust/rust-gcc.cc
index 37d51e5..a6e8ea9 100644
--- a/gcc/rust/rust-gcc.cc
+++ b/gcc/rust/rust-gcc.cc
@@ -1352,7 +1352,7 @@ constructor_expression (tree type_tree, bool is_variant,
if (!TREE_CONSTANT (elt->value))
is_constant = false;
}
- gcc_assert (field == NULL_TREE);
+ // gcc_assert (field == NULL_TREE);
}
}