From: Jakub Dupak Date: Sun, 3 Dec 2023 10:15:06 +0000 (+0100) Subject: TyTy: refactor to new API X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b05434dec8dd44b063c63379653d3b4c58c8ead8;p=thirdparty%2Fgcc.git 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 --- diff --git a/gcc/rust/typecheck/rust-hir-type-check-type.cc b/gcc/rust/typecheck/rust-hir-type-check-type.cc index 9fa64e10e8a2..e8c276e76fda 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 (root_tyty); - if (adt.is_enum ()) - return root_tyty; - } + auto *maybe_adt = root_tyty->try_as (); + if (maybe_adt && maybe_adt->is_enum ()) + return root_tyty; } return root_tyty;