Skip to content

Commit 9ef364a

Browse files
committed
Auto merge of #7019 - matthiaskrgr:clippy_v5, r=Eh2406
fix bunch of clippy warnings
2 parents 65e3885 + dac967c commit 9ef364a

File tree

8 files changed

+23
-20
lines changed

8 files changed

+23
-20
lines changed

src/bin/cargo/commands/vendor.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,20 +93,24 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
9393
None
9494
};
9595
if let Some(flag) = crates_io_cargo_vendor_flag {
96-
return Err(failure::format_err!("\
96+
return Err(failure::format_err!(
97+
"\
9798
the crates.io `cargo vendor` command has now been merged into Cargo itself
9899
and does not support the flag `{}` currently; to continue using the flag you
99100
can execute `cargo-vendor vendor ...`, and if you would like to see this flag
100101
supported in Cargo itself please feel free to file an issue at
101102
https://github.com/rust-lang/cargo/issues/new
102-
", flag).into());
103+
",
104+
flag
105+
)
106+
.into());
103107
}
104108

105109
let ws = args.workspace(config)?;
106110
let path = args
107111
.value_of_os("path")
108112
.map(|val| PathBuf::from(val.to_os_string()))
109-
.unwrap_or(PathBuf::from("vendor"));
113+
.unwrap_or_else(|| PathBuf::from("vendor"));
110114
ops::vendor(
111115
&ws,
112116
&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 & 2 deletions
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
@@ -160,7 +160,6 @@ fn handle_cause(cargo_err: &Error, shell: &mut Shell) -> bool {
160160

161161
// The first error has already been printed to the shell.
162162
for err in cargo_err.iter_causes() {
163-
164163
// If we're not in verbose mode then print remaining errors until one
165164
// marked as `Internal` appears.
166165
if verbose != Verbose && err.downcast_ref::<Internal>().is_some() {

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

src/cargo/util/sha256.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
use self::crypto_hash::{Algorithm, Hasher};
2-
use std::fs::File;
2+
use crate::util::{CargoResult, CargoResultExt};
33
use crypto_hash;
4-
use std::io::{self, Write, Read};
4+
use std::fs::File;
5+
use std::io::{self, Read, Write};
56
use std::path::Path;
6-
use crate::util::{CargoResult, CargoResultExt};
77

88
pub struct Sha256(Hasher);
99

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)