Skip to content

Commit

Permalink
Add a getter for Frame.loc
Browse files Browse the repository at this point in the history
This is necessary for Priroda.
  • Loading branch information
bjorn3 committed Feb 27, 2021
1 parent ec7f8d9 commit 632a895
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions compiler/rustc_mir/src/interpret/eval_context.rs
Expand Up @@ -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))
Expand Down

0 comments on commit 632a895

Please sign in to comment.