From bf6ba974dede851b59afb9aa031ce0c548b754c4 Mon Sep 17 00:00:00 2001 From: Bruno Dutra Date: Sat, 18 Aug 2018 12:32:37 +0200 Subject: [PATCH] Impl SnapshotContext for Memory --- src/librustc_mir/interpret/snapshot.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/librustc_mir/interpret/snapshot.rs b/src/librustc_mir/interpret/snapshot.rs index 2bb184cd9bc..d23122825aa 100644 --- a/src/librustc_mir/interpret/snapshot.rs +++ b/src/librustc_mir/interpret/snapshot.rs @@ -269,6 +269,16 @@ struct MemorySnapshot<'a, 'mir: 'a, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx> + 'a data: &'a M::MemoryData, } +impl<'a, 'b, 'mir, 'tcx, M> SnapshotContext<'b> for Memory<'a, 'mir, 'tcx, M> + where M: Machine<'mir, 'tcx>, +{ + type To = Allocation; + type From = AllocId; + fn resolve(&'b self, id: &Self::From) -> Option<&'b Self::To> { + self.get(*id).ok() + } +} + /// The virtual machine state during const-evaluation at a given point in time. #[derive(Eq, PartialEq)] pub struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> {