Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clarify that calling fs::remove_dir_all on a file is an error #137230

Closed
lolbinarycat opened this issue Feb 18, 2025 · 2 comments
Closed

clarify that calling fs::remove_dir_all on a file is an error #137230

lolbinarycat opened this issue Feb 18, 2025 · 2 comments
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.

Comments

@lolbinarycat
Copy link
Contributor

Location

https://doc.rust-lang.org/stable/std/fs/fn.remove_dir_all.html

Summary

Add to the errors section "if the passed path is a regular file, this function returns NotADirectory". This clarifies that it is not the same operation as rm -r, and also specifies which error will be returned in this case.

@lolbinarycat lolbinarycat added the A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools label Feb 18, 2025
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Feb 18, 2025
@jieyouxu jieyouxu added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Feb 18, 2025
@jieyouxu jieyouxu self-assigned this Feb 18, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Feb 18, 2025

This is actually mentioned already as

Additionally, [remove_dir_all] will also fail if the path is not a directory.

EDIT: wait I'm dumb, I just added that locally 💀

Though I do want to slightly reformat the caveats to make it easier to spot on a quick glance.

@jieyouxu
Copy link
Member

Oh wait, this line exists on nightly std docs but not yet stable, which is why I'm so confused. It is indeed present already at https://doc.rust-lang.org/nightly/std/fs/fn.remove_dir_all.html.

I'm going to close this as the core request "documenting it will fail on not-a-directory" is satisfied, I'll send a follow-up to slightly reformat the error docs.

@jieyouxu jieyouxu removed their assignment Feb 18, 2025
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 2, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
tgross35 added a commit to tgross35/rust that referenced this issue Mar 2, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
tgross35 added a commit to tgross35/rust that referenced this issue Mar 3, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Mar 4, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
tgross35 added a commit to tgross35/rust that referenced this issue Mar 4, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 4, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 4, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 5, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Mar 5, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
jieyouxu added a commit to jieyouxu/rust that referenced this issue Mar 5, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Mar 5, 2025
Rollup merge of rust-lang#137240 - jieyouxu:remove_dir_all, r=Mark-Simulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
github-actions bot pushed a commit to model-checking/verify-rust-std that referenced this issue Mar 14, 2025
…mulacrum

Slightly reformat `std::fs::remove_dir_all` error docs

To make the error cases easier to spot on a quick glance, as I've been bitten by this a couple of times already 💀

cc rust-lang#137230.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants