Skip to content
forked from rust-lang/rust
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 57c7b80

Browse files
committedNov 10, 2024
elem_offset / subslice_range: use addr() instead of 'as usize'
1 parent 978a553 commit 57c7b80

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed
 

‎core/src/slice/mod.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -4578,8 +4578,8 @@ impl<T> [T] {
45784578
panic!("elements are zero-sized");
45794579
}
45804580

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

45844584
let byte_offset = elem_start.wrapping_sub(self_start);
45854585

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

4634-
let self_start = self.as_ptr() as usize;
4635-
let subslice_start = subslice.as_ptr() as usize;
4634+
let self_start = self.as_ptr().addr();
4635+
let subslice_start = subslice.as_ptr().addr();
46364636

46374637
let byte_start = subslice_start.wrapping_sub(self_start);
46384638

0 commit comments

Comments
 (0)
Failed to load comments.