about summary refs log tree commit diff
diff options
context:
space:
mode:
authorBruno Dutra <brunocodutra@gmail.com>2018-09-03 20:03:14 +0200
committerBruno Dutra <brunocodutra@gmail.com>2018-09-03 20:03:14 +0200
commit05cdf8dc3d490fbec2519de90b254f47ec7373e8 (patch)
tree153fcc2d7845009a285eb63705fdc7434df98e80
parent61a999a531d03c73626716e2b48d259e13f3b6af (diff)
downloadrust-05cdf8dc3d490fbec2519de90b254f47ec7373e8.tar.gz
rust-05cdf8dc3d490fbec2519de90b254f47ec7373e8.zip
Document snapshot.rs
-rw-r--r--src/librustc/mir/interpret/mod.rs5
-rw-r--r--src/librustc_mir/interpret/snapshot.rs6
2 files changed, 11 insertions, 0 deletions
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<T: layout::HasDataLayout> 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<Id=AllocId> {
     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;