Skip to content

Commit cec8769

Browse files
committed
Directly pass in the stack instead of computing it from a machine
1 parent 9b4439b commit cec8769

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

compiler/rustc_const_eval/src/const_eval/error.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ use std::mem;
22

33
use rustc_errors::{DiagArgName, DiagArgValue, DiagMessage, Diagnostic, IntoDiagArg};
44
use rustc_hir::CRATE_HIR_ID;
5+
use rustc_middle::mir::interpret::Provenance;
56
use rustc_middle::mir::AssertKind;
67
use rustc_middle::query::TyCtxtAt;
78
use rustc_middle::ty::TyCtxt;
@@ -58,12 +59,12 @@ impl<'tcx> Into<InterpErrorInfo<'tcx>> for ConstEvalErrKind {
5859

5960
pub fn get_span_and_frames<'tcx, 'mir>(
6061
tcx: TyCtxtAt<'tcx>,
61-
machine: &CompileTimeInterpreter<'mir, 'tcx>,
62+
stack: &[Frame<'mir, 'tcx, impl Provenance, impl Sized>],
6263
) -> (Span, Vec<errors::FrameNote>)
6364
where
6465
'tcx: 'mir,
6566
{
66-
let mut stacktrace = Frame::generate_stacktrace_from_stack(&machine.stack);
67+
let mut stacktrace = Frame::generate_stacktrace_from_stack(stack);
6768
// Filter out `requires_caller_location` frames.
6869
stacktrace.retain(|frame| !frame.instance.def.requires_caller_location(*tcx));
6970
let span = stacktrace.first().map(|f| f.span).unwrap_or(tcx.span);
@@ -167,7 +168,7 @@ pub(super) fn lint<'tcx, 'mir, L>(
167168
) where
168169
L: for<'a> rustc_errors::LintDiagnostic<'a, ()>,
169170
{
170-
let (span, frames) = get_span_and_frames(tcx, machine);
171+
let (span, frames) = get_span_and_frames(tcx, &machine.stack);
171172

172173
tcx.emit_node_span_lint(
173174
lint,

compiler/rustc_const_eval/src/const_eval/eval_queries.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ fn eval_in_interpreter<'mir, 'tcx, R: InterpretationResult<'tcx>>(
382382
*ecx.tcx,
383383
error,
384384
None,
385-
|| super::get_span_and_frames(ecx.tcx, &ecx.machine),
385+
|| super::get_span_and_frames(ecx.tcx, ecx.stack()),
386386
|span, frames| ConstEvalError {
387387
span,
388388
error_kind: kind,
@@ -447,7 +447,7 @@ pub fn const_report_error<'mir, 'tcx>(
447447
*ecx.tcx,
448448
error,
449449
None,
450-
|| crate::const_eval::get_span_and_frames(ecx.tcx, &ecx.machine),
450+
|| crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()),
451451
move |span, frames| errors::UndefinedBehavior { span, ub_note, frames, raw_bytes },
452452
)
453453
}

0 commit comments

Comments
 (0)