diff options
| author | Dylan DPC <99973273+Dylan-DPC@users.noreply.github.com> | 2022-06-29 10:28:23 +0530 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-29 10:28:23 +0530 |
| commit | 021d21c88877bb8f5db8326ebfdb1baad64b1e70 (patch) | |
| tree | 8f771af4019503b233c959d674df90929c23c353 /compiler/rustc_const_eval/src/interpret | |
| parent | b8bb6f9a4bdd246891758612c98c5a11d5aad76b (diff) | |
| parent | 852a111133c86b24b190d6f9b5e19f8864e954a2 (diff) | |
| download | rust-021d21c88877bb8f5db8326ebfdb1baad64b1e70.tar.gz rust-021d21c88877bb8f5db8326ebfdb1baad64b1e70.zip | |
Rollup merge of #98549 - RalfJung:interpret-stacktraces, r=oli-obk
interpret: do not prune requires_caller_location stack frames quite so early https://github.com/rust-lang/rust/pull/87000 made the interpreter skip `caller_location` frames for its stacktraces and `cur_span`. However, those functions are used for much more than just panic reporting, and e.g. when Miri reports UB somewhere, it probably wants to point inside `caller_location` frames. (And if it did not, it would want to have its own logic to decide that, not be forced into it by the core interpreter engine.) This fixes some rare ICEs in Miri that say "we should never pop more than one frame at once". So let's remove all `caller_location` logic from the core interpreter, and instead move it to CTFE error reporting. This does not change user-visible behavior. That's the first commit. We might additionally want to change CTFE error reporting to treat panics differently from other errors: only prune `caller_location` frames for panics. The second commit does that. But honestly I am not sure if this is an improvement. r? ``@oli-obk``
Diffstat (limited to 'compiler/rustc_const_eval/src/interpret')
| -rw-r--r-- | compiler/rustc_const_eval/src/interpret/eval_context.rs | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/compiler/rustc_const_eval/src/interpret/eval_context.rs b/compiler/rustc_const_eval/src/interpret/eval_context.rs index 1c1bbd370bd..66c73624501 100644 --- a/compiler/rustc_const_eval/src/interpret/eval_context.rs +++ b/compiler/rustc_const_eval/src/interpret/eval_context.rs @@ -428,11 +428,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { #[inline(always)] pub fn cur_span(&self) -> Span { - self.stack() - .iter() - .rev() - .find(|frame| !frame.instance.def.requires_caller_location(*self.tcx)) - .map_or(self.tcx.span, |f| f.current_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()) } #[inline(always)] @@ -939,12 +937,9 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> { #[must_use] pub fn generate_stacktrace(&self) -> Vec<FrameInfo<'tcx>> { let mut frames = Vec::new(); - for frame in self - .stack() - .iter() - .rev() - .skip_while(|frame| frame.instance.def.requires_caller_location(*self.tcx)) - { + // This deliberately does *not* honor `requires_caller_location` since it is used for much + // more than just panics. + for frame in self.stack().iter().rev() { let lint_root = frame.current_source_info().and_then(|source_info| { match &frame.body.source_scopes[source_info.scope].local_data { mir::ClearCrossCrate::Set(data) => Some(data.lint_root), |
