Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,9 @@ static_assertions = "1.1"
testutil = { path = "testutil" }
# In tests, unlike in production, zerocopy-derive is not optional
zerocopy-derive = { version = "=0.8.39", path = "zerocopy-derive" }

[workspace.lints.clippy]
borrow_as_ptr = "warn"

[lints]
workspace = true
7 changes: 4 additions & 3 deletions src/ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,16 +1234,17 @@ mod tests {
use crate::util::AsAddress as _;

let mut buf = Align::<[u8; 8], u64>::default();
let buf_ptr = buf.t.as_mut_ptr();

let r = Ref::<_, u64>::from_bytes(&buf.t[..]).unwrap();
let rf = Ref::into_ref(r);
assert_eq!(rf, &0u64);
let buf_addr = (&buf.t as *const [u8; 8]).addr();
assert_eq!((rf as *const u64).addr(), buf_addr);
assert_eq!((rf as *const u64).cast(), buf_ptr);

let r = Ref::<_, u64>::from_bytes(&mut buf.t[..]).unwrap();
let rf = Ref::into_mut(r);
assert_eq!(rf, &mut 0u64);
assert_eq!((rf as *mut u64).addr(), buf_addr);
assert_eq!((rf as *mut u64).cast(), buf_ptr);

*rf = u64::MAX;
assert_eq!(buf.t, [0xFF; 8]);
Expand Down
4 changes: 2 additions & 2 deletions src/wrappers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ mod tests {
let uninit = MaybeUninit::new(&input);
// SAFETY: `uninit` is in an initialized state
let output = unsafe { uninit.assume_init() };
assert_eq!(&input as *const _, output as *const _);
assert!(core::ptr::eq(&input, output));
assert_eq!(input, *output);
}

Expand All @@ -1005,7 +1005,7 @@ mod tests {
let uninit = MaybeUninit::new(&input[..]);
// SAFETY: `uninit` is in an initialized state
let output = unsafe { uninit.assume_init() };
assert_eq!(&input[..] as *const _, output as *const _);
assert!(core::ptr::eq(&input[..], output));
assert_eq!(input, *output);
}
}
Expand Down
Loading