Fix some clippy warnings.

This commit is contained in:
Eric Huss 2019-07-14 15:19:33 -07:00
parent 705009eb38
commit 9fa65608e4
12 changed files with 18 additions and 26 deletions

View File

@ -19,7 +19,7 @@ pub fn main(config: &mut Config) -> CliResult {
return super::execute_external_subcommand(config, cmd, &[cmd, "--help"]) return super::execute_external_subcommand(config, cmd, &[cmd, "--help"])
.map_err(|_| e.into()); .map_err(|_| e.into());
} else { } else {
return Err(e)?; return Err(e.into());
} }
} }
}; };

View File

@ -153,9 +153,10 @@ pub fn exec(config: &mut Config, args: &ArgMatches<'_>) -> CliResult {
let root = args.value_of("root"); let root = args.value_of("root");
if args.is_present("no-track") && !config.cli_unstable().install_upgrade { 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" "`--no-track` flag is unstable, pass `-Z install-upgrade` to enable it"
))?; )
.into());
}; };
if args.is_present("list") { if args.is_present("list") {

View File

@ -1577,7 +1577,7 @@ pub fn translate_dep_info(
(DepInfoPathType::TargetRootRelative, &*file) (DepInfoPathType::TargetRootRelative, &*file)
}; };
new_contents.push(ty as u8); new_contents.push(ty as u8);
new_contents.extend(util::path2bytes(&path)?); new_contents.extend(util::path2bytes(path)?);
new_contents.push(0); new_contents.push(0);
} }
paths::write(cargo_dep_info, &new_contents)?; paths::write(cargo_dep_info, &new_contents)?;

View File

@ -39,7 +39,7 @@ pub struct PackageOpts<'cfg> {
pub no_default_features: bool, 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<Option<FileLock>> { pub fn package(ws: &Workspace<'_>, opts: &PackageOpts<'_>) -> CargoResult<Option<FileLock>> {
if ws.root().join("Cargo.lock").exists() { if ws.root().join("Cargo.lock").exists() {

View File

@ -515,8 +515,8 @@ pub enum CommandInfo {
impl CommandInfo { impl CommandInfo {
pub fn name(&self) -> &str { pub fn name(&self) -> &str {
match self { match self {
CommandInfo::BuiltIn { name, .. } => &name, CommandInfo::BuiltIn { name, .. } => name,
CommandInfo::External { name, .. } => &name, CommandInfo::External { name, .. } => name,
} }
} }
} }

View File

@ -1058,7 +1058,7 @@ impl TomlManifest {
.any(|t| t.name() == run) .any(|t| t.name() == run)
{ {
let suggestion = 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); bail!("default-run target `{}` not found{}", run, suggestion);
} }
} }

View File

@ -46,7 +46,7 @@ fn print_available(
writeln!(output, " {}", target.name())?; writeln!(output, " {}", target.name())?;
} }
} }
Err(failure::err_msg(output))? Err(failure::err_msg(output))
} }
pub fn print_available_examples( pub fn print_available_examples(

View File

@ -1,6 +1,6 @@
use crate::support::{basic_bin_manifest, main_file, project}; use crate::support::{basic_bin_manifest, main_file, project};
static MANIFEST_OUTPUT: &'static str = r#" static MANIFEST_OUTPUT: &str = r#"
{ {
"authors": [ "authors": [
"wycats@example.com" "wycats@example.com"

View File

@ -1033,12 +1033,12 @@ impl Execs {
); );
if let (Err(_), Err(_)) = (match_std, match_err) { if let (Err(_), Err(_)) = (match_std, match_err) {
Err(format!( return Err(format!(
"expected to find:\n\ "expected to find:\n\
{}\n\n\ {}\n\n\
did not find in either output.", did not find in either output.",
expect expect
))?; ));
} }
} }

View File

@ -10,7 +10,7 @@ use std::sync::Mutex;
use filetime::{self, FileTime}; use filetime::{self, FileTime};
use lazy_static::lazy_static; use lazy_static::lazy_static;
static CARGO_INTEGRATION_TEST_DIR: &'static str = "cit"; static CARGO_INTEGRATION_TEST_DIR: &str = "cit";
lazy_static! { lazy_static! {
static ref GLOBAL_ROOT: PathBuf = { static ref GLOBAL_ROOT: PathBuf = {

View File

@ -3062,17 +3062,8 @@ fn cargo_test_env() {
let cargo = cargo_exe().canonicalize().unwrap(); let cargo = cargo_exe().canonicalize().unwrap();
p.cargo("test --lib -- --nocapture") p.cargo("test --lib -- --nocapture")
.with_stderr_contains(format!( .with_stderr_contains(cargo.to_str().unwrap())
"\ .with_stdout_contains("test env_test ... ok")
{}
",
cargo.to_str().unwrap()
))
.with_stdout_contains(format!(
"\
test env_test ... ok
",
))
.run(); .run();
} }

View File

@ -1,8 +1,8 @@
use crate::support::registry::Package; use crate::support::registry::Package;
use crate::support::{project, Project}; use crate::support::{project, Project};
static WARNING1: &'static str = "Hello! I'm a warning. :)"; static WARNING1: &str = "Hello! I'm a warning. :)";
static WARNING2: &'static str = "And one more!"; static WARNING2: &str = "And one more!";
fn make_lib(lib_src: &str) { fn make_lib(lib_src: &str) {
Package::new("bar", "0.0.1") Package::new("bar", "0.0.1")