]> git.lizzy.rs Git - rust.git/commitdiff
Remove unnecessary `Result` (function always returned `Ok`)
authorOliver Scherer <github35764891676564198441@oli-obk.de>
Tue, 13 Nov 2018 08:44:59 +0000 (09:44 +0100)
committerOliver Scherer <github35764891676564198441@oli-obk.de>
Sat, 24 Nov 2018 10:36:31 +0000 (11:36 +0100)
src/librustc/mir/interpret/allocation.rs
src/librustc_mir/interpret/memory.rs

index 6ef7a5a266d37812a6bca44612ba9901558ac935..42bcd3a90276071b13ed81eb85b91533129a2e59 100644 (file)
@@ -406,12 +406,12 @@ pub fn relocations(
         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 @@ fn check_relocations(
         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 @@ fn clear_relocations(
         // 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(());
             }
index 3119d9ed0ffa33f286a2c11b9f0ba2326a6d8050..896a7a25b5d954e05536fdbb40a6b16528cd44e3 100644 (file)
@@ -655,7 +655,7 @@ pub fn copy_repeatedly(
         // (`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(