Skip to content
Permalink
Browse files

we can now print on entering/leaving the topmost frame, and make sure…

… it stays that way
  • Loading branch information...
RalfJung authored and eddyb committed Feb 7, 2019
1 parent 22d6c55 commit 4653ae1e3e9ce3613844987b43431b35302fb34a
Showing with 13 additions and 16 deletions.
  1. +9 −8 src/librustc_mir/const_eval.rs
  2. +4 −8 src/librustc_mir/interpret/eval_context.rs
@@ -602,14 +602,15 @@ pub fn const_eval_raw_provider<'a, 'tcx>(
other => return other,
}
}
// the first trace is for replicating an ice
// There's no tracking issue, but the next two lines concatenated link to the discussion on
// zulip. It's not really possible to test this, because it doesn't show up in diagnostics
// or MIR.
// https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/
// subject/anon_const_instance_printing/near/135980032
trace!("const eval: {}", key.value.instance);
trace!("const eval: {:?}", key);
if cfg!(debug_assertions) {
// Make sure we format the instance even if we do not print it.
// This serves as a regression test against an ICE on printing.
// The next two lines concatenated contain some discussion:
// https://rust-lang.zulipchat.com/#narrow/stream/146212-t-compiler.2Fconst-eval/
// subject/anon_const_instance_printing/near/135980032
let instance = key.value.instance.to_string();
trace!("const eval: {:?} ({})", key, instance);
}

let cid = key.value;
let def_id = cid.instance.def.def_id();
@@ -450,7 +450,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
return_place: Option<PlaceTy<'tcx, M::PointerTag>>,
return_to_block: StackPopCleanup,
) -> EvalResult<'tcx> {
if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc...
if self.stack.len() > 0 {
info!("PAUSING({}) {}", self.cur_frame(), self.frame().instance);
}
::log_settings::settings().indentation += 1;
@@ -525,9 +525,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
self.frame_mut().locals = locals;
}

if self.stack.len() > 1 { // FIXME no check should be needed, but some instances ICE
info!("ENTERING({}) {}", self.cur_frame(), self.frame().instance);
}
info!("ENTERING({}) {}", self.cur_frame(), self.frame().instance);

if self.stack.len() > self.tcx.sess.const_eval_stack_frame_limit {
err!(StackFrameLimitReached)
@@ -537,9 +535,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
}

pub(super) fn pop_stack_frame(&mut self) -> EvalResult<'tcx> {
if self.stack.len() > 1 { // FIXME no check should be needed, but some instances ICE
info!("LEAVING({}) {}", self.cur_frame(), self.frame().instance);
}
info!("LEAVING({}) {}", self.cur_frame(), self.frame().instance);
::log_settings::settings().indentation -= 1;
let frame = self.stack.pop().expect(
"tried to pop a stack frame, but there were none",
@@ -591,7 +587,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'a, 'mir, 'tcx>> EvalContext<'a, 'mir, 'tc
StackPopCleanup::None { .. } => {}
}

if self.stack.len() > 1 { // FIXME should be "> 0", printing topmost frame crashes rustc...
if self.stack.len() > 0 {
info!("CONTINUING({}) {}", self.cur_frame(), self.frame().instance);
}

0 comments on commit 4653ae1

Please sign in to comment.
You can’t perform that action at this time.