Remove cur_span hook.

This commit is contained in:
Camille GILLOT
2023-09-09 16:41:57 +00:00
parent 24adf07e5f
commit bcfe1a4bf2
3 changed files with 6 additions and 19 deletions

View File

@@ -445,7 +445,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
#[inline(always)] #[inline(always)]
pub fn cur_span(&self) -> Span { pub fn cur_span(&self) -> Span {
M::cur_span(self) // This deliberately does *not* honor `requires_caller_location` since it is used for much
// more than just panics.
self.stack().last().map_or(self.tcx.span, |f| f.current_span())
} }
#[inline(always)] #[inline(always)]

View File

@@ -11,7 +11,6 @@ use rustc_middle::mir;
use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::layout::TyAndLayout;
use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_middle::ty::{self, Ty, TyCtxt};
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_span::Span;
use rustc_target::abi::{Align, Size}; use rustc_target::abi::{Align, Size};
use rustc_target::spec::abi::Abi as CallAbi; use rustc_target::spec::abi::Abi as CallAbi;
@@ -441,16 +440,6 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized {
frame: Frame<'mir, 'tcx, Self::Provenance>, frame: Frame<'mir, 'tcx, Self::Provenance>,
) -> InterpResult<'tcx, Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>>; ) -> InterpResult<'tcx, Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>>;
#[inline(always)]
fn cur_span(ecx: &InterpCx<'mir, 'tcx, Self>) -> Span
where
'tcx: 'mir,
{
// This deliberately does *not* honor `requires_caller_location` since it is used for much
// more than just panics.
Self::stack(ecx).last().map_or(ecx.tcx.span, |f| f.current_span())
}
/// Borrow the current thread's stack. /// Borrow the current thread's stack.
fn stack<'a>( fn stack<'a>(
ecx: &'a InterpCx<'mir, 'tcx, Self>, ecx: &'a InterpCx<'mir, 'tcx, Self>,

View File

@@ -16,7 +16,7 @@ use rustc_mir_dataflow::value_analysis::{
}; };
use rustc_mir_dataflow::{lattice::FlatSet, Analysis, Results, ResultsVisitor}; use rustc_mir_dataflow::{lattice::FlatSet, Analysis, Results, ResultsVisitor};
use rustc_span::def_id::DefId; use rustc_span::def_id::DefId;
use rustc_span::{Span, DUMMY_SP}; use rustc_span::DUMMY_SP;
use rustc_target::abi::{Align, FieldIdx, VariantIdx}; use rustc_target::abi::{Align, FieldIdx, VariantIdx};
use crate::MirPass; use crate::MirPass;
@@ -689,11 +689,6 @@ impl<'mir, 'tcx: 'mir> rustc_const_eval::interpret::Machine<'mir, 'tcx> for Dumm
type MemoryKind = !; type MemoryKind = !;
const PANIC_ON_ALLOC_FAIL: bool = true; const PANIC_ON_ALLOC_FAIL: bool = true;
#[inline(always)]
fn cur_span(_ecx: &InterpCx<'mir, 'tcx, Self>) -> Span {
DUMMY_SP
}
#[inline(always)] #[inline(always)]
fn enforce_alignment(_ecx: &InterpCx<'mir, 'tcx, Self>) -> CheckAlignment { fn enforce_alignment(_ecx: &InterpCx<'mir, 'tcx, Self>) -> CheckAlignment {
// We do not check for alignment to avoid having to carry an `Align` // 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
_ecx: &'a InterpCx<'mir, 'tcx, Self>, _ecx: &'a InterpCx<'mir, 'tcx, Self>,
) -> &'a [rustc_const_eval::interpret::Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>] ) -> &'a [rustc_const_eval::interpret::Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>]
{ {
unimplemented!() // Return an empty stack instead of panicking, as `cur_span` uses it to evaluate constants.
&[]
} }
fn stack_mut<'a>( fn stack_mut<'a>(