Skip to content

Commit c5e2051

Browse files
committed
Auto merge of #43714 - ollie27:rustbuild_create_dir_all, r=alexcrichton
rustbuild: Replace create_dir_racy with create_dir_all `create_dir_all` has since been fixed (in #39799) so no need for `create_dir_racy`.
2 parents 65b0a0c + 94c90e7 commit c5e2051

File tree

1 file changed

+1
-20
lines changed

1 file changed

+1
-20
lines changed

src/build_helper/lib.rs

+1-20
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
extern crate filetime;
1414

1515
use std::fs::File;
16-
use std::io;
1716
use std::path::{Path, PathBuf};
1817
use std::process::{Command, Stdio};
1918
use std::{fs, env};
@@ -211,7 +210,7 @@ pub fn native_lib_boilerplate(src_name: &str,
211210

212211
let out_dir = env::var_os("RUSTBUILD_NATIVE_DIR").unwrap_or(env::var_os("OUT_DIR").unwrap());
213212
let out_dir = PathBuf::from(out_dir).join(out_name);
214-
t!(create_dir_racy(&out_dir));
213+
t!(fs::create_dir_all(&out_dir));
215214
if link_name.contains('=') {
216215
println!("cargo:rustc-link-lib={}", link_name);
217216
} else {
@@ -260,21 +259,3 @@ fn fail(s: &str) -> ! {
260259
println!("\n\n{}\n\n", s);
261260
std::process::exit(1);
262261
}
263-
264-
fn create_dir_racy(path: &Path) -> io::Result<()> {
265-
match fs::create_dir(path) {
266-
Ok(()) => return Ok(()),
267-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => return Ok(()),
268-
Err(ref e) if e.kind() == io::ErrorKind::NotFound => {}
269-
Err(e) => return Err(e),
270-
}
271-
match path.parent() {
272-
Some(p) => try!(create_dir_racy(p)),
273-
None => return Err(io::Error::new(io::ErrorKind::Other, "failed to create whole tree")),
274-
}
275-
match fs::create_dir(path) {
276-
Ok(()) => Ok(()),
277-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
278-
Err(e) => Err(e),
279-
}
280-
}

0 commit comments

Comments
 (0)