diff --git a/Cargo.toml b/Cargo.toml index c868b14a66..b152656e5b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -217,3 +217,9 @@ members = ["tests/integration/randomize_readdir"] harness = false name = "sccache_bench" test = false + +[lints] +workspace = true + +[workspace.lints.clippy] +implicit_clone = "warn" diff --git a/src/compiler/c.rs b/src/compiler/c.rs index 3e700c7cbc..2dc09d8424 100644 --- a/src/compiler/c.rs +++ b/src/compiler/c.rs @@ -381,9 +381,9 @@ where // Create an argument vector containing both preprocessor and arch args, to // use in creating a hash key let mut preprocessor_and_arch_args = self.parsed_args.preprocessor_args.clone(); - preprocessor_and_arch_args.extend(self.parsed_args.arch_args.to_vec()); + preprocessor_and_arch_args.extend(self.parsed_args.arch_args.clone()); // common_args is used in preprocessing too - preprocessor_and_arch_args.extend(self.parsed_args.common_args.to_vec()); + preprocessor_and_arch_args.extend(self.parsed_args.common_args.clone()); let absolute_input_path: Cow<'_, _> = if self.parsed_args.input.is_absolute() { Cow::Borrowed(&self.parsed_args.input) @@ -508,15 +508,15 @@ where return Ok(HashResult { key, compilation: Box::new(CCompilation { - parsed_args: self.parsed_args.to_owned(), + parsed_args: self.parsed_args.clone(), is_locally_preprocessed: false, #[cfg(feature = "dist-client")] preprocessed_input: PREPROCESSING_SKIPPED_COMPILE_POISON .to_vec(), - executable: self.executable.to_owned(), + executable: self.executable.clone(), compiler: self.compiler.to_owned(), - cwd: cwd.to_owned(), - env_vars: env_vars.to_owned(), + cwd: cwd.clone(), + env_vars: env_vars.clone(), }), weak_toolchain_key, }); @@ -622,7 +622,7 @@ where // Create an argument vector containing both common and arch args, to // use in creating a hash key let mut common_and_arch_args = self.parsed_args.common_args.clone(); - common_and_arch_args.extend(self.parsed_args.arch_args.to_vec()); + common_and_arch_args.extend(self.parsed_args.arch_args.clone()); let key = HashKeyParams::new( &self.executable_digest, diff --git a/src/compiler/compiler.rs b/src/compiler/compiler.rs index 0865c5ea3c..7f49a706d3 100644 --- a/src/compiler/compiler.rs +++ b/src/compiler/compiler.rs @@ -197,7 +197,7 @@ impl CompileCommandImpl for SingleCompileCommand { let mut cmd = creator.clone().new_command_sync(executable); cmd.args(arguments) .env_clear() - .envs(env_vars.to_vec()) + .envs(env_vars.clone()) .current_dir(cwd); run_input_output(cmd, None).await } diff --git a/src/compiler/gcc.rs b/src/compiler/gcc.rs index b740029a6e..e69906c880 100644 --- a/src/compiler/gcc.rs +++ b/src/compiler/gcc.rs @@ -1198,7 +1198,7 @@ mod test { o => panic!("Got unexpected parse result: {:?}", o), }; let mut common_and_arch_args = common_args.clone(); - common_and_arch_args.extend(common_args.to_vec()); + common_and_arch_args.extend(common_args.clone()); debug!("common_and_arch_args: {:?}", common_and_arch_args); assert_eq!(Some("foo.cpp"), input.to_str()); assert_eq!(Language::Cxx, language); diff --git a/src/compiler/msvc.rs b/src/compiler/msvc.rs index fdf4e87f5c..590fdd27cd 100644 --- a/src/compiler/msvc.rs +++ b/src/compiler/msvc.rs @@ -731,7 +731,7 @@ pub fn parse_arguments( } let (input, language) = match input_arg { Some(i) => match Language::from_file_name(Path::new(&i)) { - Some(l) => (i.to_owned(), l), + Some(l) => (i.clone(), l), None => cannot_cache!("unknown source language"), }, // We can't cache compilation without an input. diff --git a/src/compiler/nvcc.rs b/src/compiler/nvcc.rs index bf8dc6e978..ee3c3a5a57 100644 --- a/src/compiler/nvcc.rs +++ b/src/compiler/nvcc.rs @@ -822,7 +822,7 @@ where // * .cpp1.ii - cicc/ptxas input // * .cpp4.ii - cudafe++ input if out_name.ends_with(".cpp1.ii") { - Some(out_name.to_owned()) + Some(out_name.clone()) } else { None } @@ -944,7 +944,7 @@ where .args(&[arguments, &["--dryrun".into(), "--keep".into()][..]].concat()) .env_clear() .current_dir(cwd) - .envs(env_vars.to_vec()); + .envs(env_vars.clone()); let nvcc_dryrun_output = run_input_output(nvcc_dryrun_cmd, None).await?; @@ -1250,7 +1250,7 @@ where cwd, [ vec![exe.clone().into_os_string().into_string().unwrap()], - args.to_vec() + args.clone() ] .concat() .join(" ") @@ -1264,7 +1264,7 @@ where cmd.args(args) .current_dir(cwd) .env_clear() - .envs(env_vars.to_vec()); + .envs(env_vars.clone()); run_input_output(cmd, None) .await diff --git a/src/compiler/preprocessor_cache.rs b/src/compiler/preprocessor_cache.rs index 18a8127abd..8b5df88743 100644 --- a/src/compiler/preprocessor_cache.rs +++ b/src/compiler/preprocessor_cache.rs @@ -183,7 +183,7 @@ impl PreprocessorCacheEntry { for (digest, includes) in self.results.iter_mut().rev() { let result_matches = Self::result_matches(digest, includes, config, updated); if result_matches { - return Some(digest.to_string()); + return Some(digest.clone()); } } None diff --git a/src/compiler/rust.rs b/src/compiler/rust.rs index ea42d61c50..ed8a179497 100644 --- a/src/compiler/rust.rs +++ b/src/compiler/rust.rs @@ -1140,7 +1140,7 @@ fn parse_arguments(arguments: &[OsString], cwd: &Path) -> CompilerArguments extra_filename = Some(value.to_owned()), ("extra-filename", None) => cannot_cache!("extra-filename"), - ("profile-use", Some(v)) => profile = Some(v.to_string()), + ("profile-use", Some(v)) => profile = Some(v.clone()), // Incremental compilation makes a mess of sccache's entire world // view. It produces additional compiler outputs that we don't cache, // and just letting rustc do its work in incremental mode is likely @@ -1887,7 +1887,7 @@ impl Compilation for RustCompilation { fn outputs<'a>(&'a self) -> Box + 'a> { Box::new(self.outputs.iter().map(|(k, v)| FileObjectSource { - key: k.to_string(), + key: k.clone(), path: v.path.clone(), optional: v.optional, })) diff --git a/src/dist/http.rs b/src/dist/http.rs index 566b30224f..09aa862ed8 100644 --- a/src/dist/http.rs +++ b/src/dist/http.rs @@ -1314,8 +1314,8 @@ mod client { weak_key: String, toolchain_packager: Box, ) -> Result<(Toolchain, Option<(String, PathBuf)>)> { - let compiler_path = compiler_path.to_owned(); - let weak_key = weak_key.to_owned(); + let compiler_path = compiler_path.clone(); + let weak_key = weak_key.clone(); let tc_cache = self.tc_cache.clone(); self.pool diff --git a/src/server.rs b/src/server.rs index 7ceeb07f47..fe1225cfc5 100644 --- a/src/server.rs +++ b/src/server.rs @@ -531,7 +531,7 @@ pub fn start_server(config: &Config, addr: &crate::net::SocketAddr) -> Result<() SccacheServer::<_>::with_listener(l, runtime, client, dist_client, storage); Ok(( srv.local_addr() - .unwrap_or_else(|| crate::net::SocketAddr::UnixAbstract(p.to_vec())), + .unwrap_or_else(|| crate::net::SocketAddr::UnixAbstract(p.clone())), Box::new(move |f| srv.run(f)) as Box _>, )) } diff --git a/src/util.rs b/src/util.rs index 78fc55c22b..452a4969e9 100644 --- a/src/util.rs +++ b/src/util.rs @@ -255,7 +255,7 @@ impl TimeMacroFinder { } // Also check the concatenation with the previous small read if !self.previous_small_read.is_empty() { - let mut concatenated = self.previous_small_read.to_owned(); + let mut concatenated = self.previous_small_read.clone(); concatenated.extend(visit); self.find_macros(&concatenated); } diff --git a/tests/helpers/mod.rs b/tests/helpers/mod.rs index 36d528c05e..db0e978a5a 100644 --- a/tests/helpers/mod.rs +++ b/tests/helpers/mod.rs @@ -86,7 +86,7 @@ impl SccacheTest<'_> { Ok(SccacheTest { tempdir, - env: env.to_owned(), + env: env.clone(), }) }