Skip to content

Commit 6b28835

Browse files
committed
Address potential future UB by only using raw pointers
rust-lang/unsafe-code-guidelines#346
1 parent 1ce75c1 commit 6b28835

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/raw/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1330,11 +1330,12 @@ impl<T, A: Allocator> RawTable<T, A> {
13301330
) -> [Option<NonNull<T>>; N] {
13311331
// TODO use `MaybeUninit::uninit_array` here instead once that's stable.
13321332
let mut outs: MaybeUninit<[Option<NonNull<T>>; N]> = MaybeUninit::uninit();
1333-
let outs_ptr = outs.as_mut_ptr();
1333+
// TODO use `*mut [T; N]::as_mut_ptr` here instead once that's stable.
1334+
let outs_ptr = outs.as_mut_ptr() as *mut Option<NonNull<T>>;
13341335

13351336
for (i, &hash) in hashes.iter().enumerate() {
13361337
let cur = self.find(hash, |k| eq(i, k)).map(|cur| cur.as_non_null());
1337-
*(*outs_ptr).get_unchecked_mut(i) = cur;
1338+
outs_ptr.add(i).write(cur);
13381339
}
13391340

13401341
outs.assume_init()

0 commit comments

Comments
 (0)