diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index de76064b7cd..ac34de490bb 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -112,7 +112,11 @@ pub struct Frame<'mir, 'tcx: 'mir> { } impl<'a, 'mir, 'tcx: 'mir> HashStable> for Frame<'mir, 'tcx> { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + let Frame { mir, instance, @@ -142,7 +146,10 @@ pub enum StackPopCleanup { } impl<'a> HashStable> for StackPopCleanup { - fn hash_stable(&self, hcx: &mut StableHashingContext<'b>, hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { match self { StackPopCleanup::Goto(ref block) => block.hash_stable(hcx, hasher), StackPopCleanup::None { cleanup } => cleanup.hash_stable(hcx, hasher), diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index fd7324c2d17..0d165ef4803 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -59,7 +59,10 @@ pub enum Place { } impl<'a> HashStable> for Place { - fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) { + fn hash_stable( + &self, hcx: &mut StableHashingContext<'a>, + hasher: &mut StableHasher) { + match self { Place::Ptr(mem_place) => mem_place.hash_stable(hcx, hasher), diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 02b3c696e1f..72cc6220470 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -2,7 +2,10 @@ use std::hash::{Hash, Hasher}; use rustc::ich::{StableHashingContext, StableHashingContextProvider}; use rustc::mir; -use rustc::mir::interpret::{AllocId, Pointer, Scalar, ScalarMaybeUndef, Relocations, Allocation, UndefMask}; +use rustc::mir::interpret::{ + AllocId, Pointer, Scalar, ScalarMaybeUndef, Relocations, Allocation, UndefMask +}; + use rustc::ty; use rustc::ty::layout::Align; use rustc_data_structures::indexed_vec::IndexVec; @@ -29,7 +32,10 @@ macro_rules! __impl_snapshot_field { macro_rules! impl_snapshot_for { // FIXME(mark-i-m): Some of these should be `?` rather than `*`. - (enum $enum_name:ident { $( $variant:ident $( ( $($field:ident $(-> $delegate:expr)*),* ) )* ),* $(,)* }) => { + (enum $enum_name:ident { + $( $variant:ident $( ( $($field:ident $(-> $delegate:expr)*),* ) )* ),* $(,)* + }) => { + impl<'a, Ctx> self::Snapshot<'a, Ctx> for $enum_name where Ctx: self::SnapshotContext<'a>, { @@ -40,7 +46,9 @@ macro_rules! impl_snapshot_for { match *self { $( $enum_name::$variant $( ( $(ref $field),* ) )* => - $enum_name::$variant $( ( $( __impl_snapshot_field!($field, __ctx $(, $delegate)*) ),* ), )* + $enum_name::$variant $( + ( $( __impl_snapshot_field!($field, __ctx $(, $delegate)*) ),* ), + )* )* } } @@ -165,7 +173,9 @@ impl<'a, Ctx> Snapshot<'a, Ctx> for Relocations type Item = Relocations>; fn snapshot(&self, ctx: &'a Ctx) -> Self::Item { - Relocations::from_presorted(self.iter().map(|(size, id)| (*size, id.snapshot(ctx))).collect()) + Relocations::from_presorted(self.iter() + .map(|(size, id)| (*size, id.snapshot(ctx))) + .collect()) } } @@ -268,7 +278,11 @@ pub struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { impl<'a, 'mir, 'tcx, M> EvalSnapshot<'a, 'mir, 'tcx, M> where M: Machine<'mir, 'tcx>, { - pub fn new(machine: &M, memory: &Memory<'a, 'mir, 'tcx, M>, stack: &[Frame<'mir, 'tcx>]) -> Self { + pub fn new( + machine: &M, + memory: &Memory<'a, 'mir, 'tcx, M>, + stack: &[Frame<'mir, 'tcx>]) -> Self { + EvalSnapshot { machine: machine.clone(), memory: memory.clone(), @@ -276,7 +290,8 @@ impl<'a, 'mir, 'tcx, M> EvalSnapshot<'a, 'mir, 'tcx, M> } } - fn snapshot<'b: 'a>(&'b self) -> (&'b M, MemorySnapshot<'b, 'mir, 'tcx, M>, Vec>) { + fn snapshot<'b: 'a>(&'b self) + -> (&'b M, MemorySnapshot<'b, 'mir, 'tcx, M>, Vec>) { let EvalSnapshot{ machine, memory, stack } = self; (&machine, memory.snapshot(), stack.iter().map(|frame| frame.snapshot(memory)).collect()) } @@ -294,10 +309,15 @@ impl<'a, 'mir, 'tcx, M> Hash for EvalSnapshot<'a, 'mir, 'tcx, M> } } -impl<'a, 'b, 'mir, 'tcx, M> HashStable> for EvalSnapshot<'a, 'mir, 'tcx, M> +impl<'a, 'b, 'mir, 'tcx, M> HashStable> + for EvalSnapshot<'a, 'mir, 'tcx, M> where M: Machine<'mir, 'tcx>, { - fn hash_stable(&self, hcx: &mut StableHashingContext<'b>, hasher: &mut StableHasher) { + fn hash_stable( + &self, + hcx: &mut StableHashingContext<'b>, + hasher: &mut StableHasher) { + let EvalSnapshot{ machine, memory, stack } = self; (machine, &memory.data, stack).hash_stable(hcx, hasher); }