From b79f6ac69dec0a6fa807a85d6a3172ec87466637 Mon Sep 17 00:00:00 2001 From: Kenny Kerr Date: Wed, 13 Sep 2023 11:01:02 -0500 Subject: [PATCH] new clippy issues --- crates/libs/core/src/array.rs | 2 ++ crates/libs/core/src/com_interface.rs | 2 +- crates/libs/core/src/interface.rs | 3 ++- crates/libs/core/src/strings/bstr.rs | 2 ++ crates/libs/core/src/type.rs | 1 + 5 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/libs/core/src/array.rs b/crates/libs/core/src/array.rs index 0ea6a85e2a..92de007192 100644 --- a/crates/libs/core/src/array.rs +++ b/crates/libs/core/src/array.rs @@ -103,6 +103,8 @@ impl> Array { #[doc(hidden)] /// Get a mutable pointer to the array's length /// + /// # Safety + /// /// This function is safe but writing to the pointer is not. Calling this without /// a subsequent call to `set_abi` is likely to either leak memory or cause UB pub unsafe fn set_abi_len(&mut self) -> *mut u32 { diff --git a/crates/libs/core/src/com_interface.rs b/crates/libs/core/src/com_interface.rs index 3c60345218..5eae5a1e9c 100644 --- a/crates/libs/core/src/com_interface.rs +++ b/crates/libs/core/src/com_interface.rs @@ -41,7 +41,7 @@ pub unsafe trait ComInterface: Interface + Clone { /// Call `QueryInterface` on this interface /// - /// # SAFETY + /// # Safety /// /// `interface` must be a non-null, valid pointer for writing an interface pointer #[doc(hidden)] diff --git a/crates/libs/core/src/interface.rs b/crates/libs/core/src/interface.rs index a39c3f4a2d..602f9dbb7e 100644 --- a/crates/libs/core/src/interface.rs +++ b/crates/libs/core/src/interface.rs @@ -16,7 +16,7 @@ pub unsafe trait Interface: Sized { /// Cast this interface as a reference to the supplied interfaces `Vtable` /// - /// # SAFETY + /// # Safety /// /// This is safe if `T` is an equivalent interface to `Self` or a super interface. /// In other words, `T::Vtable` must be equivalent to the beginning of `Self::Vtable`. @@ -65,6 +65,7 @@ pub unsafe trait Interface: Sized { } } +/// # Safety #[doc(hidden)] pub unsafe fn from_raw_borrowed(raw: &*mut std::ffi::c_void) -> Option<&T> { T::from_raw_borrowed(raw) diff --git a/crates/libs/core/src/strings/bstr.rs b/crates/libs/core/src/strings/bstr.rs index a7cae256c3..63f751c3c3 100644 --- a/crates/libs/core/src/strings/bstr.rs +++ b/crates/libs/core/src/strings/bstr.rs @@ -51,11 +51,13 @@ impl BSTR { } } + /// # Safety #[doc(hidden)] pub unsafe fn from_raw(raw: *const u16) -> Self { Self(raw) } + /// # Safety #[doc(hidden)] pub fn into_raw(self) -> *const u16 { unsafe { std::mem::transmute(self) } diff --git a/crates/libs/core/src/type.rs b/crates/libs/core/src/type.rs index 707b87ac24..c0d5aa5d61 100644 --- a/crates/libs/core/src/type.rs +++ b/crates/libs/core/src/type.rs @@ -103,6 +103,7 @@ primitives!(bool, i8, u8, i16, u16, i32, u32, i64, u64, f32, f64, usize, isize); #[doc(hidden)] pub type AbiType = >::Abi; +/// # Safety #[doc(hidden)] pub unsafe fn from_abi>(abi: T::Abi) -> Result { T::from_abi(abi)