From cdbb12111231314513e0143af3624655b3b0f6ba Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sat, 3 Aug 2024 15:03:10 +1000
Subject: [PATCH] build(deps): bump the deps group across 1 directory with 2
 updates (#1859)

* build(deps): bump the deps group across 1 directory with 2 updates

Bumps the deps group with 2 updates in the / directory: [fs4](https://github.com/al8n/fs4-rs) and [windows-sys](https://github.com/microsoft/windows-rs).


Updates `fs4` from 0.8.4 to 0.9.1
- [Release notes](https://github.com/al8n/fs4-rs/releases)
- [Commits](https://github.com/al8n/fs4-rs/commits)

Updates `windows-sys` from 0.52.0 to 0.59.0
- [Release notes](https://github.com/microsoft/windows-rs/releases)
- [Commits](https://github.com/microsoft/windows-rs/compare/0.52.0...0.59.0)

---
updated-dependencies:
- dependency-name: fs4
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: deps
- dependency-name: windows-sys
  dependency-type: direct:production
  update-type: version-update:semver-minor
  dependency-group: deps
...

Signed-off-by: dependabot[bot] <support@github.com>

* Fix use of fs4

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix windows.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Rm drop impl for LibraryHandle

As unmounting dynlib might cause UB

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

* Fix clippy in windows.rs

Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>

---------

Signed-off-by: dependabot[bot] <support@github.com>
Signed-off-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Jiahao XU <30436523+NobodyXu@users.noreply.github.com>
---
 Cargo.lock                                  |  6 +++---
 crates/detect-targets/Cargo.toml            |  2 +-
 crates/detect-targets/src/detect/windows.rs | 10 ++--------
 crates/fs-lock/Cargo.toml                   |  2 +-
 crates/fs-lock/src/lib.rs                   |  2 +-
 5 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 156440f1..7f5faefd 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -898,7 +898,7 @@ dependencies = [
  "tokio",
  "tracing",
  "tracing-subscriber",
- "windows-sys 0.52.0",
+ "windows-sys 0.59.0",
 ]
 
 [[package]]
@@ -1123,9 +1123,9 @@ dependencies = [
 
 [[package]]
 name = "fs4"
-version = "0.8.4"
+version = "0.9.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "f7e180ac76c23b45e767bd7ae9579bc0bb458618c4bc71835926e098e61d15f8"
+checksum = "e8c6b3bd49c37d2aa3f3f2220233b29a7cd23f79d1fe70e5337d25fb390793de"
 dependencies = [
  "rustix",
  "windows-sys 0.52.0",
diff --git a/crates/detect-targets/Cargo.toml b/crates/detect-targets/Cargo.toml
index 00ffe458..03399ae8 100644
--- a/crates/detect-targets/Cargo.toml
+++ b/crates/detect-targets/Cargo.toml
@@ -27,7 +27,7 @@ tracing = ["dep:tracing"]
 cli-logging = ["tracing", "dep:tracing-subscriber"]
 
 [target.'cfg(target_os = "windows")'.dependencies]
-windows-sys = { version = "0.52.0", features = [
+windows-sys = { version = "0.59.0", features = [
     "Win32_System_Threading",
     "Win32_System_SystemInformation",
     "Win32_Foundation",
diff --git a/crates/detect-targets/src/detect/windows.rs b/crates/detect-targets/src/detect/windows.rs
index 5e4fe447..5bb397cb 100644
--- a/crates/detect-targets/src/detect/windows.rs
+++ b/crates/detect-targets/src/detect/windows.rs
@@ -1,6 +1,6 @@
 use std::mem;
 use windows_sys::Win32::{
-    Foundation::{FreeLibrary, HMODULE, S_OK},
+    Foundation::{HMODULE, S_OK},
     System::{
         LibraryLoader::{GetProcAddress, LoadLibraryA},
         SystemInformation::{
@@ -16,7 +16,7 @@ struct LibraryHandle(HMODULE);
 impl LibraryHandle {
     fn new(name: &[u8]) -> Option<Self> {
         let handle = unsafe { LoadLibraryA(name.as_ptr() as _) };
-        (handle != 0).then(|| Self(handle))
+        (!handle.is_null()).then_some(Self(handle))
     }
 
     /// Get a function pointer to a function in the library.
@@ -33,12 +33,6 @@ impl LibraryHandle {
     }
 }
 
-impl Drop for LibraryHandle {
-    fn drop(&mut self) {
-        unsafe { FreeLibrary(self.0) };
-    }
-}
-
 type GetMachineTypeAttributesFuncType =
     unsafe extern "system" fn(u16, *mut MACHINE_ATTRIBUTES) -> i32;
 const _: () = {
diff --git a/crates/fs-lock/Cargo.toml b/crates/fs-lock/Cargo.toml
index 00be6e48..bd7ed3c9 100644
--- a/crates/fs-lock/Cargo.toml
+++ b/crates/fs-lock/Cargo.toml
@@ -10,4 +10,4 @@ edition = "2021"
 license = "Apache-2.0 OR MIT"
 
 [dependencies]
-fs4 = "0.8.1"
+fs4 = "0.9.1"
diff --git a/crates/fs-lock/src/lib.rs b/crates/fs-lock/src/lib.rs
index af209ff5..0a96609f 100644
--- a/crates/fs-lock/src/lib.rs
+++ b/crates/fs-lock/src/lib.rs
@@ -8,7 +8,7 @@ use std::{
     ops,
 };
 
-use fs4::FileExt;
+use fs4::fs_std::FileExt;
 
 /// A locked file.
 #[derive(Debug)]