Skip to content

Commit

Permalink
elem_offset / subslice_range: use addr() instead of 'as usize'
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 10, 2024
1 parent 978a553 commit 57c7b80
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions core/src/slice/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4578,8 +4578,8 @@ impl<T> [T] {
panic!("elements are zero-sized");
}

let self_start = self.as_ptr() as usize;
let elem_start = element as *const T as usize;
let self_start = self.as_ptr().addr();
let elem_start = ptr::from_ref(element).addr();

let byte_offset = elem_start.wrapping_sub(self_start);

Expand Down Expand Up @@ -4631,8 +4631,8 @@ impl<T> [T] {
panic!("elements are zero-sized");
}

let self_start = self.as_ptr() as usize;
let subslice_start = subslice.as_ptr() as usize;
let self_start = self.as_ptr().addr();
let subslice_start = subslice.as_ptr().addr();

let byte_start = subslice_start.wrapping_sub(self_start);

Expand Down

0 comments on commit 57c7b80

Please sign in to comment.