diff --git a/ash/Cargo.toml b/ash/Cargo.toml index 7ba4c1c..adc7587 100644 --- a/ash/Cargo.toml +++ b/ash/Cargo.toml @@ -11,7 +11,7 @@ documentation = "https://docs.rs/ash" edition = "2018" [dependencies] -libloading = { version = "0.6.1", optional = true } +libloading = { version = "0.7", optional = true } [features] default = ["libloading"] diff --git a/ash/src/entry_libloading.rs b/ash/src/entry_libloading.rs index 9e3f893..9a392bc 100644 --- a/ash/src/entry_libloading.rs +++ b/ash/src/entry_libloading.rs @@ -42,6 +42,10 @@ impl Error for LoadingError { impl EntryCustom> { /// Load default Vulkan library for the current platform /// + /// # Safety + /// `dlopen`ing native libraries is inherently unsafe. The safety guidelines + /// for [`Library::new`] and [`Library::get`] apply here. + /// /// ```rust,no_run /// use ash::{vk, Entry, version::EntryV1_0}; /// # fn main() -> Result<(), Box> { @@ -57,15 +61,19 @@ impl EntryCustom> { /// let instance = unsafe { entry.create_instance(&create_info, None)? }; /// # Ok(()) } /// ``` - pub fn new() -> Result { + pub unsafe fn new() -> Result { Self::with_library(&LIB_PATH) } /// Load Vulkan library at `path` - pub fn with_library>(path: &P) -> Result { + /// + /// # Safety + /// `dlopen`ing native libraries is inherently unsafe. The safety guidelines + /// for [`Library::new`] and [`Library::get`] apply here. + pub unsafe fn with_library(path: &impl AsRef) -> Result { let lib = Library::new(path).map_err(LoadingError).map(Arc::new)?; - Ok(Self::new_custom(lib, |vk_lib, name| unsafe { + Ok(Self::new_custom(lib, |vk_lib, name| { vk_lib .get(name.to_bytes_with_nul()) .map(|symbol| *symbol)