Auto merge of #7444 - matthiaskrgr:clippy_v8, r=Eh2406

fix a bunch of clippy warnings
This commit is contained in:
bors 2019-09-26 16:17:25 +00:00
commit d2db2bda80
9 changed files with 17 additions and 19 deletions

View File

@ -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(

View File

@ -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 {

View File

@ -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! {

View File

@ -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`).

View File

@ -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()));

View File

@ -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 })
@ -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)
}

View File

@ -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
}
}

View File

@ -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
@ -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 \
@ -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
@ -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)

View File

@ -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>) {