-
Notifications
You must be signed in to change notification settings - Fork 12.1k
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
Document behavior of create_dir_all
wrt. empty path
#125112
base: master
Are you sure you want to change the base?
Conversation
rustbot has assigned @Mark-Simulacrum. Use |
r? dtolnay - technically a new stable guarantee, I think? So probably needs libs-api FCP. |
@rust-lang/libs-api:
fn main() {
let tempdir = tempfile::tempdir().unwrap();
let repro = tempdir.path().join("repro");
std::fs::create_dir(&repro).unwrap();
std::env::set_current_dir(&repro).unwrap();
std::fs::remove_dir(&repro).unwrap();
std::fs::write(&repro, "").unwrap();
std::fs::create_dir_all(&repro).unwrap_err(); // FAIL
std::fs::create_dir_all("").unwrap(); // ok
} |
Team member @dtolnay has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
Our previous empty paths topic: #114149. In that case we decided not to regard the empty path as current dir for |
Interestingly |
I'd add that this case is a bit different, because |
On Linux, $ mkdir .
mkdir: cannot create directory ‘.’: File exists |
I think the wording here is a little vague. It says that it always "succeeds," but doesn't say what "succeeds" means. Can we elaborate on what success means for this case? |
The behavior makes sense because `Path::new("one_component").parent() == Some(Path::new(""))`, so if one naively wants to create the parent directory for a file to be written, it simply works. Closes rust-lang#105108 by documenting the current behavior.
04d2e35
to
6add5c9
Compare
Done. |
@tbu- Yeah, that's a good point. Even if we wanted to create the current directory, we can't. |
The behavior makes sense because
Path::new("one_component").parent() == Some(Path::new(""))
, so if one naively wants to create the parent directory for a file to be written, it simply works.Closes #105108 by documenting the current behavior.