Skip to content

Commit d7e77b5

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 de7e52d + 3a372e3 commit d7e77b5

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
@@ -2923,6 +2923,8 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
29232923
///
29242924
/// Consider ignoring the error if validating the removal is not required for your use case.
29252925
///
2926+
/// This function may return [`io::ErrorKind::DirectoryNotEmpty`] if the directory is concurrently
2927+
/// written into, which typically indicates some contents were removed but not all.
29262928
/// [`io::ErrorKind::NotFound`] is only returned if no removal occurs.
29272929
///
29282930
/// [`fs::remove_file`]: remove_file

0 commit comments

Comments
 (0)