aboutsummaryrefslogtreecommitdiff
path: root/gcc/rust/util/rust-lang-item.h
diff options
context:
space:
mode:
authorPhilip Herron <herron.philip@googlemail.com>2025-02-10 16:28:30 +0000
committerPhilip Herron <philip.herron@embecosm.com>2025-02-11 15:44:05 +0000
commit3fd738ca7b346343853344a749d22815740fa114 (patch)
tree4a43999e8dc5501344ae8566b1c06b5aa938ca6e /gcc/rust/util/rust-lang-item.h
parentaf234dd6a9dcb71498d16a8fb65ad53bc5d62ef4 (diff)
downloadgcc-3fd738ca7b346343853344a749d22815740fa114.zip
gcc-3fd738ca7b346343853344a749d22815740fa114.tar.gz
gcc-3fd738ca7b346343853344a749d22815740fa114.tar.bz2
gccrs: add discriminant value intrinsic
This is pretty nasty piece of rust in my opinion the return type of this intrinsic results into a lang item associated type: <T as DiscriminantKind>::Discriminant This is a special case which needs to support mapping onto the repr type of the associated ADT that is passed in, but defaults to iszie otherwise. This patch assumes we only come accross this case in a HIR::CALL_EXPR, so and makes assumutions that its always of this function signiture. I will do some checking in libcore to verify that assumption. More work is needed to parse the repr type on enums but the code is there to support this when its in to change the types etc. Addresses Rust-GCC#3348 gcc/rust/ChangeLog: * backend/rust-compile-intrinsic.cc (discriminant_value_handler): new handler * typecheck/rust-hir-trait-resolve.cc (TraitItemReference::resolve_item): track the defid * typecheck/rust-hir-type-check-base.cc (TypeCheckBase::parse_repr_options): default isize * typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::visit): special case CallExpr * typecheck/rust-hir-type-check-item.cc (TypeCheckItem::visit): parse repr options enum * typecheck/rust-hir-type-check-type.cc (TypeCheckType::visit): remove bad diagnostic * typecheck/rust-tyty.cc (PlaceholderType::PlaceholderType): track defid (PlaceholderType::clone): likewise (PlaceholderType::get_def_id): likeiwse * typecheck/rust-tyty.h: placeholder track defid * util/rust-lang-item.cc: add new lang items * util/rust-lang-item.h: likewise gcc/testsuite/ChangeLog: * rust/execute/torture/enum_intrinsics1.rs: New test. Signed-off-by: Philip Herron <herron.philip@googlemail.com>
Diffstat (limited to 'gcc/rust/util/rust-lang-item.h')
-rw-r--r--gcc/rust/util/rust-lang-item.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/gcc/rust/util/rust-lang-item.h b/gcc/rust/util/rust-lang-item.h
index 61d6454e..1aaa887 100644
--- a/gcc/rust/util/rust-lang-item.h
+++ b/gcc/rust/util/rust-lang-item.h
@@ -147,6 +147,9 @@ public:
STRUCTURAL_PEQ,
STRUCTURAL_TEQ,
+
+ DISCRIMINANT_TYPE,
+ DISCRIMINANT_KIND,
};
static const BiMap<std::string, Kind> lang_items;