https://gcc.gnu.org/g:b78b238e7aebd6d551f4b3a0684f341db0075610
commit r15-8334-gb78b238e7aebd6d551f4b3a0684f341db0075610 Author: badumbatish <tanghocle...@gmail.com> Date: Fri Aug 23 22:21:05 2024 -0700 gccrs: Add pop guard for binder gcc/rust/ChangeLog: * typecheck/rust-hir-type-check.h: Add pop guard for binder Diff: --- gcc/rust/typecheck/rust-hir-type-check.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/gcc/rust/typecheck/rust-hir-type-check.h b/gcc/rust/typecheck/rust-hir-type-check.h index 3fcb32a6e385..fa49e0689f30 100644 --- a/gcc/rust/typecheck/rust-hir-type-check.h +++ b/gcc/rust/typecheck/rust-hir-type-check.h @@ -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 ();