Skip to content

Commit

Permalink
Auto merge of #7444 - matthiaskrgr:clippy_v8, r=Eh2406
Browse files Browse the repository at this point in the history
 fix a bunch of clippy warnings
  • Loading branch information
bors committed Sep 26, 2019
2 parents 494cbd8 + 3fce509 commit d2db2bd
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 19 deletions.
4 changes: 1 addition & 3 deletions crates/cargo-test-support/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1158,9 +1158,7 @@ impl Execs {

// It's easier to read tabs in outputs if they don't show up as literal
// hidden characters
let matcher = matcher.replace("\t", "<tab>");

matcher
matcher.replace("\t", "<tab>")
}

fn match_std(
Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,9 +372,9 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
None
} else {
self.export_dir.as_ref().and_then(|export_dir| {
hardlink.as_ref().and_then(|hardlink| {
Some(export_dir.join(hardlink.file_name().unwrap()))
})
hardlink
.as_ref()
.map(|hardlink| export_dir.join(hardlink.file_name().unwrap()))
})
};
ret.push(OutputFile {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/custom_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ impl BuildOutput {
// common with tools like pkg-config
// e.g. -L/some/dir/local/lib or -licui18n
let (flag, mut value) = flag.split_at(2);
if value.len() == 0 {
if value.is_empty() {
value = match flags_iter.next() {
Some(v) => v,
None => failure::bail! {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl Layout {
paths::create_dir_all(&self.examples)?;
paths::create_dir_all(&self.build)?;

return Ok(());
Ok(())
}

/// Fetch the destination path for final artifacts (`/…/target/debug`).
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/resolver/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ pub(super) fn activation_error(
// Maybe the user mistyped the name? Like `dep-thing` when `Dep_Thing`
// was meant. So we try asking the registry for a `fuzzy` search for suggestions.
let mut candidates = Vec::new();
if let Err(e) = registry.query(&new_dep, &mut |s| candidates.push(s.clone()), true) {
if let Err(e) = registry.query(&new_dep, &mut |s| candidates.push(s), true) {
return to_resolve_err(e);
};
candidates.sort_unstable_by(|a, b| a.name().cmp(&b.name()));
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/sources/registry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -604,7 +604,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {

fn download(&mut self, package: PackageId) -> CargoResult<MaybePackage> {
let hash = self.index.hash(package, &mut *self.ops)?;
match self.ops.download(package, &hash)? {
match self.ops.download(package, hash)? {
MaybeLock::Ready(file) => self.get_pkg(package, &file).map(MaybePackage::Ready),
MaybeLock::Download { url, descriptor } => {
Ok(MaybePackage::Download { url, descriptor })
Expand All @@ -614,7 +614,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {

fn finish_download(&mut self, package: PackageId, data: Vec<u8>) -> CargoResult<Package> {
let hash = self.index.hash(package, &mut *self.ops)?;
let file = self.ops.finish_download(package, &hash, &data)?;
let file = self.ops.finish_download(package, hash, &data)?;
self.get_pkg(package, &file)
}

Expand Down
4 changes: 2 additions & 2 deletions src/cargo/util/dependency_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,14 +107,14 @@ impl<N: Hash + Eq + Clone, E: Eq + Hash + Clone, V> DependencyQueue<N, E, V> {
.get(key)
.into_iter()
.flat_map(|it| it.values())
.flat_map(|set| set)
.flatten()
{
set.extend(depth(dep, map, results).iter().cloned())
}

let slot = results.get_mut(key).unwrap();
*slot = set;
return &*slot;
&*slot
}
}

Expand Down
8 changes: 4 additions & 4 deletions src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -954,7 +954,7 @@ impl TomlManifest {
.or_else(|| me.build_dependencies2.as_ref());
process_dependencies(&mut cx, build_deps, Some(Kind::Build))?;

for (name, platform) in me.target.iter().flat_map(|t| t) {
for (name, platform) in me.target.iter().flatten() {
cx.platform = Some(name.parse()?);
process_dependencies(&mut cx, platform.dependencies.as_ref(), None)?;
let build_deps = platform
Expand Down Expand Up @@ -1210,7 +1210,7 @@ impl TomlManifest {
bail!("cannot specify both [replace] and [patch]");
}
let mut replace = Vec::new();
for (spec, replacement) in self.replace.iter().flat_map(|x| x) {
for (spec, replacement) in self.replace.iter().flatten() {
let mut spec = PackageIdSpec::parse(spec).chain_err(|| {
format!(
"replacements must specify a valid semver \
Expand Down Expand Up @@ -1252,7 +1252,7 @@ impl TomlManifest {

fn patch(&self, cx: &mut Context<'_, '_>) -> CargoResult<HashMap<Url, Vec<Dependency>>> {
let mut patch = HashMap::new();
for (url, deps) in self.patch.iter().flat_map(|x| x) {
for (url, deps) in self.patch.iter().flatten() {
let url = match &url[..] {
CRATES_IO_REGISTRY => CRATES_IO_INDEX.parse().unwrap(),
_ => cx
Expand Down Expand Up @@ -1469,7 +1469,7 @@ impl DetailedTomlDependency {
Some(id) => Dependency::parse(pkg_name, version, new_source_id, id, cx.config)?,
None => Dependency::parse_no_deprecated(pkg_name, version, new_source_id)?,
};
dep.set_features(self.features.iter().flat_map(|x| x))
dep.set_features(self.features.iter().flatten())
.set_default_features(
self.default_features
.or(self.default_features2)
Expand Down
4 changes: 2 additions & 2 deletions tests/testsuite/standard_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ fn setup() -> Option<Setup> {
.build();
p.cargo("build").run();

return Some(Setup {
Some(Setup {
rustc_wrapper: p.bin("foo"),
real_sysroot: paths::sysroot(),
});
})
}

fn enable_build_std(e: &mut Execs, setup: &Setup, arg: Option<&str>) {
Expand Down

0 comments on commit d2db2bd

Please sign in to comment.