about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPhilpax <me@philpax.me>2022-12-15 11:14:13 +0100
committerPhilpax <me@philpax.me>2023-04-27 03:19:14 +0200
commitd5d2785c86a70fba65e9baa862a54be22b3b786c (patch)
tree59aa9dee9c59795b09e01f016766f8983ec950b5
parentcb9aa8c9c19236f09667dc0bddbe6daee638696c (diff)
downloadrust-d5d2785c86a70fba65e9baa862a54be22b3b786c.tar.gz
rust-d5d2785c86a70fba65e9baa862a54be22b3b786c.zip
docs(std): clarify `remove_dir_all` errors
-rw-r--r--library/std/src/fs.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/library/std/src/fs.rs b/library/std/src/fs.rs
index 42a68496fc4..30e553f285b 100644
--- a/library/std/src/fs.rs
+++ b/library/std/src/fs.rs
@@ -2284,6 +2284,11 @@ pub fn remove_dir<P: AsRef<Path>>(path: P) -> io::Result<()> {
 ///
 /// See [`fs::remove_file`] and [`fs::remove_dir`].
 ///
+/// `remove_dir_all` will fail if `remove_dir` or `remove_file` fail on any constituent paths, including the root path.
+/// As a result, the directory you are deleting must exist, meaning that this function is not idempotent.
+///
+/// Consider ignoring the error if validating the removal is not required for your use case.
+///
 /// [`fs::remove_file`]: remove_file
 /// [`fs::remove_dir`]: remove_dir
 ///