about summary refs log tree commit diff
path: root/compiler/stable_mir/src/mir
diff options
context:
space:
mode:
authorKirby Linvill <kjlinvill@gmail.com>2023-10-25 22:09:12 +0100
committerKirby Linvill <kjlinvill@gmail.com>2023-10-25 22:18:58 +0100
commit39b293fb5a68081e7c050ed2805c8e3404c9763a (patch)
tree9a743dfd0baa99e0e327c195b9f501c31a44dd1c /compiler/stable_mir/src/mir
parent372c5335327f330858b03889a46614d2a248d325 (diff)
downloadrust-39b293fb5a68081e7c050ed2805c8e3404c9763a.tar.gz
rust-39b293fb5a68081e7c050ed2805c8e3404c9763a.zip
Add a public API to get all body locals
This is particularly helpful for the ui tests, but also could be helpful
for Stable MIR users who just want all the locals without needing to
concatenate responses
Diffstat (limited to 'compiler/stable_mir/src/mir')
-rw-r--r--compiler/stable_mir/src/mir/body.rs8
1 files changed, 8 insertions, 0 deletions
diff --git a/compiler/stable_mir/src/mir/body.rs b/compiler/stable_mir/src/mir/body.rs
index dc472b3786c..97dd649bf64 100644
--- a/compiler/stable_mir/src/mir/body.rs
+++ b/compiler/stable_mir/src/mir/body.rs
@@ -48,6 +48,14 @@ impl Body {
     pub fn internal_locals(&self) -> &[LocalDecl] {
         &self.locals[self.arg_count + 1..]
     }
+
+    /// Convenience function to get all the locals in this function.
+    ///
+    /// Locals are typically accessed via the more specific methods `ret_local`,
+    /// `arg_locals`, and `internal_locals`.
+    pub fn locals(&self) -> &[LocalDecl] {
+        &self.locals
+    }
 }
 
 type LocalDecls = Vec<LocalDecl>;