Skip to content

Commit 05cdf8d

Browse files
committedSep 3, 2018
Document snapshot.rs
1 parent 61a999a commit 05cdf8d

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed
 

Diff for: ‎src/librustc/mir/interpret/mod.rs

+5
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,11 @@ pub trait PointerArithmetic: layout::HasDataLayout {
133133
impl<T: layout::HasDataLayout> PointerArithmetic for T {}
134134

135135

136+
/// Pointer is generic over the type that represents a reference to Allocations,
137+
/// thus making it possible for the most convenient representation to be used in
138+
/// each context.
139+
///
140+
/// Defaults to the index based and loosely coupled AllocId.
136141
#[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)]
137142
pub struct Pointer<Id=AllocId> {
138143
pub alloc_id: Id,

Diff for: ‎src/librustc_mir/interpret/snapshot.rs

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
//! This module contains the machinery necessary to detect infinite loops
2+
//! during const-evaluation by taking snapshots of the state of the interpreter
3+
//! at regular intervals.
4+
15
use std::hash::{Hash, Hasher};
26

37
use rustc::ich::{StableHashingContext, StableHashingContextProvider};
@@ -89,6 +93,8 @@ trait SnapshotContext<'a> {
8993
fn resolve(&'a self, id: &AllocId) -> Option<&'a Allocation>;
9094
}
9195

96+
/// Taking a snapshot of the evaluation context produces a view of
97+
/// the state of the interpreter that is invariant to `AllocId`s.
9298
trait Snapshot<'a, Ctx: SnapshotContext<'a>> {
9399
type Item;
94100
fn snapshot(&self, ctx: &'a Ctx) -> Self::Item;

0 commit comments

Comments
 (0)