From f41c7922724a859a9f501650e076e23273c77ab4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 04:42:06 +0000 Subject: [PATCH 1/4] Initial plan for issue From c43b6514ec0d62ad6ad54db4f18e445b68efcca5 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 04:55:41 +0000 Subject: [PATCH 2/4] Migrate from fs4 to std::File flocks Co-authored-by: wmmc88 <16629657+wmmc88@users.noreply.github.com> --- Cargo.toml | 3 +-- crates/cargo-wdk/Cargo.toml | 1 - crates/cargo-wdk/tests/common.rs | 7 ++++--- crates/wdk-macros/Cargo.toml | 1 - crates/wdk-macros/src/lib.rs | 11 ++++++----- tests/wdk-macros-tests/Cargo.toml | 1 - tests/wdk-macros-tests/src/lib.rs | 5 +++-- 7 files changed, 14 insertions(+), 15 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index a480062dd..99d3d6a89 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ resolver = "3" [workspace.package] edition = "2021" -rust-version = "1.84.0" +rust-version = "1.88.0" repository = "https://github.com/microsoft/windows-drivers-rs" readme = "README.md" license = "MIT OR Apache-2.0" @@ -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..f4d49b444 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 is now available in std::fs::File (stable since Rust 1.88) +// No additional imports needed for file locking /// 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..85e5a534e 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 is now available in std::fs::File (stable since Rust 1.88) +// No additional imports needed for file locking 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..7b0d171cd 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 is now available in std::fs::File (stable since Rust 1.88) +// No additional imports needed for file locking 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"); } } From b7b937629e871223a1d7201590a5728981265613 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Wed, 11 Jun 2025 04:57:49 +0000 Subject: [PATCH 3/4] Update comments about file lock API stabilization status Co-authored-by: wmmc88 <16629657+wmmc88@users.noreply.github.com> --- Cargo.toml | 2 +- crates/cargo-wdk/tests/common.rs | 5 +++-- crates/wdk-macros/src/lib.rs | 5 +++-- tests/wdk-macros-tests/src/lib.rs | 5 +++-- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 99d3d6a89..90521426a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,7 +16,7 @@ resolver = "3" [workspace.package] edition = "2021" -rust-version = "1.88.0" +rust-version = "1.84.0" repository = "https://github.com/microsoft/windows-drivers-rs" readme = "README.md" license = "MIT OR Apache-2.0" diff --git a/crates/cargo-wdk/tests/common.rs b/crates/cargo-wdk/tests/common.rs index f4d49b444..44adf4cba 100644 --- a/crates/cargo-wdk/tests/common.rs +++ b/crates/cargo-wdk/tests/common.rs @@ -2,8 +2,9 @@ #![allow(clippy::literal_string_with_formatting_args)] -// File locking is now available in std::fs::File (stable since Rust 1.88) -// No additional imports needed for file locking +// File locking APIs are being stabilized in std::fs::File +// This migration prepares for the stable file lock APIs +// See: https://github.com/rust-lang/rust/issues/130994 /// Sets the `RUSTFLAGS` environment variable to include `+crt-static`. /// diff --git a/crates/wdk-macros/src/lib.rs b/crates/wdk-macros/src/lib.rs index 85e5a534e..0eb961ae4 100644 --- a/crates/wdk-macros/src/lib.rs +++ b/crates/wdk-macros/src/lib.rs @@ -6,8 +6,9 @@ use std::{collections::BTreeMap, path::PathBuf, str::FromStr}; -// File locking is now available in std::fs::File (stable since Rust 1.88) -// No additional imports needed for file locking +// File locking APIs are being stabilized in std::fs::File +// This migration prepares for the stable file lock APIs +// See: https://github.com/rust-lang/rust/issues/130994 use itertools::Itertools; use proc_macro::TokenStream; use proc_macro2::{Span, TokenStream as TokenStream2}; diff --git a/tests/wdk-macros-tests/src/lib.rs b/tests/wdk-macros-tests/src/lib.rs index 7b0d171cd..949d82b1c 100644 --- a/tests/wdk-macros-tests/src/lib.rs +++ b/tests/wdk-macros-tests/src/lib.rs @@ -3,8 +3,9 @@ use std::{path::PathBuf, sync::LazyLock}; -// File locking is now available in std::fs::File (stable since Rust 1.88) -// No additional imports needed for file locking +// File locking APIs are being stabilized in std::fs::File +// This migration prepares for the stable file lock APIs +// See: https://github.com/rust-lang/rust/issues/130994 pub use macrotest::{expand, expand_args}; pub use owo_colors::OwoColorize; pub use paste::paste; From f20a104ed2c6ca3c9dd324c7b3d7868493d38e4a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Thu, 14 Aug 2025 20:36:22 +0000 Subject: [PATCH 4/4] Update comments to reflect file lock API stabilization status Co-authored-by: wmmc88 <16629657+wmmc88@users.noreply.github.com> --- Cargo.lock | 12 ------------ crates/cargo-wdk/tests/common.rs | 3 +-- crates/wdk-macros/src/lib.rs | 3 +-- tests/wdk-macros-tests/src/lib.rs | 3 +-- 4 files changed, 3 insertions(+), 18 deletions(-) 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/crates/cargo-wdk/tests/common.rs b/crates/cargo-wdk/tests/common.rs index 44adf4cba..ba157e6ef 100644 --- a/crates/cargo-wdk/tests/common.rs +++ b/crates/cargo-wdk/tests/common.rs @@ -2,8 +2,7 @@ #![allow(clippy::literal_string_with_formatting_args)] -// File locking APIs are being stabilized in std::fs::File -// This migration prepares for the stable file lock APIs +// 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`. diff --git a/crates/wdk-macros/src/lib.rs b/crates/wdk-macros/src/lib.rs index 0eb961ae4..637c225b6 100644 --- a/crates/wdk-macros/src/lib.rs +++ b/crates/wdk-macros/src/lib.rs @@ -6,8 +6,7 @@ use std::{collections::BTreeMap, path::PathBuf, str::FromStr}; -// File locking APIs are being stabilized in std::fs::File -// This migration prepares for the stable file lock APIs +// 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; diff --git a/tests/wdk-macros-tests/src/lib.rs b/tests/wdk-macros-tests/src/lib.rs index 949d82b1c..42a94ed04 100644 --- a/tests/wdk-macros-tests/src/lib.rs +++ b/tests/wdk-macros-tests/src/lib.rs @@ -3,8 +3,7 @@ use std::{path::PathBuf, sync::LazyLock}; -// File locking APIs are being stabilized in std::fs::File -// This migration prepares for the stable file lock APIs +// 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;