Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
target
Cargo.lock
/fuzz/hfuzz_target
/.vscode
98 changes: 98 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 6 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ use core::mem::align_of;
use core::mem::size_of;
use core::mem::ManuallyDrop;
use core::mem::MaybeUninit;
use core::ptr::addr_of;
use core::ptr::addr_of_mut;
use core::ptr::copy;
use core::ptr::copy_nonoverlapping;
use core::ptr::NonNull;
Expand Down Expand Up @@ -207,16 +205,16 @@ impl<T, const N: usize> RawSmallVec<T, N> {

#[inline]
const fn as_ptr_inline(&self) -> *const T {
// SAFETY: This is safe because we don't read the value. We only get a pointer to the data.
// Dereferencing the pointer is unsafe so unsafe code is required to misuse the return
// value.
(unsafe { addr_of!(self.inline) }) as *const T
// SAFETY: it is safe because we aren't reading the value, just getting a
// reference to it. reading it would be UB potentially, but for that downstream
// unsafe is required
(unsafe {&raw const self.inline}) as *mut T
}

#[inline]
const fn as_mut_ptr_inline(&mut self) -> *mut T {
// SAFETY: See above.
(unsafe { addr_of_mut!(self.inline) }) as *mut T
// SAFETY: same as above
(unsafe {&raw mut self.inline}) as *mut T
}

/// # Safety
Expand Down
2 changes: 1 addition & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ fn test_invalid_grow() {
#[should_panic]
fn drain_overflow() {
let mut v: SmallVec<u8, 8> = smallvec![0];
v.drain(..=std::usize::MAX);
v.drain(..=usize::MAX);
}

#[test]
Expand Down
Loading