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 all commits
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
10 changes: 7 additions & 3 deletions src/bin/cargo/commands/vendor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,20 +93,24 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
None
};
if let Some(flag) = crates_io_cargo_vendor_flag {
return Err(failure::format_err!("\
return Err(failure::format_err!(
"\
the crates.io `cargo vendor` command has now been merged into Cargo itself
and does not support the flag `{}` currently; to continue using the flag you
can execute `cargo-vendor vendor ...`, and if you would like to see this flag
supported in Cargo itself please feel free to file an issue at
https://github.com/rust-lang/cargo/issues/new
", flag).into());
",
flag
)
.into());
}

let ws = args.workspace(config)?;
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
3 changes: 1 addition & 2 deletions 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 Expand Up @@ -160,7 +160,6 @@ fn handle_cause(cargo_err: &Error, shell: &mut Shell) -> bool {

// The first error has already been printed to the shell.
for err in cargo_err.iter_causes() {

// If we're not in verbose mode then print remaining errors until one
// marked as `Internal` appears.
if verbose != Verbose && err.downcast_ref::<Internal>().is_some() {
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
6 changes: 3 additions & 3 deletions src/cargo/util/sha256.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use self::crypto_hash::{Algorithm, Hasher};
use std::fs::File;
use crate::util::{CargoResult, CargoResultExt};
use crypto_hash;
use std::io::{self, Write, Read};
use std::fs::File;
use std::io::{self, Read, Write};
use std::path::Path;
use crate::util::{CargoResult, CargoResultExt};

pub struct Sha256(Hasher);

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