Skip to content

Commit 64ae327

Browse files
committed
fix a bunch of clippy warnings
Fixes: clippy::into_iter_on_ref clippy::needless_borrow clippy::useless_format clippy::renamed_and_removed_lints clippy::clone_on_copy clippy::or_fun_call clippy::redundant_clone
1 parent 65e3885 commit 64ae327

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

src/bin/cargo/commands/vendor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ https://github.com/rust-lang/cargo/issues/new
106106
let path = args
107107
.value_of_os("path")
108108
.map(|val| PathBuf::from(val.to_os_string()))
109-
.unwrap_or(PathBuf::from("vendor"));
109+
.unwrap_or_else(|| PathBuf::from("vendor"));
110110
ops::vendor(
111111
&ws,
112112
&ops::VendorOptions {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ fn compute_metadata<'a, 'cfg>(
559559
} else {
560560
cx.bcx.rustflags_args(unit)
561561
}
562-
.into_iter();
562+
.iter();
563563

564564
// Ignore some flags. These may affect reproducible builds if they affect
565565
// the path. The fingerprint will handle recompilation if these change.

src/cargo/core/compiler/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1309,7 +1309,7 @@ fn replay_output_cache(
13091309
}
13101310
let contents = fs::read_to_string(&path)?;
13111311
for line in contents.lines() {
1312-
on_stderr_line(state, &line, package_id, &target, &mut options)?;
1312+
on_stderr_line(state, line, package_id, &target, &mut options)?;
13131313
}
13141314
Ok(())
13151315
})

src/cargo/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#![warn(rust_2018_idioms)]
44
// Clippy isn't enforced by CI (@alexcrichton isn't a fan).
55
#![allow(clippy::blacklisted_name)] // frequently used in tests
6-
#![allow(clippy::cyclomatic_complexity)] // large project
6+
#![allow(clippy::cognitive_complexity)] // large project
77
#![allow(clippy::derive_hash_xor_eq)] // there's an intentional incoherence
88
#![allow(clippy::explicit_into_iter_loop)] // explicit loops are clearer
99
#![allow(clippy::explicit_iter_loop)] // explicit loops are clearer

src/cargo/ops/vendor.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> {
2727
}
2828
let workspaces = extra_workspaces.iter().chain(Some(ws)).collect::<Vec<_>>();
2929
let vendor_config =
30-
sync(ws.config(), &workspaces, opts).chain_err(|| format!("failed to sync"))?;
30+
sync(ws.config(), &workspaces, opts).chain_err(|| "failed to sync".to_string())?;
3131

3232
let shell = ws.config().shell();
3333
if shell.verbosity() != Verbosity::Quiet {
@@ -97,7 +97,7 @@ fn sync(
9797
// crate to work with.
9898
for ws in workspaces {
9999
let (packages, resolve) =
100-
ops::resolve_ws(&ws).chain_err(|| "failed to load pkg lockfile")?;
100+
ops::resolve_ws(ws).chain_err(|| "failed to load pkg lockfile")?;
101101

102102
packages
103103
.get_many(resolve.iter())
@@ -129,7 +129,7 @@ fn sync(
129129
// tables about them.
130130
for ws in workspaces {
131131
let (packages, resolve) =
132-
ops::resolve_ws(&ws).chain_err(|| "failed to load pkg lockfile")?;
132+
ops::resolve_ws(ws).chain_err(|| "failed to load pkg lockfile")?;
133133

134134
packages
135135
.get_many(resolve.iter())
@@ -142,14 +142,14 @@ fn sync(
142142
continue;
143143
}
144144
ids.insert(
145-
pkg.clone(),
145+
pkg,
146146
packages
147147
.get_one(pkg)
148148
.chain_err(|| "failed to fetch package")?
149149
.clone(),
150150
);
151151

152-
checksums.insert(pkg.clone(), resolve.checksums().get(&pkg).cloned());
152+
checksums.insert(pkg, resolve.checksums().get(&pkg).cloned());
153153
}
154154
}
155155

@@ -204,10 +204,10 @@ fn sync(
204204
)?;
205205

206206
let _ = fs::remove_dir_all(&dst);
207-
let pathsource = PathSource::new(&src, id.source_id(), config);
208-
let paths = pathsource.list_files(&pkg)?;
207+
let pathsource = PathSource::new(src, id.source_id(), config);
208+
let paths = pathsource.list_files(pkg)?;
209209
let mut map = BTreeMap::new();
210-
cp_sources(&src, &paths, &dst, &mut map)
210+
cp_sources(src, &paths, &dst, &mut map)
211211
.chain_err(|| format!("failed to copy over vendored sources for: {}", id))?;
212212

213213
// Finally, emit the metadata about this package

tests/testsuite/resolve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ fn pub_fail() {
246246
pkg!(("e", "0.0.6") => [dep_req_kind("a", "<= 0.0.4", Kind::Normal, true),]),
247247
pkg!(("kB", "0.0.3") => [dep_req("a", ">= 0.0.5"),dep("e"),]),
248248
];
249-
let reg = registry(input.clone());
249+
let reg = registry(input);
250250
assert!(resolve_and_validated(pkg_id("root"), vec![dep("kB")], &reg, None).is_err());
251251
}
252252

tests/testsuite/support/resolver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl SatResolve {
428428
.unwrap_or(&empty_vec)
429429
.iter()
430430
.filter(|&p| dep.matches_id(*p))
431-
.map(|p| self.var_for_is_packages_used[&p].positive())
431+
.map(|p| self.var_for_is_packages_used[p].positive())
432432
.collect();
433433
if matches.is_empty() {
434434
return false;

0 commit comments

Comments
 (0)