From 22f66de8f1ba5ce815973be4e1b60ad202d39fd0 Mon Sep 17 00:00:00 2001 From: Arthur Cohen Date: Tue, 26 Nov 2024 16:34:37 +0000 Subject: [PATCH] stacked-contexts: Add peek() method gcc/rust/ChangeLog: * util/rust-stacked-contexts.h: Add new method to see what context we are currently in. --- gcc/rust/util/rust-stacked-contexts.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gcc/rust/util/rust-stacked-contexts.h b/gcc/rust/util/rust-stacked-contexts.h index 86cdf9f88d2a..603db5627e94 100644 --- a/gcc/rust/util/rust-stacked-contexts.h +++ b/gcc/rust/util/rust-stacked-contexts.h @@ -71,6 +71,12 @@ template class StackedContexts return last; } + const T& peek() { + rust_assert (!stack.empty()); + + return stack.back(); + } + /** * Are we currently inside of a special context? */