Skip to content

Commit bcfe1a4

Browse files
committed
Remove cur_span hook.
1 parent 24adf07 commit bcfe1a4

File tree

3 files changed

+6
-19
lines changed

3 files changed

+6
-19
lines changed

compiler/rustc_const_eval/src/interpret/eval_context.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
445445

446446
#[inline(always)]
447447
pub fn cur_span(&self) -> Span {
448-
M::cur_span(self)
448+
// This deliberately does *not* honor `requires_caller_location` since it is used for much
449+
// more than just panics.
450+
self.stack().last().map_or(self.tcx.span, |f| f.current_span())
449451
}
450452

451453
#[inline(always)]

compiler/rustc_const_eval/src/interpret/machine.rs

-11
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ use rustc_middle::mir;
1111
use rustc_middle::ty::layout::TyAndLayout;
1212
use rustc_middle::ty::{self, Ty, TyCtxt};
1313
use rustc_span::def_id::DefId;
14-
use rustc_span::Span;
1514
use rustc_target::abi::{Align, Size};
1615
use rustc_target::spec::abi::Abi as CallAbi;
1716

@@ -441,16 +440,6 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
441440
frame: Frame<'mir, 'tcx, Self::Provenance>,
442441
) -> InterpResult<'tcx, Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>>;
443442

444-
#[inline(always)]
445-
fn cur_span(ecx: &InterpCx<'mir, 'tcx, Self>) -> Span
446-
where
447-
'tcx: 'mir,
448-
{
449-
// This deliberately does *not* honor `requires_caller_location` since it is used for much
450-
// more than just panics.
451-
Self::stack(ecx).last().map_or(ecx.tcx.span, |f| f.current_span())
452-
}
453-
454443
/// Borrow the current thread's stack.
455444
fn stack<'a>(
456445
ecx: &'a InterpCx<'mir, 'tcx, Self>,

compiler/rustc_mir_transform/src/dataflow_const_prop.rs

+3-7
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use rustc_mir_dataflow::value_analysis::{
1616
};
1717
use rustc_mir_dataflow::{lattice::FlatSet, Analysis, Results, ResultsVisitor};
1818
use rustc_span::def_id::DefId;
19-
use rustc_span::{Span, DUMMY_SP};
19+
use rustc_span::DUMMY_SP;
2020
use rustc_target::abi::{Align, FieldIdx, VariantIdx};
2121

2222
use crate::MirPass;
@@ -689,11 +689,6 @@ impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for Dumm
689689
type MemoryKind = !;
690690
const PANIC_ON_ALLOC_FAIL: bool = true;
691691

692-
#[inline(always)]
693-
fn cur_span(_ecx: &InterpCx<'mir, 'tcx, Self>) -> Span {
694-
DUMMY_SP
695-
}
696-
697692
#[inline(always)]
698693
fn enforce_alignment(_ecx: &InterpCx<'mir, 'tcx, Self>) -> CheckAlignment {
699694
// We do not check for alignment to avoid having to carry an `Align`
@@ -802,7 +797,8 @@ impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for Dumm
802797
_ecx: &'a InterpCx<'mir, 'tcx, Self>,
803798
) -> &'a [rustc_const_eval::interpret::Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>]
804799
{
805-
unimplemented!()
800+
// Return an empty stack instead of panicking, as `cur_span` uses it to evaluate constants.
801+
&[]
806802
}
807803

808804
fn stack_mut<'a>(

0 commit comments

Comments
 (0)