diff --git a/Cargo.lock b/Cargo.lock index 4a1590d1e..e35f55dcd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -177,7 +177,6 @@ dependencies = [ "cargo_metadata", "clap", "clap-verbosity-flag", - "fs4", "include_dir", "mockall", "mockall_double", @@ -420,16 +419,6 @@ version = "2.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6c2141d6d6c8512188a7891b4b01590a45f6dac67afb4f255c4124dbb86d4eaa" -[[package]] -name = "fs4" -version = "0.12.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c29c30684418547d476f0b48e84f4821639119c483b1eccd566c8cd0cd05f521" -dependencies = [ - "rustix", - "windows-sys", -] - [[package]] name = "generic-array" version = "0.14.7" @@ -1160,7 +1149,6 @@ name = "wdk-macros" version = "0.4.0" dependencies = [ "cfg-if", - "fs4", "itertools", "pretty_assertions", "proc-macro2", diff --git a/Cargo.toml b/Cargo.toml index a480062dd..90521426a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -42,7 +42,6 @@ cfg-if = "1.0.0" clap = "4.5.13" clap-cargo = "0.14.1" clap-verbosity-flag = "3.0.2" -fs4 = "0.12.0" include_dir = "0.7.4" itertools = "0.13.0" mockall = "0.13.1" diff --git a/crates/cargo-wdk/Cargo.toml b/crates/cargo-wdk/Cargo.toml index e52b46c2f..8b39f266e 100644 --- a/crates/cargo-wdk/Cargo.toml +++ b/crates/cargo-wdk/Cargo.toml @@ -16,7 +16,6 @@ anyhow.workspace = true cargo_metadata.workspace = true clap = { workspace = true, features = ["derive"] } clap-verbosity-flag.workspace = true -fs4.workspace = true include_dir.workspace = true mockall.workspace = true mockall_double.workspace = true diff --git a/crates/cargo-wdk/tests/common.rs b/crates/cargo-wdk/tests/common.rs index 345bdfeda..ba157e6ef 100644 --- a/crates/cargo-wdk/tests/common.rs +++ b/crates/cargo-wdk/tests/common.rs @@ -2,7 +2,8 @@ #![allow(clippy::literal_string_with_formatting_args)] -use fs4::fs_std::FileExt; +// File locking APIs were stabilized in std::fs::File in Rust 1.89.0 +// See: https://github.com/rust-lang/rust/issues/130994 /// Sets the `RUSTFLAGS` environment variable to include `+crt-static`. /// @@ -39,7 +40,7 @@ where { let lock_file = std::fs::File::create("cargo-wdk-test.lock") .expect("Unable to create lock file for cargo-wdk tests"); - FileExt::lock_exclusive(&lock_file).expect("Unable to cargo-wdk-test.lock file"); + lock_file.lock_exclusive().expect("Unable to lock cargo-wdk-test.lock file"); f(); - FileExt::unlock(&lock_file).expect("Unable to unlock cargo-wdk-test.lock file"); + lock_file.unlock().expect("Unable to unlock cargo-wdk-test.lock file"); } diff --git a/crates/wdk-macros/Cargo.toml b/crates/wdk-macros/Cargo.toml index f9cbeb95d..e0bcdfb78 100644 --- a/crates/wdk-macros/Cargo.toml +++ b/crates/wdk-macros/Cargo.toml @@ -23,7 +23,6 @@ nightly = [] [dependencies] cfg-if.workspace = true -fs4.workspace = true itertools.workspace = true proc-macro2.workspace = true quote.workspace = true diff --git a/crates/wdk-macros/src/lib.rs b/crates/wdk-macros/src/lib.rs index f3a86e385..637c225b6 100644 --- a/crates/wdk-macros/src/lib.rs +++ b/crates/wdk-macros/src/lib.rs @@ -6,7 +6,8 @@ use std::{collections::BTreeMap, path::PathBuf, str::FromStr}; -use fs4::fs_std::FileExt; +// File locking APIs were stabilized in std::fs::File in Rust 1.89.0 +// See: https://github.com/rust-lang/rust/issues/130994 use itertools::Itertools; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; @@ -122,14 +123,14 @@ struct FileLockGuard { impl FileLockGuard { fn new(file: std::fs::File, span: Span) -> Result { - FileExt::lock_exclusive(&file).to_syn_result(span, "unable to obtain file lock")?; + file.lock_exclusive().to_syn_result(span, "unable to obtain file lock")?; Ok(Self { file }) } } impl Drop for FileLockGuard { fn drop(&mut self) { - let _ = FileExt::unlock(&self.file); + let _ = self.file.unlock(); } } @@ -976,7 +977,7 @@ mod tests { { let test_flock: std::fs::File = std::fs::File::create(SCRATCH_DIR.join("test.lock")).unwrap(); - FileExt::lock_exclusive(&test_flock).unwrap(); + test_flock.lock_exclusive().unwrap(); let cached_function_info_map_path = SCRATCH_DIR.join(CACHE_FILE_NAME); @@ -993,7 +994,7 @@ mod tests { std::fs::remove_file(cached_function_info_map_path).unwrap(); } - FileExt::unlock(&test_flock).unwrap(); + test_flock.unlock().unwrap(); } mod to_snake_case { diff --git a/tests/wdk-macros-tests/Cargo.toml b/tests/wdk-macros-tests/Cargo.toml index e3ddbec4d..4eae97dad 100644 --- a/tests/wdk-macros-tests/Cargo.toml +++ b/tests/wdk-macros-tests/Cargo.toml @@ -9,7 +9,6 @@ publish = false [lib] [dependencies] -fs4 = { version = "0.13.1", features = ["sync"] } macrotest = "1.0.13" owo-colors = "4.2.0" paste = "1.0.15" diff --git a/tests/wdk-macros-tests/src/lib.rs b/tests/wdk-macros-tests/src/lib.rs index 8d9a46b26..42a94ed04 100644 --- a/tests/wdk-macros-tests/src/lib.rs +++ b/tests/wdk-macros-tests/src/lib.rs @@ -3,7 +3,8 @@ use std::{path::PathBuf, sync::LazyLock}; -use fs4::fs_std::FileExt; +// File locking APIs were stabilized in std::fs::File in Rust 1.89.0 +// See: https://github.com/rust-lang/rust/issues/130994 pub use macrotest::{expand, expand_args}; pub use owo_colors::OwoColorize; pub use paste::paste; @@ -270,7 +271,7 @@ pub fn _create_symlink_if_nonexistent(link: &std::path::Path, target: &std::path // explicitly unlock the target_file to avoid waiting for windows to eventually // automatically release the lock when target_file handle is closed - FileExt::unlock(&target_file) + target_file.unlock() .expect("file locks should be successfully released"); } }