Skip to content

Commit

Permalink
Document snapshot.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
brunocodutra committed Sep 3, 2018
1 parent 61a999a commit 05cdf8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/librustc/mir/interpret/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions src/librustc_mir/interpret/snapshot.rs
Original file line number Diff line number Diff line change
@@ -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};
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 05cdf8d

Please sign in to comment.