Commit Message
Arthur Cohen
Jan. 30, 2024, 12:07 p.m. UTC
From: Jakub Dupak <dev@jakubdupak.com> gcc/rust/ChangeLog: * typecheck/rust-hir-type-check-type.cc (TypeCheckType::resolve_root_path): Refactor. Signed-off-by: Jakub Dupak <dev@jakubdupak.com> --- gcc/rust/typecheck/rust-hir-type-check-type.cc | 11 +++-------- 1 file 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 62a17769c3f..951920138cb 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;