diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs
index 6e144ba7ed2ee7627e74d0b9fd87f5518127f916..467634f28969a544df1751bd1be56ae6bf170653 100644
--- a/src/librustc_mir/interpret/eval_context.rs
+++ b/src/librustc_mir/interpret/eval_context.rs
@@ -196,8 +196,24 @@ pub fn access_mut(&mut self) -> EvalResult<'tcx, &mut Operand> {
}
/// The virtual machine state during const-evaluation at a given point in time.
-type EvalSnapshot<'a, 'mir, 'tcx, M>
- = (M, Vec>, Memory<'a, 'mir, 'tcx, M>);
+#[derive(Eq, PartialEq, Hash)]
+pub(crate) struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
+ machine: M,
+ memory: Memory<'a, 'mir, 'tcx, M>,
+ stack: Vec>,
+}
+
+impl<'a, 'mir, 'tcx, M> EvalSnapshot<'a, 'mir, 'tcx, M>
+ where M: Machine<'mir, 'tcx>,
+{
+ fn new<'b>(machine: &M, memory: &Memory<'a, 'mir, 'tcx, M>, stack: &[Frame<'mir, 'tcx>]) -> Self {
+ EvalSnapshot {
+ machine: machine.clone(),
+ memory: memory.clone(),
+ stack: stack.into(),
+ }
+ }
+}
pub(super) struct InfiniteLoopDetector<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {
/// The set of all `EvalSnapshot` *hashes* observed by this detector.
@@ -238,13 +254,12 @@ pub fn is_empty(&self) -> bool {
pub fn observe_and_analyze(
&mut self,
machine: &M,
- stack: &Vec>,
memory: &Memory<'a, 'mir, 'tcx, M>,
+ stack: &[Frame<'mir, 'tcx>],
) -> EvalResult<'tcx, ()> {
- let snapshot = (machine, stack, memory);
let mut fx = FxHasher::default();
- snapshot.hash(&mut fx);
+ (machine, memory, stack).hash(&mut fx);
let hash = fx.finish();
if self.hashes.insert(hash) {
@@ -252,7 +267,7 @@ pub fn observe_and_analyze(
return Ok(())
}
- if self.snapshots.insert((machine.clone(), stack.clone(), memory.clone())) {
+ if self.snapshots.insert(EvalSnapshot::new(machine, memory, stack)) {
// Spurious collision or first cycle
return Ok(())
}
diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs
index 114ef093ec2fddd90327a2cfcbfe9326b36ad91c..f3d655c2651a9de7f445342ac4eaa38e0c204a4f 100644
--- a/src/librustc_mir/interpret/step.rs
+++ b/src/librustc_mir/interpret/step.rs
@@ -73,7 +73,7 @@ pub fn inc_step_counter_and_detect_loops(&mut self) -> EvalResult<'tcx, ()> {
"Constant evaluating a complex constant, this might take some time");
}
- self.loop_detector.observe_and_analyze(&self.machine, &self.stack, &self.memory)
+ self.loop_detector.observe_and_analyze(&self.machine, &self.memory, &self.stack[..])
}
pub fn run(&mut self) -> EvalResult<'tcx> {