diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-05-13 12:30:40 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-09-11 16:29:41 +0000 |
| commit | 6ad6b4381cb38c7562649deb24374889f1f1b9ae (patch) | |
| tree | 19ef15a23ce96ce640737d5a155518422ecb2c98 /compiler/rustc_const_eval/src | |
| parent | 68c2f5ba0ffb6f7f0724dd62c7562daa634caaec (diff) | |
| download | rust-6ad6b4381cb38c7562649deb24374889f1f1b9ae.tar.gz rust-6ad6b4381cb38c7562649deb24374889f1f1b9ae.zip | |
Support non-scalar constants.
Diffstat (limited to 'compiler/rustc_const_eval/src')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/eval_context.rs | 4 | ||||
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/machine.rs | 10 |
2 files changed, 11 insertions, 3 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index db1eaf58621..3bbafada8f6 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -445,9 +445,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { #[inline(always)] pub fn cur_span(&self) -> Span { - // 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()) + M::cur_span(self) } #[inline(always)] diff --git a/compiler/rustc_const_eval/src/interpret/machine.rs b/compiler/rustc_const_eval/src/interpret/machine.rs index 9fda6b037c8..82aca3d30a2 100644 --- a/compiler/rustc_const_eval/src/interpret/machine.rs +++ b/compiler/rustc_const_eval/src/interpret/machine.rs @@ -11,6 +11,7 @@ use rustc_middle::mir; use rustc_middle::ty::layout::TyAndLayout; use rustc_middle::ty::{self, Ty, TyCtxt}; use rustc_span::def_id::DefId; +use rustc_span::Span; use rustc_target::abi::{Align, Size}; use rustc_target::spec::abi::Abi as CallAbi; @@ -440,6 +441,15 @@ pub trait Machine<'mir, 'tcx: 'mir>: Sized { frame: Frame<'mir, 'tcx, Self::Provenance>, ) -> InterpResult<'tcx, Frame<'mir, 'tcx, Self::Provenance, Self::FrameExtra>>; + 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. fn stack<'a>( ecx: &'a InterpCx<'mir, 'tcx, Self>, |
