From 55d238c8c175bfa3b6b7a4489ecdcd4ad47d28af Mon Sep 17 00:00:00 2001 From: NightRa Date: Wed, 15 Apr 2020 19:05:09 +0300 Subject: [PATCH] Avoid changing the error variant name for now - Should be done in the next breaking change --- src/error.rs | 14 +++++++------- src/os/windows/mod.rs | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/error.rs b/src/error.rs index d80a002..dcbe2b1 100644 --- a/src/error.rs +++ b/src/error.rs @@ -31,10 +31,10 @@ pub enum Error { DlClose { desc: DlDescription }, /// The `dlclose` call failed and system did not report an error. DlCloseUnknown, - /// The `LoadLibraryExW` call failed. - LoadLibraryExW { source: WindowsError }, - /// The `LoadLibraryExW` call failed and system did not report an error. - LoadLibraryExWUnknown, + /// The `LoadLibraryW` call failed. + LoadLibraryW { source: WindowsError }, + /// The `LoadLibraryW` call failed and system did not report an error. + LoadLibraryWUnknown, /// The `GetProcAddress` call failed. GetProcAddress { source: WindowsError }, /// The `GetProcAddressUnknown` call failed and system did not report an error. @@ -57,7 +57,7 @@ impl std::error::Error for Error { match *self { CreateCString { ref source } => Some(source), CreateCStringWithTrailing { ref source } => Some(source), - LoadLibraryExW { ref source } => Some(&source.0), + LoadLibraryW { ref source } => Some(&source.0), GetProcAddress { ref source } => Some(&source.0), FreeLibrary { ref source } => Some(&source.0), _ => None, @@ -75,8 +75,8 @@ impl std::fmt::Display for Error { DlSymUnknown => write!(f, "dlsym failed, but system did not report the error"), DlClose { ref desc } => write!(f, "{}", desc.0.to_string_lossy()), DlCloseUnknown => write!(f, "dlclose failed, but system did not report the error"), - LoadLibraryExW { .. } => write!(f, "LoadLibraryW failed"), - LoadLibraryExWUnknown => + LoadLibraryW { .. } => write!(f, "LoadLibraryW failed"), + LoadLibraryWUnknown => write!(f, "LoadLibraryW failed, but system did not report the error"), GetProcAddress { .. } => write!(f, "GetProcAddress failed"), GetProcAddressUnknown => diff --git a/src/os/windows/mod.rs b/src/os/windows/mod.rs index 1ff4a7d..3620b3e 100644 --- a/src/os/windows/mod.rs +++ b/src/os/windows/mod.rs @@ -33,7 +33,7 @@ unsafe impl Sync for Library {} impl Library { /// Find and load a shared library (module). /// - /// Corresponds to `LoadLibraryExW(filename, reserved: NULL, flags: 0)` which is equivalent to `LoadLibraryW(filename)` + /// Corresponds to `LoadLibraryW(filename, reserved: NULL, flags: 0)` which is equivalent to `LoadLibraryW(filename)` #[inline] pub fn new>(filename: P) -> Result { Library::load_with_flags(filename, 0) @@ -44,12 +44,12 @@ impl Library { /// Locations where library is searched for is platform specific and can’t be adjusted /// portably. /// - /// Corresponds to `LoadLibraryExW(filename, reserved: NULL, flags)`. + /// Corresponds to `LoadLibraryW(filename, reserved: NULL, flags)`. pub fn load_with_flags>(filename: P, flags: DWORD) -> Result { let wide_filename: Vec = filename.as_ref().encode_wide().chain(Some(0)).collect(); let _guard = ErrorModeGuard::new(); - let ret = with_get_last_error(|source| crate::Error::LoadLibraryExW { source }, || { + let ret = with_get_last_error(|source| crate::Error::LoadLibraryW { source }, || { // Make sure no winapi calls as a result of drop happen inside this closure, because // otherwise that might change the return value of the GetLastError. let handle = unsafe { libloaderapi::LoadLibraryExW(wide_filename.as_ptr(), std::ptr::null_mut(), flags) }; @@ -58,9 +58,9 @@ impl Library { } else { Some(Library(handle)) } - }).map_err(|e| e.unwrap_or(crate::Error::LoadLibraryExWUnknown)); + }).map_err(|e| e.unwrap_or(crate::Error::LoadLibraryWUnknown)); drop(wide_filename); // Drop wide_filename here to ensure it doesn’t get moved and dropped - // inside the closure by mistake. See comment inside the closure. + // inside the closure by mistake. See comment inside the closure. ret }