Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix bunch of clippy warnings #7019

Merged
merged 2 commits into from
Jun 7, 2019
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
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
  • Loading branch information
matthiaskrgr committed Jun 7, 2019
commit 64ae32774a21fb435bf72a867c77633db996965e
2 changes: 1 addition & 1 deletion src/bin/cargo/commands/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ https://github.com/rust-lang/cargo/issues/new
let path = args
.value_of_os("path")
.map(|val| PathBuf::from(val.to_os_string()))
.unwrap_or(PathBuf::from("vendor"));
.unwrap_or_else(|| PathBuf::from("vendor"));
ops::vendor(
&ws,
&ops::VendorOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/context/compilation_files.rs
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ fn compute_metadata<'a, 'cfg>(
} else {
cx.bcx.rustflags_args(unit)
}
.into_iter();
.iter();

// Ignore some flags. These may affect reproducible builds if they affect
// the path. The fingerprint will handle recompilation if these change.
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/compiler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1309,7 +1309,7 @@ fn replay_output_cache(
}
let contents = fs::read_to_string(&path)?;
for line in contents.lines() {
on_stderr_line(state, &line, package_id, &target, &mut options)?;
on_stderr_line(state, line, package_id, &target, &mut options)?;
}
Ok(())
})
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![warn(rust_2018_idioms)]
// Clippy isn't enforced by CI (@alexcrichton isn't a fan).
#![allow(clippy::blacklisted_name)] // frequently used in tests
#![allow(clippy::cyclomatic_complexity)] // large project
#![allow(clippy::cognitive_complexity)] // large project
#![allow(clippy::derive_hash_xor_eq)] // there's an intentional incoherence
#![allow(clippy::explicit_into_iter_loop)] // explicit loops are clearer
#![allow(clippy::explicit_iter_loop)] // explicit loops are clearer
Expand Down
16 changes: 8 additions & 8 deletions src/cargo/ops/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn vendor(ws: &Workspace<'_>, opts: &VendorOptions<'_>) -> CargoResult<()> {
}
let workspaces = extra_workspaces.iter().chain(Some(ws)).collect::<Vec<_>>();
let vendor_config =
sync(ws.config(), &workspaces, opts).chain_err(|| format!("failed to sync"))?;
sync(ws.config(), &workspaces, opts).chain_err(|| "failed to sync".to_string())?;

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

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

packages
.get_many(resolve.iter())
Expand All @@ -142,14 +142,14 @@ fn sync(
continue;
}
ids.insert(
pkg.clone(),
pkg,
packages
.get_one(pkg)
.chain_err(|| "failed to fetch package")?
.clone(),
);

checksums.insert(pkg.clone(), resolve.checksums().get(&pkg).cloned());
checksums.insert(pkg, resolve.checksums().get(&pkg).cloned());
}
}

Expand Down Expand Up @@ -204,10 +204,10 @@ fn sync(
)?;

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

// Finally, emit the metadata about this package
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/resolve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ fn pub_fail() {
pkg!(("e", "0.0.6") => [dep_req_kind("a", "<= 0.0.4", Kind::Normal, true),]),
pkg!(("kB", "0.0.3") => [dep_req("a", ">= 0.0.5"),dep("e"),]),
];
let reg = registry(input.clone());
let reg = registry(input);
assert!(resolve_and_validated(pkg_id("root"), vec![dep("kB")], &reg, None).is_err());
}

Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/support/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -428,7 +428,7 @@ impl SatResolve {
.unwrap_or(&empty_vec)
.iter()
.filter(|&p| dep.matches_id(*p))
.map(|p| self.var_for_is_packages_used[&p].positive())
.map(|p| self.var_for_is_packages_used[p].positive())
.collect();
if matches.is_empty() {
return false;
Expand Down