Skip to content

Commit 7847f69

Browse files
authored
Rollup merge of rust-lang#82607 - bjorn3:frame_loc_getter, r=RalfJung
Add a getter for Frame.loc This is necessary for Priroda. For context see https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/topic/Frame.3A.3Aloc.20no.20longer.20public/near/228070266 and oli-obk/priroda#27. cc `@DJMcNab` r? `@RalfJung`
2 parents e38b3eb + 632a895 commit 7847f69

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

compiler/rustc_mir/src/interpret/eval_context.rs

+10
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,16 @@ impl<'mir, 'tcx, Tag> Frame<'mir, 'tcx, Tag> {
226226
}
227227

228228
impl<'mir, 'tcx, Tag, Extra> Frame<'mir, 'tcx, Tag, Extra> {
229+
/// Get the current location within the Frame.
230+
///
231+
/// If this is `Err`, we are not currently executing any particular statement in
232+
/// this frame (can happen e.g. during frame initialization, and during unwinding on
233+
/// frames without cleanup code).
234+
/// We basically abuse `Result` as `Either`.
235+
pub fn current_loc(&self) -> Result<mir::Location, Span> {
236+
self.loc
237+
}
238+
229239
/// Return the `SourceInfo` of the current instruction.
230240
pub fn current_source_info(&self) -> Option<&mir::SourceInfo> {
231241
self.loc.ok().map(|loc| self.body.source_info(loc))

0 commit comments

Comments
 (0)