diff --git a/src/cargo/core/compiler/custom_build.rs b/src/cargo/core/compiler/custom_build.rs index c88d2f84521..2a00cf23b92 100644 --- a/src/cargo/core/compiler/custom_build.rs +++ b/src/cargo/core/compiler/custom_build.rs @@ -322,7 +322,7 @@ fn build_work<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoRes } else { state.running(&cmd); let output = if extra_verbose { - state.capture_output(cmd, true) + state.capture_output(&cmd, true) } else { cmd.exec_with_output() }; diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 1c111f727ec..fe6012f66a1 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -110,7 +110,7 @@ impl<'a> JobState<'a> { pub fn capture_output( &self, - cmd: ProcessBuilder, + cmd: &ProcessBuilder, print_output: bool, ) -> CargoResult { cmd.exec_with_streaming( diff --git a/src/cargo/core/compiler/mod.rs b/src/cargo/core/compiler/mod.rs index 1427f958288..e64a84b9b4d 100644 --- a/src/cargo/core/compiler/mod.rs +++ b/src/cargo/core/compiler/mod.rs @@ -118,7 +118,7 @@ impl Executor for DefaultExecutor { _mode: CompileMode, state: &job_queue::JobState<'_>, ) -> CargoResult<()> { - state.capture_output(cmd, false).map(drop) + state.capture_output(&cmd, false).map(drop) } } @@ -645,7 +645,7 @@ fn rustdoc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> CargoResult false, ).map(drop) } else if should_capture_output { - state.capture_output(rustdoc, false).map(drop) + state.capture_output(&rustdoc, false).map(drop) } else { rustdoc.exec() }; diff --git a/src/cargo/lib.rs b/src/cargo/lib.rs index 511531e337f..36f64c949cb 100644 --- a/src/cargo/lib.rs +++ b/src/cargo/lib.rs @@ -110,7 +110,7 @@ impl fmt::Display for VersionInfo { if let Some(channel) = self.cfg_info.as_ref().map(|ci| &ci.release_channel) { if channel != "stable" { write!(f, "-{}", channel)?; - let empty = String::from(""); + let empty = String::new(); write!(f, "{}", self.pre_release.as_ref().unwrap_or(&empty))?; } }; diff --git a/src/cargo/ops/fix.rs b/src/cargo/ops/fix.rs index 662c573c215..7bc2cd405b8 100644 --- a/src/cargo/ops/fix.rs +++ b/src/cargo/ops/fix.rs @@ -270,7 +270,7 @@ fn rustfix_crate(lock_addr: &str, rustc: &Path, filename: &Path, args: &FixArgs) rustfix_and_fix(&mut fixes, rustc, filename, args)?; let mut progress_yet_to_be_made = false; for (path, file) in fixes.files.iter_mut() { - if file.errors_applying_fixes.len() == 0 { + if file.errors_applying_fixes.is_empty() { continue } // If anything was successfully fixed *and* there's at least one @@ -523,7 +523,7 @@ impl FixArgs { ret.prepare_for_edition = PrepareFor::Next; } ret.idioms = env::var(IDIOMS_ENV).is_ok(); - return ret + ret } fn apply(&self, cmd: &mut Command) { @@ -535,10 +535,7 @@ impl FixArgs { if let Some(edition) = &self.enabled_edition { cmd.arg("--edition").arg(edition); if self.idioms { - match &edition[..] { - "2018" => { cmd.arg("-Wrust-2018-idioms"); } - _ => {} - } + if edition == "2018" { cmd.arg("-Wrust-2018-idioms"); } } } match &self.prepare_for_edition { diff --git a/src/cargo/util/diagnostic_server.rs b/src/cargo/util/diagnostic_server.rs index 6f309ea063e..ae9e6c1ec2d 100644 --- a/src/cargo/util/diagnostic_server.rs +++ b/src/cargo/util/diagnostic_server.rs @@ -199,7 +199,7 @@ guide can be found at file, match edition { Some(s) => format!("with the {} edition", s), - None => format!("without an edition"), + None => "without an edition".to_string(), }, ))?; Ok(()) diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index b0521c8a34c..210fbd77e58 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -1024,12 +1024,12 @@ fn cargo_compile_with_downloaded_dependency_with_offline() { p2.cargo("build") .masquerade_as_nightly_cargo() .arg("-Zoffline"), - execs().with_stderr(format!( + execs().with_stderr( "\ [COMPILING] present_dep v1.2.3 [COMPILING] bar v0.1.0 ([..]) [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" - )), + ), ); } @@ -4439,7 +4439,7 @@ fn target_edition_feature_gated() { assert_that( p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -4451,7 +4451,7 @@ Caused by: consider adding `cargo-features = [\"edition\"]` to the manifest " - )), + ), ); } diff --git a/tests/testsuite/concurrent.rs b/tests/testsuite/concurrent.rs index 7c6bbeafdd1..8983aace37a 100644 --- a/tests/testsuite/concurrent.rs +++ b/tests/testsuite/concurrent.rs @@ -52,7 +52,7 @@ fn multiple_installs() { #[test] fn concurrent_installs() { - const LOCKED_BUILD: &'static str = "waiting for file lock on build directory"; + const LOCKED_BUILD: &str = "waiting for file lock on build directory"; pkg("foo", "0.0.1"); pkg("bar", "0.0.1"); diff --git a/tests/testsuite/config.rs b/tests/testsuite/config.rs index fc7d02d1f53..b712fdaaccc 100644 --- a/tests/testsuite/config.rs +++ b/tests/testsuite/config.rs @@ -4,6 +4,7 @@ use cargo::util::toml::{self, VecStringOrBool as VSOB}; use cargo::CargoError; use support::{execs, lines_match, paths, project}; use support::hamcrest::assert_that; +use std::borrow::Borrow; use std::collections; use std::fs; @@ -68,8 +69,9 @@ fn new_config(env: &[(&str, &str)]) -> Config { config } -fn assert_error(error: CargoError, msgs: &str) { +fn assert_error>(error: E, msgs: &str) { let causes = error + .borrow() .iter_chain() .map(|e| e.to_string()) .collect::>() diff --git a/tests/testsuite/corrupt_git.rs b/tests/testsuite/corrupt_git.rs index dc219045230..7d31575aaaa 100644 --- a/tests/testsuite/corrupt_git.rs +++ b/tests/testsuite/corrupt_git.rs @@ -38,7 +38,7 @@ fn deleting_database_files() { let mut files = Vec::new(); find_files(&paths::home().join(".cargo/git/db"), &mut files); - assert!(files.len() > 0); + assert!(!files.is_empty()); let log = "cargo::sources::git=trace"; for file in files { @@ -120,7 +120,7 @@ fn deleting_checkout_files() { .join(".git"); let mut files = Vec::new(); find_files(&dir, &mut files); - assert!(files.len() > 0); + assert!(!files.is_empty()); let log = "cargo::sources::git=trace"; for file in files { diff --git a/tests/testsuite/doc.rs b/tests/testsuite/doc.rs index ca212bf2ff6..d6898f292dc 100644 --- a/tests/testsuite/doc.rs +++ b/tests/testsuite/doc.rs @@ -626,7 +626,7 @@ fn doc_same_name() { #[test] fn doc_target() { - const TARGET: &'static str = "arm-unknown-linux-gnueabihf"; + const TARGET: &str = "arm-unknown-linux-gnueabihf"; let p = project() .file( diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index a805fc5cf8b..59d8099820d 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -61,7 +61,7 @@ fn cargo_compile_simple_git_dep() { [COMPILING] dep1 v0.5.0 ({}#[..])\n\ [COMPILING] foo v0.5.0 ({})\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - path2url(git_root.clone()), + path2url(&git_root), path2url(git_root), path2url(root) )), @@ -146,7 +146,7 @@ fn cargo_compile_offline_with_cached_git_dep() { rev = "{}" "#, git_project.url(), - rev1.clone() + rev1 ), ) .file("src/main.rs", "fn main(){}") @@ -166,7 +166,7 @@ fn cargo_compile_offline_with_cached_git_dep() { rev = "{}" "#, git_project.url(), - rev2.clone() + rev2 ).as_bytes()) .unwrap(); assert_that(prj.cargo("build"), execs()); @@ -303,7 +303,7 @@ fn cargo_compile_git_dep_branch() { [COMPILING] dep1 v0.5.0 ({}?branch=branchy#[..])\n\ [COMPILING] foo v0.5.0 ({})\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - path2url(git_root.clone()), + path2url(&git_root), path2url(git_root), path2url(root) )), @@ -376,7 +376,7 @@ fn cargo_compile_git_dep_tag() { [COMPILING] dep1 v0.5.0 ({}?tag=v0.1.0#[..])\n\ [COMPILING] foo v0.5.0 ({})\n\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]\n", - path2url(git_root.clone()), + path2url(&git_root), path2url(git_root), path2url(root) )), @@ -2674,7 +2674,7 @@ fn invalid_git_dependency_manifest() { \n\ Caused by:\n \ duplicate key: `categories` for key `project`", - path2url(git_root.clone()), + path2url(&git_root), path2url(git_root), )), ); diff --git a/tests/testsuite/init.rs b/tests/testsuite/init.rs index 7a0f6ed95b4..43dd027fc4d 100644 --- a/tests/testsuite/init.rs +++ b/tests/testsuite/init.rs @@ -403,7 +403,7 @@ fn gitignore_no_newline_in_new() { .unwrap() .read_to_string(&mut contents) .unwrap(); - assert!(!contents.starts_with("\n")); + assert!(!contents.starts_with('\n')); } #[test] @@ -446,7 +446,7 @@ fn mercurial_no_newline_in_new() { .unwrap() .read_to_string(&mut contents) .unwrap(); - assert!(!contents.starts_with("\n")); + assert!(!contents.starts_with('\n')); } #[test] diff --git a/tests/testsuite/login.rs b/tests/testsuite/login.rs index 062929a9d50..81070a335a9 100644 --- a/tests/testsuite/login.rs +++ b/tests/testsuite/login.rs @@ -60,7 +60,7 @@ fn check_token(expected_token: &str, registry: Option<&str>) -> bool { .get("registry") .and_then(|registry_table| registry_table.get("token")) .and_then(|v| match v { - &toml::Value::String(ref token) => Some(token.as_str().to_string()), + toml::Value::String(ref token) => Some(token.as_str().to_string()), _ => None, }), _ => None, diff --git a/tests/testsuite/main.rs b/tests/testsuite/main.rs index 6b89f298006..7ec164ef00c 100644 --- a/tests/testsuite/main.rs +++ b/tests/testsuite/main.rs @@ -1,4 +1,6 @@ #![deny(warnings)] +#![cfg_attr(feature = "cargo-clippy", allow(blacklisted_name))] +#![cfg_attr(feature = "cargo-clippy", allow(explicit_iter_loop))] extern crate bufstream; extern crate cargo; diff --git a/tests/testsuite/package.rs b/tests/testsuite/package.rs index 671eebebcd0..55fe71eb423 100644 --- a/tests/testsuite/package.rs +++ b/tests/testsuite/package.rs @@ -1016,7 +1016,7 @@ fn test_edition_malformed() { assert_that( p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -1025,8 +1025,8 @@ Caused by: Caused by: supported edition values are `2015` or `2018`, but `chicken` is unknown -" - )), +".to_string() + ), ); } @@ -1048,7 +1048,7 @@ fn test_edition_nightly() { assert_that( p.cargo("build").arg("-v").masquerade_as_nightly_cargo(), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ error: failed to parse manifest at `[..]` @@ -1060,7 +1060,7 @@ Caused by: consider adding `cargo-features = [\"edition\"]` to the manifest " - )), + ), ); } diff --git a/tests/testsuite/patch.rs b/tests/testsuite/patch.rs index cf815afc305..980f449459f 100644 --- a/tests/testsuite/patch.rs +++ b/tests/testsuite/patch.rs @@ -702,7 +702,7 @@ fn remove_patch() { File::create(p.root().join("Cargo.toml")) .unwrap() .write_all( - r#" + br#" [package] name = "foo" version = "0.0.1" @@ -713,7 +713,7 @@ fn remove_patch() { [patch.crates-io] bar = { path = 'bar' } - "#.as_bytes(), + "#, ) .unwrap(); assert_that(p.cargo("build"), execs()); diff --git a/tests/testsuite/publish.rs b/tests/testsuite/publish.rs index f09643f6d37..a27111a0fcc 100644 --- a/tests/testsuite/publish.rs +++ b/tests/testsuite/publish.rs @@ -51,9 +51,9 @@ See [..] // Skip the metadata payload and the size of the tarball let mut sz = [0; 4]; assert_eq!(f.read(&mut sz).unwrap(), 4); - let sz = ((sz[0] as u32) << 0) | ((sz[1] as u32) << 8) | ((sz[2] as u32) << 16) - | ((sz[3] as u32) << 24); - f.seek(SeekFrom::Current(sz as i64 + 4)).unwrap(); + let sz = (u32::from(sz[0]) << 0) | (u32::from(sz[1]) << 8) | (u32::from(sz[2]) << 16) + | (u32::from(sz[3]) << 24); + f.seek(SeekFrom::Current(i64::from(sz) + 4)).unwrap(); // Verify the tarball let mut rdr = GzDecoder::new(f); @@ -127,9 +127,9 @@ See [..] // Skip the metadata payload and the size of the tarball let mut sz = [0; 4]; assert_eq!(f.read(&mut sz).unwrap(), 4); - let sz = ((sz[0] as u32) << 0) | ((sz[1] as u32) << 8) | ((sz[2] as u32) << 16) - | ((sz[3] as u32) << 24); - f.seek(SeekFrom::Current(sz as i64 + 4)).unwrap(); + let sz = (u32::from(sz[0]) << 0) | (u32::from(sz[1]) << 8) | (u32::from(sz[2]) << 16) + | (u32::from(sz[3]) << 24); + f.seek(SeekFrom::Current(i64::from(sz) + 4)).unwrap(); // Verify the tarball let mut rdr = GzDecoder::new(f); @@ -205,15 +205,15 @@ See [..] // Skip the metadata payload and the size of the tarball let mut sz = [0; 4]; assert_eq!(f.read(&mut sz).unwrap(), 4); - let sz = ((sz[0] as u32) << 0) | ((sz[1] as u32) << 8) | ((sz[2] as u32) << 16) - | ((sz[3] as u32) << 24); - f.seek(SeekFrom::Current(sz as i64 + 4)).unwrap(); + let sz = (u32::from(sz[0]) << 0) | (u32::from(sz[1]) << 8) | (u32::from(sz[2]) << 16) + | (u32::from(sz[3]) << 24); + f.seek(SeekFrom::Current(i64::from(sz) + 4)).unwrap(); // Verify the tarball let mut rdr = GzDecoder::new(f); assert_eq!( rdr.header().unwrap().filename().unwrap(), - "foo-0.0.1.crate".as_bytes() + b"foo-0.0.1.crate" ); let mut contents = Vec::new(); rdr.read_to_end(&mut contents).unwrap(); @@ -285,15 +285,15 @@ See [..] // Skip the metadata payload and the size of the tarball let mut sz = [0; 4]; assert_eq!(f.read(&mut sz).unwrap(), 4); - let sz = ((sz[0] as u32) << 0) | ((sz[1] as u32) << 8) | ((sz[2] as u32) << 16) - | ((sz[3] as u32) << 24); - f.seek(SeekFrom::Current(sz as i64 + 4)).unwrap(); + let sz = (u32::from(sz[0]) << 0) | (u32::from(sz[1]) << 8) | (u32::from(sz[2]) << 16) + | (u32::from(sz[3]) << 24); + f.seek(SeekFrom::Current(i64::from(sz) + 4)).unwrap(); // Verify the tarball let mut rdr = GzDecoder::new(f); assert_eq!( rdr.header().unwrap().filename().unwrap(), - "foo-0.0.1.crate".as_bytes() + b"foo-0.0.1.crate" ); let mut contents = Vec::new(); rdr.read_to_end(&mut contents).unwrap(); diff --git a/tests/testsuite/required_features.rs b/tests/testsuite/required_features.rs index 64d6d0c882e..52cc4db4165 100644 --- a/tests/testsuite/required_features.rs +++ b/tests/testsuite/required_features.rs @@ -345,20 +345,20 @@ fn test_default_features() { assert_that( p.cargo("test").arg("--no-default-features"), execs() - .with_stderr(format!( + .with_stderr( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" - )) + ) .with_stdout(""), ); assert_that( p.cargo("test").arg("--test=foo"), execs() - .with_stderr(format!( + .with_stderr( "\ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..] [RUNNING] target/debug/deps/foo-[..][EXE]" - )) + ) .with_stdout_contains("test test ... ok"), ); @@ -471,9 +471,9 @@ fn test_multiple_required_features() { assert_that( p.cargo("test").arg("--no-default-features"), execs() - .with_stderr(format!( + .with_stderr( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" - )) + ) .with_stdout(""), ); } @@ -530,18 +530,18 @@ fn bench_default_features() { assert_that( p.cargo("bench").arg("--no-default-features"), execs() - .with_stderr(format!("[FINISHED] release [optimized] target(s) in [..]")) + .with_stderr("[FINISHED] release [optimized] target(s) in [..]".to_string()) .with_stdout(""), ); assert_that( p.cargo("bench").arg("--bench=foo"), execs() - .with_stderr(format!( + .with_stderr( "\ [FINISHED] release [optimized] target(s) in [..] [RUNNING] target/release/deps/foo-[..][EXE]" - )) + ) .with_stdout_contains("test bench ... bench: [..]"), ); @@ -689,7 +689,7 @@ fn bench_multiple_required_features() { assert_that( p.cargo("bench").arg("--no-default-features"), execs() - .with_stderr(format!("[FINISHED] release [optimized] target(s) in [..]")) + .with_stderr("[FINISHED] release [optimized] target(s) in [..]") .with_stdout(""), ); } @@ -728,13 +728,13 @@ fn install_default_features() { assert_that( p.cargo("install --path .").arg("--no-default-features"), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) [FINISHED] release [optimized] target(s) in [..] [ERROR] no binaries are available for install using the selected features " - )), + ), ); assert_that(cargo_home(), is_not(has_installed_exe("foo"))); @@ -749,7 +749,7 @@ fn install_default_features() { p.cargo("install --path .") .arg("--bin=foo") .arg("--no-default-features"), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) [ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be found at \ @@ -759,7 +759,7 @@ Caused by: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` " - )), + ), ); assert_that(cargo_home(), is_not(has_installed_exe("foo"))); @@ -774,7 +774,7 @@ Consider enabling them by passing e.g. `--features=\"a\"` p.cargo("install --path .") .arg("--example=foo") .arg("--no-default-features"), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) [ERROR] failed to compile `foo v0.0.1 ([..])`, intermediate artifacts can be found at \ @@ -784,7 +784,7 @@ Caused by: target `foo` in package `foo` requires the features: `a` Consider enabling them by passing e.g. `--features=\"a\"` " - )), + ), ); assert_that(cargo_home(), is_not(has_installed_exe("foo"))); } @@ -1092,9 +1092,9 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` assert_that( p.cargo("test"), execs() - .with_stderr(format!( + .with_stderr( "[FINISHED] dev [unoptimized + debuginfo] target(s) in [..]" - )) + ) .with_stdout(""), ); @@ -1119,7 +1119,7 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` assert_that( p.cargo("bench"), execs() - .with_stderr(format!("[FINISHED] release [optimized] target(s) in [..]")) + .with_stderr("[FINISHED] release [optimized] target(s) in [..]") .with_stdout(""), ); @@ -1144,13 +1144,13 @@ Consider enabling them by passing e.g. `--features=\"bar/a\"` // install assert_that( p.cargo("install --path ."), - execs().with_status(101).with_stderr(format!( + execs().with_status(101).with_stderr( "\ [INSTALLING] foo v0.0.1 ([..]) [FINISHED] release [optimized] target(s) in [..] [ERROR] no binaries are available for install using the selected features " - )), + ), ); assert_that(cargo_home(), is_not(has_installed_exe("foo"))); diff --git a/tests/testsuite/rustc.rs b/tests/testsuite/rustc.rs index cc3f6ff7d8a..20040ca6be0 100644 --- a/tests/testsuite/rustc.rs +++ b/tests/testsuite/rustc.rs @@ -1,7 +1,7 @@ use support::{basic_manifest, basic_bin_manifest, basic_lib_manifest, execs, project}; use support::hamcrest::assert_that; -const CARGO_RUSTC_ERROR: &'static str = +const CARGO_RUSTC_ERROR: &str = "[ERROR] extra arguments to `rustc` can only be passed to one target, consider filtering the package by passing e.g. `--lib` or `--bin NAME` to specify a single target"; diff --git a/tests/testsuite/rustflags.rs b/tests/testsuite/rustflags.rs index 1c81ee21d81..1940f12cf49 100644 --- a/tests/testsuite/rustflags.rs +++ b/tests/testsuite/rustflags.rs @@ -678,7 +678,7 @@ fn build_rustflags_normal_source_with_target() { ) .build(); - let ref host = rustc_host(); + let host = &rustc_host(); // Use RUSTFLAGS to pass an argument that will generate an error assert_that( diff --git a/tests/testsuite/support/git.rs b/tests/testsuite/support/git.rs index 3edbc10b637..a35f65f3ad9 100644 --- a/tests/testsuite/support/git.rs +++ b/tests/testsuite/support/git.rs @@ -130,7 +130,7 @@ pub fn add_submodule<'a>( t!(origin.fetch(&[], None, None)); t!(subrepo.checkout_head(None)); t!(s.add_finalize()); - return s; + s } pub fn commit(repo: &git2::Repository) -> git2::Oid { diff --git a/tests/testsuite/support/mod.rs b/tests/testsuite/support/mod.rs index 602e4f8a9e2..7d64d4a1f5d 100644 --- a/tests/testsuite/support/mod.rs +++ b/tests/testsuite/support/mod.rs @@ -351,7 +351,7 @@ impl Project { pub fn process>(&self, program: T) -> ProcessBuilder { let mut p = ::support::process(program); p.cwd(self.root()); - return p; + p } /// Create a `ProcessBuilder` to run cargo. @@ -361,7 +361,7 @@ impl Project { pub fn cargo(&self, cmd: &str) -> ProcessBuilder { let mut p = self.process(&cargo_exe()); split_and_add_args(&mut p, cmd); - return p; + p } /// Returns the contents of `Cargo.lock`. @@ -779,7 +779,7 @@ impl Execs { .map_err(|_| "stdout was not utf8 encoded".to_owned())?; let lines = stdout .lines() - .filter(|line| line.starts_with("{")) + .filter(|line| line.starts_with('{')) .collect::>(); if lines.len() != objects.len() { return Err(format!( @@ -935,7 +935,7 @@ impl Execs { } }; } - if a.len() > 0 { + if !a.is_empty() { Err(format!( "Output included extra lines:\n\ {}\n", @@ -1073,8 +1073,8 @@ fn find_mismatch<'a>(expected: &'a Value, actual: &'a Value) -> Option<(&'a Valu }, ); - if l.len() > 0 { - assert!(r.len() > 0); + if !l.is_empty() { + assert!(!r.is_empty()); Some((&l[0], &r[0])) } else { assert_eq!(r.len(), 0); @@ -1255,8 +1255,8 @@ pub fn basic_lib_manifest(name: &str) -> String { ) } -pub fn path2url(p: PathBuf) -> Url { - Url::from_file_path(&*p).ok().unwrap() +pub fn path2url>(p: P) -> Url { + Url::from_file_path(p).ok().unwrap() } fn substitute_macros(input: &str) -> String { @@ -1287,10 +1287,10 @@ fn substitute_macros(input: &str) -> String { ("[EXE]", if cfg!(windows) { ".exe" } else { "" }), ]; let mut result = input.to_owned(); - for &(pat, subst) in macros.iter() { + for &(pat, subst) in ¯os { result = result.replace(pat, subst) } - return result; + result } pub mod install; @@ -1357,7 +1357,7 @@ fn _process(t: &OsStr) -> cargo::util::ProcessBuilder { .env_remove("GIT_COMMITTER_EMAIL") .env_remove("CARGO_TARGET_DIR") // we assume 'target' .env_remove("MSYSTEM"); // assume cmd.exe everywhere on windows - return p; + p } pub trait ChannelChanger: Sized { diff --git a/tests/testsuite/support/registry.rs b/tests/testsuite/support/registry.rs index 4422b10290f..3e07113d872 100644 --- a/tests/testsuite/support/registry.rs +++ b/tests/testsuite/support/registry.rs @@ -289,7 +289,7 @@ impl Package { )); } - return cksum; + cksum } fn make_archive(&self) { diff --git a/tests/testsuite/tool_paths.rs b/tests/testsuite/tool_paths.rs index f5710a43a10..ab07d213508 100644 --- a/tests/testsuite/tool_paths.rs +++ b/tests/testsuite/tool_paths.rs @@ -124,7 +124,7 @@ fn relative_tools() { .build(); let foo_path = p.root().join("bar"); - let foo_url = path2url(foo_path.clone()); + let foo_url = path2url(&foo_path); let prefix = p.root().into_os_string().into_string().unwrap(); let output = if cfg!(windows) { (