]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
TyTy: refactor to new API
authorJakub Dupak <dev@jakubdupak.com>
Sun, 3 Dec 2023 10:15:06 +0000 (11:15 +0100)
committerPhilip Herron <philip.herron@embecosm.com>
Tue, 19 Dec 2023 17:23:09 +0000 (17:23 +0000)
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

index 9fa64e10e8a23c688ad9e78e403f4f159eb0c5e5..e8c276e76fda39cf3afc10f68bb8ce4034e0ebc9 100644 (file)
@@ -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;