From 9fa65608e44fd7150c511e5eb8732935adc3d2b3 Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Sun, 14 Jul 2019 15:19:33 -0700 Subject: [PATCH] Fix some clippy warnings. --- src/bin/cargo/cli.rs | 2 +- src/bin/cargo/commands/install.rs | 5 +++-- src/cargo/core/compiler/fingerprint.rs | 2 +- src/cargo/ops/cargo_package.rs | 2 +- src/cargo/util/command_prelude.rs | 4 ++-- src/cargo/util/toml/mod.rs | 2 +- src/cargo/util/workspace.rs | 2 +- tests/testsuite/read_manifest.rs | 2 +- tests/testsuite/support/mod.rs | 4 ++-- tests/testsuite/support/paths.rs | 2 +- tests/testsuite/test.rs | 13 ++----------- tests/testsuite/warn_on_failure.rs | 4 ++-- 12 files changed, 18 insertions(+), 26 deletions(-) diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 36b479cc291..f5d507701aa 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -19,7 +19,7 @@ pub fn main(config: &mut Config) -> CliResult { return super::execute_external_subcommand(config, cmd, &[cmd, "--help"]) .map_err(|_| e.into()); } else { - return Err(e)?; + return Err(e.into()); } } }; diff --git a/src/bin/cargo/commands/install.rs b/src/bin/cargo/commands/install.rs index 18c1957c455..5dd0c49e093 100644 --- a/src/bin/cargo/commands/install.rs +++ b/src/bin/cargo/commands/install.rs @@ -153,9 +153,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult { let root = args.value_of("root"); if args.is_present("no-track") && !config.cli_unstable().install_upgrade { - Err(failure::format_err!( + return Err(failure::format_err!( "`--no-track` flag is unstable, pass `-Z install-upgrade` to enable it" - ))?; + ) + .into()); }; if args.is_present("list") { diff --git a/src/cargo/core/compiler/fingerprint.rs b/src/cargo/core/compiler/fingerprint.rs index d99b992e22c..d5f2ec320e7 100644 --- a/src/cargo/core/compiler/fingerprint.rs +++ b/src/cargo/core/compiler/fingerprint.rs @@ -1577,7 +1577,7 @@ pub fn translate_dep_info( (DepInfoPathType::TargetRootRelative, &*file) }; new_contents.push(ty as u8); - new_contents.extend(util::path2bytes(&path)?); + new_contents.extend(util::path2bytes(path)?); new_contents.push(0); } paths::write(cargo_dep_info, &new_contents)?; diff --git a/src/cargo/ops/cargo_package.rs b/src/cargo/ops/cargo_package.rs index c275ceb463f..2857ab3f1ad 100644 --- a/src/cargo/ops/cargo_package.rs +++ b/src/cargo/ops/cargo_package.rs @@ -39,7 +39,7 @@ pub struct PackageOpts<'cfg> { pub no_default_features: bool, } -static VCS_INFO_FILE: &'static str = ".cargo_vcs_info.json"; +static VCS_INFO_FILE: &str = ".cargo_vcs_info.json"; pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult> { if ws.root().join("Cargo.lock").exists() { diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 4ac3a06166a..207521dac1d 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -515,8 +515,8 @@ pub enum CommandInfo { impl CommandInfo { pub fn name(&self) -> &str { match self { - CommandInfo::BuiltIn { name, .. } => &name, - CommandInfo::External { name, .. } => &name, + CommandInfo::BuiltIn { name, .. } => name, + CommandInfo::External { name, .. } => name, } } } diff --git a/src/cargo/util/toml/mod.rs b/src/cargo/util/toml/mod.rs index 29f02a1ff34..e2232827885 100644 --- a/src/cargo/util/toml/mod.rs +++ b/src/cargo/util/toml/mod.rs @@ -1058,7 +1058,7 @@ impl TomlManifest { .any(|t| t.name() == run) { let suggestion = - util::closest_msg(&run, targets.iter().filter(|t| t.is_bin()), |t| t.name()); + util::closest_msg(run, targets.iter().filter(|t| t.is_bin()), |t| t.name()); bail!("default-run target `{}` not found{}", run, suggestion); } } diff --git a/src/cargo/util/workspace.rs b/src/cargo/util/workspace.rs index 46683c4573d..73ee04499b8 100644 --- a/src/cargo/util/workspace.rs +++ b/src/cargo/util/workspace.rs @@ -46,7 +46,7 @@ fn print_available( writeln!(output, " {}", target.name())?; } } - Err(failure::err_msg(output))? + Err(failure::err_msg(output)) } pub fn print_available_examples( diff --git a/tests/testsuite/read_manifest.rs b/tests/testsuite/read_manifest.rs index edfd3a76387..61e520f1499 100644 --- a/tests/testsuite/read_manifest.rs +++ b/tests/testsuite/read_manifest.rs @@ -1,6 +1,6 @@ use crate::support::{basic_bin_manifest, main_file, project}; -static MANIFEST_OUTPUT: &'static str = r#" +static MANIFEST_OUTPUT: &str = r#" { "authors": [ "wycats@example.com" diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index cd09ea240ad..a9d9982f632 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -1033,12 +1033,12 @@ impl Execs { ); if let (Err(_), Err(_)) = (match_std, match_err) { - Err(format!( + return Err(format!( "expected to find:\n\ {}\n\n\ did not find in either output.", expect - ))?; + )); } } diff --git a/tests/testsuite/support/paths.rs b/tests/testsuite/support/paths.rs index 7e62029f769..59d12a91853 100644 --- a/tests/testsuite/support/paths.rs +++ b/tests/testsuite/support/paths.rs @@ -10,7 +10,7 @@ use std::sync::Mutex; use filetime::{self, FileTime}; use lazy_static::lazy_static; -static CARGO_INTEGRATION_TEST_DIR: &'static str = "cit"; +static CARGO_INTEGRATION_TEST_DIR: &str = "cit"; lazy_static! { static ref GLOBAL_ROOT: PathBuf = { diff --git a/tests/testsuite/test.rs b/tests/testsuite/test.rs index 63f6a963e2a..3c6fb5314b8 100644 --- a/tests/testsuite/test.rs +++ b/tests/testsuite/test.rs @@ -3062,17 +3062,8 @@ fn cargo_test_env() { let cargo = cargo_exe().canonicalize().unwrap(); p.cargo("test --lib -- --nocapture") - .with_stderr_contains(format!( - "\ -{} -", - cargo.to_str().unwrap() - )) - .with_stdout_contains(format!( - "\ -test env_test ... ok -", - )) + .with_stderr_contains(cargo.to_str().unwrap()) + .with_stdout_contains("test env_test ... ok") .run(); } diff --git a/tests/testsuite/warn_on_failure.rs b/tests/testsuite/warn_on_failure.rs index 18a5305ce0d..bf662d81a77 100644 --- a/tests/testsuite/warn_on_failure.rs +++ b/tests/testsuite/warn_on_failure.rs @@ -1,8 +1,8 @@ use crate::support::registry::Package; use crate::support::{project, Project}; -static WARNING1: &'static str = "Hello! I'm a warning. :)"; -static WARNING2: &'static str = "And one more!"; +static WARNING1: &str = "Hello! I'm a warning. :)"; +static WARNING2: &str = "And one more!"; fn make_lib(lib_src: &str) { Package::new("bar", "0.0.1")