Skip to content

Commit 30b5bac

Browse files
committed
Directly pass in the stack instead of computing it from a machine
1 parent c8a1e30 commit 30b5bac

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, IntoDiagnostic, IntoDiagnosticArg};
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::DecorateLint<'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
@@ -388,7 +388,7 @@ fn eval_in_interpreter<'mir, 'tcx, R: InterpretationResult<'tcx>>(
388388
*ecx.tcx,
389389
error,
390390
None,
391-
|| super::get_span_and_frames(ecx.tcx, &ecx.machine),
391+
|| super::get_span_and_frames(ecx.tcx, ecx.stack()),
392392
|span, frames| ConstEvalError {
393393
span,
394394
error_kind: kind,
@@ -451,7 +451,7 @@ pub fn const_report_error<'mir, 'tcx>(
451451
*ecx.tcx,
452452
error,
453453
None,
454-
|| crate::const_eval::get_span_and_frames(ecx.tcx, &ecx.machine),
454+
|| crate::const_eval::get_span_and_frames(ecx.tcx, ecx.stack()),
455455
move |span, frames| errors::UndefinedBehavior { span, ub_note, frames, raw_bytes },
456456
)
457457
}

0 commit comments

Comments
 (0)