]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
gccrs: TyTy: refactor to new API
authorJakub Dupak <dev@jakubdupak.com>
Sun, 3 Dec 2023 10:15:06 +0000 (11:15 +0100)
committerArthur Cohen <arthur.cohen@embecosm.com>
Tue, 30 Jan 2024 11:36:50 +0000 (12:36 +0100)
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 62a17769c3fe4c9ebf21939c40500d847d2b3611..951920138cb8659df0ca6eaa0b4d92c2ef484849 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;