Skip to content

Commit dd44b30

Browse files
authored
Rollup merge of rust-lang#140062 - xizheyin:issue-139958, r=workingjubilee
std: mention `remove_dir_all` can emit `DirectoryNotEmpty` when concurrently written into Closes rust-lang#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
2 parents b18c0c3 + 3a372e3 commit dd44b30

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

library/std/src/fs.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2874,6 +2874,8 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
28742874
///
28752875
/// Consider ignoring the error if validating the removal is not required for your use case.
28762876
///
2877+
/// This function may return [`io::ErrorKind::DirectoryNotEmpty`] if the directory is concurrently
2878+
/// written into, which typically indicates some contents were removed but not all.
28772879
/// [`io::ErrorKind::NotFound`] is only returned if no removal occurs.
28782880
///
28792881
/// [`fs::remove_file`]: remove_file

0 commit comments

Comments
 (0)