From 53ed3b79562fdbcbb1ca073cb48a6fea1e23d51a Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Thu, 15 Nov 2018 13:25:22 +0100 Subject: [PATCH] make memory allocation hook infallible --- src/librustc/mir/interpret/allocation.rs | 6 +++--- src/librustc_mir/interpret/memory.rs | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs index b1e92ef4b511..d6c740794d51 100644 --- a/src/librustc/mir/interpret/allocation.rs +++ b/src/librustc/mir/interpret/allocation.rs @@ -59,7 +59,7 @@ pub trait AllocationExtra: ::std::fmt::Debug + Clone { fn memory_allocated( _size: Size, _memory_extra: &MemoryExtra - ) -> EvalResult<'tcx, Self>; + ) -> Self; /// Hook for performing extra checks on a memory read access. /// @@ -102,8 +102,8 @@ impl AllocationExtra<(), ()> for () { fn memory_allocated( _size: Size, _memory_extra: &() - ) -> EvalResult<'tcx, Self> { - Ok(()) + ) -> Self { + () } } diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index b52feb41370d..5c293bac74ad 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -143,7 +143,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { align: Align, kind: MemoryKind, ) -> EvalResult<'tcx, Pointer> { - let extra = AllocationExtra::memory_allocated(size, &self.extra)?; + let extra = AllocationExtra::memory_allocated(size, &self.extra); Ok(Pointer::from(self.allocate_with(Allocation::undef(size, align, extra), kind)?)) }