add warn(unsafe_op_in_unsafe_fn)

This commit is contained in:
Dustin J. Mitchell 2022-01-31 19:57:05 +00:00
parent ce45c1004c
commit 2dc9358085
2 changed files with 7 additions and 3 deletions

View file

@ -1,3 +1,4 @@
#[warn(unsafe_op_in_unsafe_fn)]
pub mod replica;
pub mod result;
pub mod status;

View file

@ -26,17 +26,20 @@ impl TCReplica {
/// the lifetime promised by C.
pub(crate) unsafe fn from_arg_ref<'a>(tcreplica: *mut TCReplica) -> &'a mut Self {
debug_assert!(!tcreplica.is_null());
&mut *tcreplica
// SAFETY: see doc comment
unsafe { &mut *tcreplica }
}
/// Take a TCReplica from C as an argument.
///
/// # Safety
///
/// The pointer must not be NULL. The pointer becomes invalid before this function returns.
/// The pointer must not be NULL and must point to a valid replica. The pointer becomes
/// invalid before this function returns and must not be used afterward.
pub(crate) unsafe fn from_arg(tcreplica: *mut TCReplica) -> Self {
debug_assert!(!tcreplica.is_null());
*Box::from_raw(tcreplica)
// SAFETY: see doc comment
unsafe { *Box::from_raw(tcreplica) }
}
/// Convert this to a return value for handing off to C.