diff --git a/compiler/rustc_arena/src/lib.rs b/compiler/rustc_arena/src/lib.rs index de1d5c07f50..62995dfd2e2 100644 --- a/compiler/rustc_arena/src/lib.rs +++ b/compiler/rustc_arena/src/lib.rs @@ -217,6 +217,8 @@ impl TypedArena { #[inline] fn can_allocate(&self, additional: usize) -> bool { + // FIXME: this should *likely* use `offset_from`, but more + // investigation is needed (including running tests in miri). let available_bytes = self.end.get().addr() - self.ptr.get().addr(); let additional_bytes = additional.checked_mul(mem::size_of::()).unwrap(); available_bytes >= additional_bytes @@ -263,6 +265,8 @@ impl TypedArena { // If a type is `!needs_drop`, we don't need to keep track of how many elements // the chunk stores - the field will be ignored anyway. if mem::needs_drop::() { + // FIXME: this should *likely* use `offset_from`, but more + // investigation is needed (including running tests in miri). let used_bytes = self.ptr.get().addr() - last_chunk.start().addr(); last_chunk.entries = used_bytes / mem::size_of::(); } @@ -300,6 +304,8 @@ impl TypedArena { // Recall that `end` was incremented for each allocated value. end - start } else { + // FIXME: this should *likely* use `offset_from`, but more + // investigation is needed (including running tests in miri). (end - start) / mem::size_of::() }; // Pass that to the `destroy` method. diff --git a/library/core/src/slice/sort.rs b/library/core/src/slice/sort.rs index 5cf08b5740e..1f392a07971 100644 --- a/library/core/src/slice/sort.rs +++ b/library/core/src/slice/sort.rs @@ -269,6 +269,8 @@ where // Returns the number of elements between pointers `l` (inclusive) and `r` (exclusive). fn width(l: *mut T, r: *mut T) -> usize { assert!(mem::size_of::() > 0); + // FIXME: this should *likely* use `offset_from`, but more + // investigation is needed (including running tests in miri). (r.addr() - l.addr()) / mem::size_of::() } diff --git a/library/std/src/sys/unix/memchr.rs b/library/std/src/sys/unix/memchr.rs index a3e4f8ff56a..73ba604eccb 100644 --- a/library/std/src/sys/unix/memchr.rs +++ b/library/std/src/sys/unix/memchr.rs @@ -26,6 +26,8 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option { haystack.len(), ) }; + // FIXME: this should *likely* use `offset_from`, but more + // investigation is needed (including running tests in miri). if p.is_null() { None } else { Some(p.addr() - haystack.as_ptr().addr()) } }