From: Aleksey Kladov Date: Tue, 3 Apr 2018 13:14:14 +0000 (+0300) Subject: Replace home-grown create_dir_all with std::fs::create_dir_all X-Git-Tag: archive/raspbian/0.35.0-2+rpi1~3^2^2^2^2^2^2^2~22^2~1^2~104^2 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=5d0ce40deb43a12aa15814ad6c92bf6f391cf1aa;p=cargo.git Replace home-grown create_dir_all with std::fs::create_dir_all --- diff --git a/src/cargo/util/flock.rs b/src/cargo/util/flock.rs index bba61fbf5..c2929756a 100644 --- a/src/cargo/util/flock.rs +++ b/src/cargo/util/flock.rs @@ -141,7 +141,7 @@ impl Filesystem { /// Handles errors where other Cargo processes are also attempting to /// concurrently create this directory. pub fn create_dir(&self) -> io::Result<()> { - create_dir_all(&self.root) + fs::create_dir_all(&self.root) } /// Returns an adaptor that can be used to print the path of this @@ -211,7 +211,7 @@ impl Filesystem { let f = opts.open(&path) .or_else(|e| { if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive { - create_dir_all(path.parent().unwrap())?; + fs::create_dir_all(path.parent().unwrap())?; opts.open(&path) } else { Err(e) @@ -344,25 +344,3 @@ fn acquire( false } } - -fn create_dir_all(path: &Path) -> io::Result<()> { - match create_dir(path) { - Ok(()) => Ok(()), - Err(e) => { - if e.kind() == io::ErrorKind::NotFound { - if let Some(p) = path.parent() { - return create_dir_all(p).and_then(|()| create_dir(path)); - } - } - Err(e) - } - } -} - -fn create_dir(path: &Path) -> io::Result<()> { - match fs::create_dir(path) { - Ok(()) => Ok(()), - Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()), - Err(e) => Err(e), - } -} diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 3aa4f5875..651928efd 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -14,7 +14,7 @@ use url::Url; use core::{GitReference, PackageIdSpec, Profiles, SourceId, WorkspaceConfig, WorkspaceRootConfig}; use core::{Dependency, Manifest, PackageId, Summary, Target}; -use core::{EitherManifest, Edition, Feature, Features, VirtualManifest}; +use core::{Edition, EitherManifest, Feature, Features, VirtualManifest}; use core::dependency::{Kind, Platform}; use core::manifest::{LibKind, Lto, ManifestMetadata, Profile}; use sources::CRATES_IO;