aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakub Dupak <dev@jakubdupak.com>2023-12-03 11:15:06 +0100
committerArthur Cohen <arthur.cohen@embecosm.com>2024-01-30 12:36:50 +0100
commit7eaef4f5b19a6e5298ce63218a0af791f54f8102 (patch)
treee013b7372fcb383857fde48a857f373e57d3357b
parent35d5f82eaeaa849997039586109b0b302a88148a (diff)
downloadgcc-7eaef4f5b19a6e5298ce63218a0af791f54f8102.zip
gcc-7eaef4f5b19a6e5298ce63218a0af791f54f8102.tar.gz
gcc-7eaef4f5b19a6e5298ce63218a0af791f54f8102.tar.bz2
gccrs: TyTy: refactor to new API
gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Refactor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com>
-rw-r--r--gcc/rust/typecheck/rust-hir-type-check-type.cc11
1 files changed, 3 insertions, 8 deletions
diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc
index 62a1776..9519201 100644
--- a/gcc/rust/typecheck/rust-hir-type-check-type.cc
+++ b/gcc/rust/typecheck/rust-hir-type-check-type.cc
@@ -442,14 +442,9 @@ TypeCheckType::resolve_root_path (HIR::TypePath &path, size_t *offset,
root_tyty = lookup;
// this enforces the proper get_segments checks to take place
- bool is_adt = root_tyty->get_kind () == TyTy::TypeKind::ADT;
- if (is_adt)
- {
- const TyTy::ADTType &adt
- = *static_cast<const TyTy::ADTType *> (root_tyty);
- if (adt.is_enum ())
- return root_tyty;
- }
+ auto *maybe_adt = root_tyty->try_as<const TyTy::ADTType> ();
+ if (maybe_adt && maybe_adt->is_enum ())
+ return root_tyty;
}
return root_tyty;