about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbjorn3 <bjorn3@users.noreply.github.com>2021-02-27 21:01:02 +0100
committerbjorn3 <bjorn3@users.noreply.github.com>2021-02-27 21:01:02 +0100
commit632a89529a6a951b83f805f4e1bb07d127b4e69c (patch)
tree25d1b9dbddc57c96542852dbcde27f27f4934092
parentec7f8d94df0251532c47330abcb7988d77a1f818 (diff)
downloadrust-632a89529a6a951b83f805f4e1bb07d127b4e69c.tar.gz
rust-632a89529a6a951b83f805f4e1bb07d127b4e69c.zip
Add a getter for Frame.loc
This is necessary for Priroda.
-rw-r--r--compiler/rustc_mir/src/interpret/eval_context.rs10
1 files changed, 10 insertions, 0 deletions
diff --git a/compiler/rustc_mir/src/interpret/eval_context.rs b/compiler/rustc_mir/src/interpret/eval_context.rs
index 1ba87358b1c..6b796eb3721 100644
--- a/compiler/rustc_mir/src/interpret/eval_context.rs
+++ b/compiler/rustc_mir/src/interpret/eval_context.rs
@@ -226,6 +226,16 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> {
 }
 
 impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
+    /// Get the current location within the Frame.
+    ///
+    /// If this is `Err`, we are not currently executing any particular statement in
+    /// this frame (can happen e.g. during frame initialization, and during unwinding on
+    /// frames without cleanup code).
+    /// We basically abuse `Result` as `Either`.
+    pub fn current_loc(&self) -> Result<mir::Location, Span> {
+        self.loc
+    }
+
     /// Return the `SourceInfo` of the current instruction.
     pub fn current_source_info(&self) -> Option<&mir::SourceInfo> {
         self.loc.ok().map(|loc| self.body.source_info(loc))