about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2018-11-13 09:44:59 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2018-11-24 11:36:31 +0100
commit3a0e8254b06c8a9c8e4b775a18524797f1e3d44c (patch)
tree6c2df8a97f050905595f2e4c4e2b40005439b107
parent07e7804110c77d572012f913a341523bdbaac4dd (diff)
downloadrust-3a0e8254b06c8a9c8e4b775a18524797f1e3d44c.tar.gz
rust-3a0e8254b06c8a9c8e4b775a18524797f1e3d44c.zip
Remove unnecessary `Result` (function always returned `Ok`)
-rw-r--r--src/librustc/mir/interpret/allocation.rs12
-rw-r--r--src/librustc_mir/interpret/memory.rs2
2 files changed, 7 insertions, 7 deletions
diff --git a/src/librustc/mir/interpret/allocation.rs b/src/librustc/mir/interpret/allocation.rs
index 6ef7a5a266d..42bcd3a9027 100644
--- a/src/librustc/mir/interpret/allocation.rs
+++ b/src/librustc/mir/interpret/allocation.rs
@@ -406,12 +406,12 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
         cx: &impl HasDataLayout,
         ptr: Pointer<Tag>,
         size: Size,
-    ) -> EvalResult<'tcx, &[(Size, (Tag, AllocId))]> {
+    ) -> &[(Size, (Tag, AllocId))] {
         // We have to go back `pointer_size - 1` bytes, as that one would still overlap with
         // the beginning of this range.
         let start = ptr.offset.bytes().saturating_sub(cx.data_layout().pointer_size.bytes() - 1);
         let end = ptr.offset + size; // this does overflow checking
-        Ok(self.relocations.range(Size::from_bytes(start)..end))
+        self.relocations.range(Size::from_bytes(start)..end)
     }
 
     /// Check that there ar eno relocations overlapping with the given range.
@@ -422,10 +422,10 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
         ptr: Pointer<Tag>,
         size: Size,
     ) -> EvalResult<'tcx> {
-        if self.relocations(cx, ptr, size)?.len() != 0 {
-            err!(ReadPointerAsBytes)
-        } else {
+        if self.relocations(cx, ptr, size).is_empty() {
             Ok(())
+        } else {
+            err!(ReadPointerAsBytes)
         }
     }
 
@@ -444,7 +444,7 @@ impl<'tcx, Tag: Copy, Extra> Allocation<Tag, Extra> {
         // Find the start and end of the given range and its outermost relocations.
         let (first, last) = {
             // Find all relocations overlapping the given range.
-            let relocations = self.relocations(cx, ptr, size)?;
+            let relocations = self.relocations(cx, ptr, size);
             if relocations.is_empty() {
                 return Ok(());
             }
diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs
index 3119d9ed0ff..896a7a25b5d 100644
--- a/src/librustc_mir/interpret/memory.rs
+++ b/src/librustc_mir/interpret/memory.rs
@@ -655,7 +655,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'a, 'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> {
         // (`get_bytes_with_undef_and_ptr` below checks that there are no
         // relocations overlapping the edges; those would not be handled correctly).
         let relocations = {
-            let relocations = self.get(src.alloc_id)?.relocations(self, src, size)?;
+            let relocations = self.get(src.alloc_id)?.relocations(self, src, size);
             let mut new_relocations = Vec::with_capacity(relocations.len() * (length as usize));
             for i in 0..length {
                 new_relocations.extend(