Skip to content

Commit 28576e9

Browse files
committed
mark FIXMES for all the places found that are probably offset_from
1 parent 5f720fa commit 28576e9

File tree

3 files changed

+10
-0
lines changed

3 files changed

+10
-0
lines changed

compiler/rustc_arena/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,8 @@ impl<T> TypedArena<T> {
217217

218218
#[inline]
219219
fn can_allocate(&self, additional: usize) -> bool {
220+
// FIXME: this should *likely* use `offset_from`, but more
221+
// investigation is needed (including running tests in miri).
220222
let available_bytes = self.end.get().addr() - self.ptr.get().addr();
221223
let additional_bytes = additional.checked_mul(mem::size_of::<T>()).unwrap();
222224
available_bytes >= additional_bytes
@@ -263,6 +265,8 @@ impl<T> TypedArena<T> {
263265
// If a type is `!needs_drop`, we don't need to keep track of how many elements
264266
// the chunk stores - the field will be ignored anyway.
265267
if mem::needs_drop::<T>() {
268+
// FIXME: this should *likely* use `offset_from`, but more
269+
// investigation is needed (including running tests in miri).
266270
let used_bytes = self.ptr.get().addr() - last_chunk.start().addr();
267271
last_chunk.entries = used_bytes / mem::size_of::<T>();
268272
}
@@ -300,6 +304,8 @@ impl<T> TypedArena<T> {
300304
// Recall that `end` was incremented for each allocated value.
301305
end - start
302306
} else {
307+
// FIXME: this should *likely* use `offset_from`, but more
308+
// investigation is needed (including running tests in miri).
303309
(end - start) / mem::size_of::<T>()
304310
};
305311
// Pass that to the `destroy` method.

library/core/src/slice/sort.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,8 @@ where
269269
// Returns the number of elements between pointers `l` (inclusive) and `r` (exclusive).
270270
fn width<T>(l: *mut T, r: *mut T) -> usize {
271271
assert!(mem::size_of::<T>() > 0);
272+
// FIXME: this should *likely* use `offset_from`, but more
273+
// investigation is needed (including running tests in miri).
272274
(r.addr() - l.addr()) / mem::size_of::<T>()
273275
}
274276

library/std/src/sys/unix/memchr.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ pub fn memrchr(needle: u8, haystack: &[u8]) -> Option<usize> {
2626
haystack.len(),
2727
)
2828
};
29+
// FIXME: this should *likely* use `offset_from`, but more
30+
// investigation is needed (including running tests in miri).
2931
if p.is_null() { None } else { Some(p.addr() - haystack.as_ptr().addr()) }
3032
}
3133

0 commit comments

Comments
 (0)