From 3d3eed93af4150ba8876a878bf717f6714ff0a17 Mon Sep 17 00:00:00 2001 From: Simonas Kazlauskas Date: Sat, 20 Jul 2024 13:26:07 +0300 Subject: [PATCH] Address clippy lints --- src/os/unix/mod.rs | 2 +- src/safe.rs | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/os/unix/mod.rs b/src/os/unix/mod.rs index 202a002f1..a575d9aba 100644 --- a/src/os/unix/mod.rs +++ b/src/os/unix/mod.rs @@ -400,7 +400,7 @@ impl Symbol { /// Convert the loaded `Symbol` into a raw pointer. /// For unix this does the same as into_raw. pub fn as_raw_ptr(self) -> *mut raw::c_void { - return self.pointer + self.pointer } } diff --git a/src/safe.rs b/src/safe.rs index b48272582..38d3f4287 100644 --- a/src/safe.rs +++ b/src/safe.rs @@ -1,10 +1,10 @@ -use super::Error; #[cfg(libloading_docs)] use super::os::unix as imp; // the implementation used here doesn't matter particularly much... #[cfg(all(not(libloading_docs), unix))] use super::os::unix as imp; #[cfg(all(not(libloading_docs), windows))] use super::os::windows as imp; +use super::Error; use std::ffi::OsStr; use std::fmt; use std::marker; @@ -260,7 +260,14 @@ impl<'lib, T> Symbol<'lib, T> { /// ensure the resulting `Symbol` is not used past the lifetime of the `Library` this symbol /// was loaded from. pub unsafe fn try_as_raw_ptr(self) -> Option<*mut raw::c_void> { - return Some(unsafe{self.into_raw()}.as_raw_ptr()); + Some( + #[allow(unused_unsafe)] // 1.56.0 compat + unsafe { + // SAFE: the calling function has the same soundness invariants as this callee. + self.into_raw() + } + .as_raw_ptr(), + ) } } @@ -309,4 +316,5 @@ impl<'lib, T> fmt::Debug for Symbol<'lib, T> { } unsafe impl<'lib, T: Send> Send for Symbol<'lib, T> {} -unsafe impl<'lib, T: Sync> Sync for Symbol<'lib, T> {} \ No newline at end of file +unsafe impl<'lib, T: Sync> Sync for Symbol<'lib, T> {} +