Skip to content

Commit

Permalink
Auto merge of #8324 - matthiaskrgr:clippy_v14, r=ehuss
Browse files Browse the repository at this point in the history
fix clippy warnings
  • Loading branch information
bors committed Jun 4, 2020
2 parents 0227f04 + 6eefe3c commit 02205f5
Show file tree
Hide file tree
Showing 12 changed files with 20 additions and 25 deletions.
5 changes: 1 addition & 4 deletions crates/cargo-platform/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ pub struct ParseError {
orig: String,
}

#[non_exhaustive]
#[derive(Debug)]
pub enum ParseErrorKind {
UnterminatedString,
Expand All @@ -17,9 +18,6 @@ pub enum ParseErrorKind {
IncompleteExpr(&'static str),
UnterminatedExpression(String),
InvalidTarget(String),

#[doc(hidden)]
__Nonexhaustive,
}

impl fmt::Display for ParseError {
Expand Down Expand Up @@ -53,7 +51,6 @@ impl fmt::Display for ParseErrorKind {
write!(f, "unexpected content `{}` found after cfg expression", s)
}
InvalidTarget(s) => write!(f, "invalid target specifier: {}", s),
__Nonexhaustive => unreachable!(),
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/core/compiler/fingerprint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -894,7 +894,7 @@ impl Fingerprint {
if a.name != b.name {
let e = format_err!("`{}` != `{}`", a.name, b.name)
.context("unit dependency name changed");
return Err(e.into());
return Err(e);
}

if a.fingerprint.hash() != b.fingerprint.hash() {
Expand All @@ -906,7 +906,7 @@ impl Fingerprint {
b.fingerprint.hash()
)
.context("unit dependency information changed");
return Err(e.into());
return Err(e);
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/cargo/core/compiler/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub fn add_root_urls(
return Ok(());
}
let map = config.doc_extern_map()?;
if map.registries.len() == 0 && map.std.is_none() {
if map.registries.is_empty() && map.std.is_none() {
// Skip doing unnecessary work.
return Ok(());
}
Expand All @@ -90,13 +90,13 @@ pub fn add_root_urls(
.keys()
.filter_map(|name| {
if let Ok(index_url) = config.get_registry_index(name) {
return Some((name, index_url));
Some((name, index_url))
} else {
log::warn!(
"`doc.extern-map.{}` specifies a registry that is not defined",
name
);
return None;
None
}
})
.collect();
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ impl<'cfg> PackageRegistry<'cfg> {
.expect("loaded source not present");
let summaries = source.query_vec(dep)?;
let (summary, should_unlock) =
summary_for_patch(orig_patch, &locked, summaries, source).chain_err(|| {
summary_for_patch(orig_patch, locked, summaries, source).chain_err(|| {
format!(
"patch for `{}` in `{}` failed to resolve",
orig_patch.package_name(),
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/core/workspace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -863,7 +863,7 @@ impl<'cfg> Workspace<'cfg> {
let err = anyhow::format_err!("{}", warning.message);
let cx =
anyhow::format_err!("failed to parse manifest at `{}`", path.display());
return Err(err.context(cx).into());
return Err(err.context(cx));
} else {
let msg = if self.root_manifest.is_none() {
warning.message.to_string()
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#![allow(clippy::unneeded_field_pattern)]
// false positives in target-specific code, for details see
// https://github.com/rust-lang/cargo/pull/7251#pullrequestreview-274914270
#![allow(clippy::identity_conversion)]
#![allow(clippy::useless_conversion)]

use crate::core::shell::Verbosity::Verbose;
use crate::core::Shell;
Expand Down
4 changes: 2 additions & 2 deletions src/cargo/ops/cargo_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -570,8 +570,8 @@ where
// best-effort check to see if we can avoid hitting the network.
if let Ok(pkg) = select_dep_pkg(source, dep, config, false) {
let (_ws, rustc, target) =
make_ws_rustc_target(&config, opts, &source.source_id(), pkg.clone())?;
if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, &dst, force) {
make_ws_rustc_target(config, opts, &source.source_id(), pkg.clone())?;
if let Ok(true) = is_installed(&pkg, config, opts, &rustc, &target, root, dst, force) {
return Ok(Some(pkg));
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/ops/cargo_read_manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ fn walk(path: &Path, callback: &mut dyn FnMut(&Path) -> CargoResult<bool>) -> Ca
Err(e) => {
let cx = format!("failed to read directory `{}`", path.display());
let e = anyhow::Error::from(e);
return Err(e.context(cx).into());
return Err(e.context(cx));
}
};
for dir in dirs {
Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/flock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ fn acquire(
if !error_contended(&e) {
let e = anyhow::Error::from(e);
let cx = format!("failed to lock file: {}", path.display());
return Err(e.context(cx).into());
return Err(e.context(cx));
}
}
}
Expand Down
12 changes: 5 additions & 7 deletions src/cargo/util/process_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,11 @@ mod imp {
pub fn exec_replace(process_builder: &ProcessBuilder) -> CargoResult<()> {
let mut command = process_builder.build_command();
let error = command.exec();
Err(anyhow::Error::from(error)
.context(process_error(
&format!("could not execute process {}", process_builder),
None,
None,
))
.into())
Err(anyhow::Error::from(error).context(process_error(
&format!("could not execute process {}", process_builder),
None,
None,
)))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/cargo/util/toml/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ and this will become a hard error in the future.",
}

let first_error = anyhow::Error::from(first_error);
Err(first_error.context("could not parse input as TOML").into())
Err(first_error.context("could not parse input as TOML"))
}

type TomlLibTarget = TomlTarget;
Expand Down
2 changes: 1 addition & 1 deletion tests/testsuite/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#![allow(clippy::blacklisted_name)]
#![allow(clippy::explicit_iter_loop)]
#![allow(clippy::redundant_closure)]
#![allow(clippy::block_in_if_condition_stmt)] // clippy doesn't agree with rustfmt 😂
#![allow(clippy::blocks_in_if_conditions)] // clippy doesn't agree with rustfmt 😂
#![allow(clippy::inefficient_to_string)] // this causes suggestions that result in `(*s).to_string()`
#![warn(clippy::needless_borrow)]
#![warn(clippy::redundant_clone)]
Expand Down

0 comments on commit 02205f5

Please sign in to comment.