From 05cdf8dc3d490fbec2519de90b254f47ec7373e8 Mon Sep 17 00:00:00 2001 From: Bruno Dutra Date: Mon, 3 Sep 2018 20:03:14 +0200 Subject: Document snapshot.rs --- src/librustc/mir/interpret/mod.rs | 5 +++++ src/librustc_mir/interpret/snapshot.rs | 6 ++++++ 2 files changed, 11 insertions(+) (limited to 'src') diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 9b7087ca034..ccc5bba1ad6 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -133,6 +133,11 @@ pub trait PointerArithmetic: layout::HasDataLayout { impl PointerArithmetic for T {} +/// Pointer is generic over the type that represents a reference to Allocations, +/// thus making it possible for the most convenient representation to be used in +/// each context. +/// +/// Defaults to the index based and loosely coupled AllocId. #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] pub struct Pointer { pub alloc_id: Id, diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 316c80d18c1..8aa053baae9 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -1,3 +1,7 @@ +//! This module contains the machinery necessary to detect infinite loops +//! during const-evaluation by taking snapshots of the state of the interpreter +//! at regular intervals. + use std::hash::{Hash, Hasher}; use rustc::ich::{StableHashingContext, StableHashingContextProvider}; @@ -89,6 +93,8 @@ trait SnapshotContext<'a> { fn resolve(&'a self, id: &AllocId) -> Option<&'a Allocation>; } +/// Taking a snapshot of the evaluation context produces a view of +/// the state of the interpreter that is invariant to `AllocId`s. trait Snapshot<'a, Ctx: SnapshotContext<'a>> { type Item; fn snapshot(&self, ctx: &'a Ctx) -> Self::Item; -- cgit 1.4.1-3-g733a5