Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
Eh2406 committed Oct 5, 2018
1 parent d0b5a17 commit ae4a2fa
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 25 deletions.
20 changes: 13 additions & 7 deletions src/cargo/core/resolver/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ use std::iter::FromIterator;
use url::Url;

use core::{Dependency, PackageId, PackageIdSpec, Summary, Target};
use util::Graph;
use util::errors::CargoResult;
use util::graph::{Edges, Nodes};
use util::Graph;

use super::encode::Metadata;

Expand Down Expand Up @@ -226,16 +226,22 @@ unable to verify that `{0}` is the same as when the lockfile was generated
};

let crate_name = to_target.crate_name();
let mut names = deps.iter()
.map(|d| d.explicit_name_in_toml().map(|s| s.as_str()).unwrap_or(&crate_name));
let mut names = deps.iter().map(|d| {
d.explicit_name_in_toml()
.map(|s| s.as_str())
.unwrap_or(&crate_name)
});
let name = names.next().unwrap_or(&crate_name);
for n in names {
if n == name {
continue
continue;
}
bail!("multiple dependencies listed for the same crate must \
all have the same name, but the dependency on `{}` \
is listed as having different names", to);
bail!(
"multiple dependencies listed for the same crate must \
all have the same name, but the dependency on `{}` \
is listed as having different names",
to
);
}
Ok(name.to_string())
}
Expand Down
8 changes: 2 additions & 6 deletions src/cargo/core/source/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ pub trait Source {
/// version specified.
fn download(&mut self, package: &PackageId) -> CargoResult<MaybePackage>;

fn finish_download(&mut self, package: &PackageId, contents: Vec<u8>)
-> CargoResult<Package>;
fn finish_download(&mut self, package: &PackageId, contents: Vec<u8>) -> CargoResult<Package>;

/// Generates a unique string which represents the fingerprint of the
/// current state of the source.
Expand Down Expand Up @@ -88,10 +87,7 @@ pub trait Source {

pub enum MaybePackage {
Ready(Package),
Download {
url: String,
descriptor: String,
}
Download { url: String, descriptor: String },
}

impl<'a, T: Source + ?Sized + 'a> Source for Box<T> {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/graph.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::collections::hash_map::{HashMap, Iter, Keys};
use std::fmt;
use std::hash::Hash;
use std::collections::hash_map::{HashMap, Iter, Keys};

pub struct Graph<N, E> {
nodes: HashMap<N, HashMap<N, E>>,
Expand Down
19 changes: 8 additions & 11 deletions src/cargo/util/paths.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use std::ffi::{OsStr, OsString};
use std::fs::{self, File, OpenOptions};
use std::io;
use std::io::prelude::*;
use std::path::{Component, Path, PathBuf};
use std::iter;
use std::path::{Component, Path, PathBuf};

use filetime::FileTime;

Expand Down Expand Up @@ -127,8 +127,7 @@ pub fn read_bytes(path: &Path) -> CargoResult<Vec<u8>> {
}
f.read_to_end(&mut ret)?;
Ok(ret)
})()
.chain_err(|| format!("failed to read `{}`", path.display()))?;
})().chain_err(|| format!("failed to read `{}`", path.display()))?;
Ok(res)
}

Expand All @@ -137,8 +136,7 @@ pub fn write(path: &Path, contents: &[u8]) -> CargoResult<()> {
let mut f = File::create(path)?;
f.write_all(contents)?;
Ok(())
})()
.chain_err(|| format!("failed to write `{}`", path.display()))?;
})().chain_err(|| format!("failed to write `{}`", path.display()))?;
Ok(())
}

Expand All @@ -158,8 +156,7 @@ pub fn write_if_changed<P: AsRef<Path>, C: AsRef<[u8]>>(path: P, contents: C) ->
f.write_all(contents)?;
}
Ok(())
})()
.chain_err(|| format!("failed to write `{}`", path.as_ref().display()))?;
})().chain_err(|| format!("failed to write `{}`", path.as_ref().display()))?;
Ok(())
}

Expand All @@ -173,8 +170,7 @@ pub fn append(path: &Path, contents: &[u8]) -> CargoResult<()> {

f.write_all(contents)?;
Ok(())
})()
.chain_err(|| format!("failed to write `{}`", path.display()))?;
})().chain_err(|| format!("failed to write `{}`", path.display()))?;
Ok(())
}

Expand All @@ -198,8 +194,8 @@ pub fn path2bytes(path: &Path) -> CargoResult<&[u8]> {

#[cfg(unix)]
pub fn bytes2path(bytes: &[u8]) -> CargoResult<PathBuf> {
use std::os::unix::prelude::*;
use std::ffi::OsStr;
use std::os::unix::prelude::*;
Ok(PathBuf::from(OsStr::from_bytes(bytes)))
}
#[cfg(windows)]
Expand Down Expand Up @@ -258,7 +254,8 @@ fn _remove_dir_all(p: &Path) -> CargoResult<()> {
if p.symlink_metadata()?.file_type().is_symlink() {
return remove_file(p);
}
let entries = p.read_dir()
let entries = p
.read_dir()
.chain_err(|| format!("failed to read directory `{}`", p.display()))?;
for entry in entries {
let entry = entry?;
Expand Down

0 comments on commit ae4a2fa

Please sign in to comment.