]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add pop guard for binder
authorbadumbatish <tanghocle456@gmail.com>
Sat, 24 Aug 2024 05:21:05 +0000 (22:21 -0700)
committerCohenArthur <arthur.cohen@embecosm.com>
Thu, 29 Aug 2024 13:00:17 +0000 (13:00 +0000)
gcc/rust/ChangeLog:

* typecheck/rust-hir-type-check.h:
Add pop guard for binder

gcc/rust/typecheck/rust-hir-type-check.h

index c85a83955b9c88c152c8de036449910b17866824..eb0c8490ecbf7b28e25daeea780b05f0ca94ad5b 100644 (file)
@@ -349,6 +349,8 @@ private:
     /** Only to be used by the guard. */
     void pop_binder () { binder_size_stack.pop (); }
 
+    bool binder_empty () { return binder_size_stack.empty (); }
+
     /**
      * Switch from resolving a function header to a function body.
      */
@@ -424,7 +426,8 @@ public:
     ~LifetimeResolverGuard ()
     {
       rust_assert (!ctx.lifetime_resolver_stack.empty ());
-      ctx.lifetime_resolver_stack.top ().pop_binder ();
+      if (!ctx.lifetime_resolver_stack.top ().binder_empty ())
+       ctx.lifetime_resolver_stack.top ().pop_binder ();
       if (kind == RESOLVER)
        {
          ctx.lifetime_resolver_stack.pop ();