Skip to content

Commit 51efb13

Browse files
committed
make some Frame fields more private
1 parent 65b1432 commit 51efb13

File tree

5 files changed

+13
-17
lines changed

5 files changed

+13
-17
lines changed

src/concurrency/thread.rs

-4
Original file line numberDiff line numberDiff line change
@@ -377,10 +377,6 @@ impl VisitProvenance for Frame<'_, Provenance, FrameExtra<'_>> {
377377
return_place,
378378
locals,
379379
extra,
380-
body: _,
381-
instance: _,
382-
return_to_block: _,
383-
loc: _,
384380
// There are some private fields we cannot access; they contain no tags.
385381
..
386382
} = self;

src/helpers.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -1105,12 +1105,12 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
11051105
// Make an attempt to get at the instance of the function this is inlined from.
11061106
let instance: Option<_> = try {
11071107
let scope = frame.current_source_info()?.scope;
1108-
let inlined_parent = frame.body.source_scopes[scope].inlined_parent_scope?;
1109-
let source = &frame.body.source_scopes[inlined_parent];
1108+
let inlined_parent = frame.body().source_scopes[scope].inlined_parent_scope?;
1109+
let source = &frame.body().source_scopes[inlined_parent];
11101110
source.inlined.expect("inlined_parent_scope points to scope without inline info").0
11111111
};
11121112
// Fall back to the instance of the function itself.
1113-
let instance = instance.unwrap_or(frame.instance);
1113+
let instance = instance.unwrap_or(frame.instance());
11141114
// Now check the crate it is in. We could try to be clever here and e.g. check if this is
11151115
// the same crate as `start_fn`, but that would not work for running std tests in Miri, so
11161116
// we'd need some more hacks anyway. So we just check the name of the crate. If someone
@@ -1350,9 +1350,9 @@ impl<'tcx> MiriMachine<'tcx> {
13501350

13511351
/// This is the source of truth for the `is_user_relevant` flag in our `FrameExtra`.
13521352
pub fn is_user_relevant(&self, frame: &Frame<'tcx, Provenance>) -> bool {
1353-
let def_id = frame.instance.def_id();
1353+
let def_id = frame.instance().def_id();
13541354
(def_id.is_local() || self.local_crates.contains(&def_id.krate))
1355-
&& !frame.instance.def.requires_caller_location(self.tcx)
1355+
&& !frame.instance().def.requires_caller_location(self.tcx)
13561356
}
13571357
}
13581358

src/machine.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1352,7 +1352,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
13521352
) -> InterpResult<'tcx, Frame<'tcx, Provenance, FrameExtra<'tcx>>> {
13531353
// Start recording our event before doing anything else
13541354
let timing = if let Some(profiler) = ecx.machine.profiler.as_ref() {
1355-
let fn_name = frame.instance.to_string();
1355+
let fn_name = frame.instance().to_string();
13561356
let entry = ecx.machine.string_cache.entry(fn_name.clone());
13571357
let name = entry.or_insert_with(|| profiler.alloc_string(&*fn_name));
13581358

@@ -1443,7 +1443,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
14431443
// tracing-tree can autoamtically annotate scope changes, but it gets very confused by our
14441444
// concurrency and what it prints is just plain wrong. So we print our own information
14451445
// instead. (Cc https://github.com/rust-lang/miri/issues/2266)
1446-
info!("Leaving {}", ecx.frame().instance);
1446+
info!("Leaving {}", ecx.frame().instance());
14471447
Ok(())
14481448
}
14491449

@@ -1473,7 +1473,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
14731473
// Needs to be done after dropping frame to show up on the right nesting level.
14741474
// (Cc https://github.com/rust-lang/miri/issues/2266)
14751475
if !ecx.active_thread_stack().is_empty() {
1476-
info!("Continuing in {}", ecx.frame().instance);
1476+
info!("Continuing in {}", ecx.frame().instance());
14771477
}
14781478
res
14791479
}
@@ -1486,7 +1486,7 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
14861486
let Some(Provenance::Concrete { alloc_id, .. }) = mplace.ptr().provenance else {
14871487
panic!("after_local_allocated should only be called on fresh allocations");
14881488
};
1489-
let local_decl = &ecx.frame().body.local_decls[local];
1489+
let local_decl = &ecx.frame().body().local_decls[local];
14901490
let span = local_decl.source_info.span;
14911491
ecx.machine.allocation_spans.borrow_mut().insert(alloc_id, (span, None));
14921492
Ok(())

src/shims/backtrace.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
4646
let mut data = Vec::new();
4747
for frame in this.active_thread_stack().iter().rev() {
4848
// Match behavior of debuginfo (`FunctionCx::adjusted_span_and_dbg_scope`).
49-
let span = hygiene::walk_chain_collapsed(frame.current_span(), frame.body.span);
50-
data.push((frame.instance, span.lo()));
49+
let span = hygiene::walk_chain_collapsed(frame.current_span(), frame.body().span);
50+
data.push((frame.instance(), span.lo()));
5151
}
5252

5353
let ptrs: Vec<_> = data

src/shims/panic.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
4848
fn handle_miri_start_unwind(&mut self, payload: &OpTy<'tcx>) -> InterpResult<'tcx> {
4949
let this = self.eval_context_mut();
5050

51-
trace!("miri_start_unwind: {:?}", this.frame().instance);
51+
trace!("miri_start_unwind: {:?}", this.frame().instance());
5252

5353
let payload = this.read_immediate(payload)?;
5454
let thread = this.active_thread_mut();
@@ -124,7 +124,7 @@ pub trait EvalContextExt<'tcx>: crate::MiriInterpCxExt<'tcx> {
124124
// and we are unwinding, so we should catch that.
125125
trace!(
126126
"unwinding: found catch_panic frame during unwinding: {:?}",
127-
this.frame().instance
127+
this.frame().instance()
128128
);
129129

130130
// We set the return value of `try` to 1, since there was a panic.

0 commit comments

Comments
 (0)