Skip to content

Commit 5d0ce40

Browse files
committed
Replace home-grown create_dir_all with std::fs::create_dir_all
1 parent e06b964 commit 5d0ce40

File tree

2 files changed

+3
-25
lines changed

2 files changed

+3
-25
lines changed

src/cargo/util/flock.rs

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl Filesystem {
141141
/// Handles errors where other Cargo processes are also attempting to
142142
/// concurrently create this directory.
143143
pub fn create_dir(&self) -> io::Result<()> {
144-
create_dir_all(&self.root)
144+
fs::create_dir_all(&self.root)
145145
}
146146

147147
/// Returns an adaptor that can be used to print the path of this
@@ -211,7 +211,7 @@ impl Filesystem {
211211
let f = opts.open(&path)
212212
.or_else(|e| {
213213
if e.kind() == io::ErrorKind::NotFound && state == State::Exclusive {
214-
create_dir_all(path.parent().unwrap())?;
214+
fs::create_dir_all(path.parent().unwrap())?;
215215
opts.open(&path)
216216
} else {
217217
Err(e)
@@ -344,25 +344,3 @@ fn acquire(
344344
false
345345
}
346346
}
347-
348-
fn create_dir_all(path: &Path) -> io::Result<()> {
349-
match create_dir(path) {
350-
Ok(()) => Ok(()),
351-
Err(e) => {
352-
if e.kind() == io::ErrorKind::NotFound {
353-
if let Some(p) = path.parent() {
354-
return create_dir_all(p).and_then(|()| create_dir(path));
355-
}
356-
}
357-
Err(e)
358-
}
359-
}
360-
}
361-
362-
fn create_dir(path: &Path) -> io::Result<()> {
363-
match fs::create_dir(path) {
364-
Ok(()) => Ok(()),
365-
Err(ref e) if e.kind() == io::ErrorKind::AlreadyExists => Ok(()),
366-
Err(e) => Err(e),
367-
}
368-
}

src/cargo/util/toml/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use url::Url;
1414

1515
use core::{GitReference, PackageIdSpec, Profiles, SourceId, WorkspaceConfig, WorkspaceRootConfig};
1616
use core::{Dependency, Manifest, PackageId, Summary, Target};
17-
use core::{EitherManifest, Edition, Feature, Features, VirtualManifest};
17+
use core::{Edition, EitherManifest, Feature, Features, VirtualManifest};
1818
use core::dependency::{Kind, Platform};
1919
use core::manifest::{LibKind, Lto, ManifestMetadata, Profile};
2020
use sources::CRATES_IO;

0 commit comments

Comments
 (0)