about summary refs log tree commit diff
path: root/library/std
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2025-05-01 22:27:22 +0200
committerGitHub <noreply@github.com>2025-05-01 22:27:22 +0200
commit5170e21cb915cb2c4d2eec57cc56527131e93699 (patch)
treeb87daa38645e513c7140ffeb0079d4473d24b8cb /library/std
parent5a25a7a020afd5bb9f9eaaf3a4e5622c26a9276e (diff)
parent3a372e39ca54339925bf01ead93b3c1dc01078d2 (diff)
downloadrust-5170e21cb915cb2c4d2eec57cc56527131e93699.tar.gz
rust-5170e21cb915cb2c4d2eec57cc56527131e93699.zip
Rollup merge of #140062 - xizheyin:issue-139958, r=workingjubilee
std: mention `remove_dir_all` can emit `DirectoryNotEmpty` when concurrently written into

Closes #139958

The current documentation for `std::fs::remove_dir_all` function does not explicitly mention the error types that may be returned in concurrent scenarios. Specifically, when one thread attempts to remove a directory tree while another thread simultaneously writes files to that directory, the function may return an `io::ErrorKind::DirectoryNotEmpty` error, but this behavior is not clearly mentioned in the current documentation.

r? libs
Diffstat (limited to 'library/std')
-rw-r--r--library/std/src/fs.rs2
1 files changed, 2 insertions, 0 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs
index 3340a5dc23d..462c06dcea2 100644
--- a/library/std/src/fs.rs
+++ b/library/std/src/fs.rs
@@ -2874,6 +2874,8 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
 ///
 /// Consider ignoring the error if validating the removal is not required for your use case.
 ///
+/// This function may return [`io::ErrorKind::DirectoryNotEmpty`] if the directory is concurrently
+/// written into, which typically indicates some contents were removed but not all.
 /// [`io::ErrorKind::NotFound`] is only returned if no removal occurs.
 ///
 /// [`fs::remove_file`]: remove_file