Skip to content

Commit 52cecd0

Browse files
David Tolnayfacebook-github-bot
David Tolnay
authored andcommitted
Disambiguate fs2 extension-trait locking calls
Summary: Some `fs2::FileExt` extension-trait methods overlap with new file locking API on `std::fs::File` in Rust 1.84 (D70601924). ```lang=text,counterexample error: a method with this name may be added to the standard library in the future --> fbcode/clifoundation/cli_target/validator/src/main.rs:279:20 | 279 | cache_file.lock_shared()?; | ^^^^^^^^^^^ | = warning: once this associated item is added to the standard library, the ambiguity may cause an error or change in behavior! = note: for more information, see issue #48919 <rust-lang/rust#48919> = help: call with fully qualified syntax `fs4::FileExt::lock_shared(...)` to keep using the current method = note: requested on the command line with `-D unstable-name-collisions` help: add `#![feature(file_lock)]` to the crate attributes to enable `std::fs::File::lock_shared` | 1 + #![feature(file_lock)] | ``` This diff (still on Rust 1.83) qualifies all the extension-trait calls so that these do not become a factor in the Rust 1.84 diff. After D70601924, it would be reasonable to drop `fs2` and `fs4` dependencies and use the standard library APIs instead. Reviewed By: diliop Differential Revision: D70676686 fbshipit-source-id: ed9dc8fa139c56e1a6f8e2fc39b923a81e8711b3
1 parent 27696bb commit 52cecd0

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

app/buck2_client_ctx/src/daemon/client.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ use buck2_core::fs::paths::abs_norm_path::AbsNormPathBuf;
2323
use buck2_data::error::ErrorTag;
2424
use buck2_error::BuckErrorContext;
2525
use buck2_event_log::stream_value::StreamValue;
26-
use fs4::FileExt;
2726
use futures::future::BoxFuture;
2827
use futures::pin_mut;
2928
use futures::stream;
@@ -94,7 +93,7 @@ impl BuckdLifecycleLock {
9493
"locking buckd lifecycle",
9594
Duration::from_millis(5),
9695
Duration::from_millis(100),
97-
|| async { Ok(fileref.try_lock_exclusive()?) },
96+
|| async { Ok(fs4::FileExt::try_lock_exclusive(fileref)?) },
9897
)
9998
.await?;
10099

@@ -129,8 +128,7 @@ impl BuckdLifecycleLock {
129128

130129
impl Drop for BuckdLifecycleLock {
131130
fn drop(&mut self) {
132-
self.lock_file
133-
.unlock()
131+
fs4::FileExt::unlock(&self.lock_file)
134132
.expect("Unexpected failure to unlock buckd.lifecycle file.")
135133
}
136134
}

app/buck2_common/src/build_count.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ use buck2_core::fs::paths::abs_norm_path::AbsNormPathBuf;
1515
use buck2_core::fs::paths::file_name::FileName;
1616
use buck2_data::ParsedTargetPatterns;
1717
use buck2_error::BuckErrorContext;
18-
use fs4::FileExt;
1918
use serde::Deserialize;
2019
use serde::Serialize;
2120

@@ -135,7 +134,7 @@ impl BuildCountManager {
135134
Duration::from_millis(5),
136135
Duration::from_millis(100),
137136
timeout,
138-
|| async { buck2_error::Ok(fileref.try_lock_exclusive()?) },
137+
|| async { buck2_error::Ok(fs4::FileExt::try_lock_exclusive(fileref)?) },
139138
)
140139
.await?;
141140
Ok(FileLockGuard { file })
@@ -193,8 +192,7 @@ struct FileLockGuard {
193192

194193
impl Drop for FileLockGuard {
195194
fn drop(&mut self) {
196-
self.file
197-
.unlock()
195+
fs4::FileExt::unlock(&self.file)
198196
.expect("Unexpected failure to release a lock file for build count");
199197
}
200198
}

0 commit comments

Comments
 (0)