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
This commit is contained in:
Guillaume Gomez 2025-05-01 22:27:22 +02:00 committed by GitHub
commit 5170e21cb9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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