Skip to content

Commit 3fce509

Browse files
committed
fix a bunch of clippy warnings
1 parent 74383b4 commit 3fce509

File tree

9 files changed

+17
-19
lines changed

9 files changed

+17
-19
lines changed

crates/cargo-test-support/src/lib.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1158,9 +1158,7 @@ impl Execs {
11581158

11591159
// It's easier to read tabs in outputs if they don't show up as literal
11601160
// hidden characters
1161-
let matcher = matcher.replace("\t", "<tab>");
1162-
1163-
matcher
1161+
matcher.replace("\t", "<tab>")
11641162
}
11651163

11661164
fn match_std(

src/cargo/core/compiler/context/compilation_files.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,9 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
372372
None
373373
} else {
374374
self.export_dir.as_ref().and_then(|export_dir| {
375-
hardlink.as_ref().and_then(|hardlink| {
376-
Some(export_dir.join(hardlink.file_name().unwrap()))
377-
})
375+
hardlink
376+
.as_ref()
377+
.map(|hardlink| export_dir.join(hardlink.file_name().unwrap()))
378378
})
379379
};
380380
ret.push(OutputFile {

src/cargo/core/compiler/custom_build.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ impl BuildOutput {
518518
// common with tools like pkg-config
519519
// e.g. -L/some/dir/local/lib or -licui18n
520520
let (flag, mut value) = flag.split_at(2);
521-
if value.len() == 0 {
521+
if value.is_empty() {
522522
value = match flags_iter.next() {
523523
Some(v) => v,
524524
None => failure::bail! {

src/cargo/core/compiler/layout.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ impl Layout {
217217
paths::create_dir_all(&self.examples)?;
218218
paths::create_dir_all(&self.build)?;
219219

220-
return Ok(());
220+
Ok(())
221221
}
222222

223223
/// Fetch the destination path for final artifacts (`/…/target/debug`).

src/cargo/core/resolver/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ pub(super) fn activation_error(
252252
// Maybe the user mistyped the name? Like `dep-thing` when `Dep_Thing`
253253
// was meant. So we try asking the registry for a `fuzzy` search for suggestions.
254254
let mut candidates = Vec::new();
255-
if let Err(e) = registry.query(&new_dep, &mut |s| candidates.push(s.clone()), true) {
255+
if let Err(e) = registry.query(&new_dep, &mut |s| candidates.push(s), true) {
256256
return to_resolve_err(e);
257257
};
258258
candidates.sort_unstable_by(|a, b| a.name().cmp(&b.name()));

src/cargo/sources/registry/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,7 +604,7 @@ impl<'cfg> Source for RegistrySource<'cfg> {
604604

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

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

src/cargo/util/dependency_queue.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,14 @@ impl<N: Hash + Eq + Clone, E: Eq + Hash + Clone, V> DependencyQueue<N, E, V> {
107107
.get(key)
108108
.into_iter()
109109
.flat_map(|it| it.values())
110-
.flat_map(|set| set)
110+
.flatten()
111111
{
112112
set.extend(depth(dep, map, results).iter().cloned())
113113
}
114114

115115
let slot = results.get_mut(key).unwrap();
116116
*slot = set;
117-
return &*slot;
117+
&*slot
118118
}
119119
}
120120

src/cargo/util/toml/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ impl TomlManifest {
954954
.or_else(|| me.build_dependencies2.as_ref());
955955
process_dependencies(&mut cx, build_deps, Some(Kind::Build))?;
956956

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

12531253
fn patch(&self, cx: &mut Context<'_, '_>) -> CargoResult<HashMap<Url, Vec<Dependency>>> {
12541254
let mut patch = HashMap::new();
1255-
for (url, deps) in self.patch.iter().flat_map(|x| x) {
1255+
for (url, deps) in self.patch.iter().flatten() {
12561256
let url = match &url[..] {
12571257
CRATES_IO_REGISTRY => CRATES_IO_INDEX.parse().unwrap(),
12581258
_ => cx
@@ -1469,7 +1469,7 @@ impl DetailedTomlDependency {
14691469
Some(id) => Dependency::parse(pkg_name, version, new_source_id, id, cx.config)?,
14701470
None => Dependency::parse_no_deprecated(pkg_name, version, new_source_id)?,
14711471
};
1472-
dep.set_features(self.features.iter().flat_map(|x| x))
1472+
dep.set_features(self.features.iter().flatten())
14731473
.set_default_features(
14741474
self.default_features
14751475
.or(self.default_features2)

tests/testsuite/standard_lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,10 @@ fn setup() -> Option<Setup> {
104104
.build();
105105
p.cargo("build").run();
106106

107-
return Some(Setup {
107+
Some(Setup {
108108
rustc_wrapper: p.bin("foo"),
109109
real_sysroot: paths::sysroot(),
110-
});
110+
})
111111
}
112112

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

0 commit comments

Comments
 (0)