mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
interpret: expose generate_stacktrace without full InterpCx
This commit is contained in:
parent
a29f341a8a
commit
9fa3171015
@ -929,11 +929,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn generate_stacktrace(&self) -> Vec<FrameInfo<'tcx>> {
|
||||
pub fn generate_stacktrace_from_stack(
|
||||
stack: &[Frame<'mir, 'tcx, M::Provenance, M::FrameExtra>],
|
||||
) -> Vec<FrameInfo<'tcx>> {
|
||||
let mut frames = Vec::new();
|
||||
// This deliberately does *not* honor `requires_caller_location` since it is used for much
|
||||
// more than just panics.
|
||||
for frame in self.stack().iter().rev() {
|
||||
for frame in stack.iter().rev() {
|
||||
let lint_root = frame.current_source_info().and_then(|source_info| {
|
||||
match &frame.body.source_scopes[source_info.scope].local_data {
|
||||
mir::ClearCrossCrate::Set(data) => Some(data.lint_root),
|
||||
@ -947,6 +949,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
||||
trace!("generate stacktrace: {:#?}", frames);
|
||||
frames
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn generate_stacktrace(&self) -> Vec<FrameInfo<'tcx>> {
|
||||
Self::generate_stacktrace_from_stack(self.stack())
|
||||
}
|
||||
}
|
||||
|
||||
#[doc(hidden)]
|
||||
|
Loading…
Reference in New Issue
Block a user