diff --git a/crates/turborepo-cache/src/cache_archive/create.rs b/crates/turborepo-cache/src/cache_archive/create.rs index e560d5e1d7543..acc8a03a61c30 100644 --- a/crates/turborepo-cache/src/cache_archive/create.rs +++ b/crates/turborepo-cache/src/cache_archive/create.rs @@ -161,7 +161,7 @@ mod tests { fn create_entry(anchor: &AbsoluteSystemPath, file: &CreateFileDefinition) -> Result<()> { match &file.file_type { FileType::Dir => create_dir(anchor, file), - FileType::Symlink { linkname } => create_symlink(anchor, file, &linkname), + FileType::Symlink { linkname } => create_symlink(anchor, file, linkname), FileType::Fifo => create_fifo(anchor, file), FileType::File => create_file(anchor, file), } @@ -185,7 +185,7 @@ mod tests { linkname: &str, ) -> Result<()> { let path = anchor.resolve(&file.path); - path.symlink_to_file(&linkname)?; + path.symlink_to_file(linkname)?; Ok(()) } @@ -407,7 +407,7 @@ mod tests { fn test_compression() -> Result<()> { let mut buffer = Vec::new(); let mut encoder = zstd::Encoder::new(&mut buffer, 0)?.auto_finish(); - encoder.write(b"hello world")?; + encoder.write_all(b"hello world")?; // Should finish encoding on drop drop(encoder); diff --git a/crates/turborepo-cache/src/cache_archive/restore.rs b/crates/turborepo-cache/src/cache_archive/restore.rs index ced34fa0f977f..335046b0af01c 100644 --- a/crates/turborepo-cache/src/cache_archive/restore.rs +++ b/crates/turborepo-cache/src/cache_archive/restore.rs @@ -342,7 +342,7 @@ mod tests { for (tar_bytes, is_compressed) in [(&uncompressed_tar[..], false), (&compressed_tar[..], true)] { - let mut cache_reader = CacheReader::new(&tar_bytes[..], is_compressed)?; + let mut cache_reader = CacheReader::new(tar_bytes, is_compressed)?; let output_dir = tempdir()?; let output_dir_path = output_dir.path().to_string_lossy(); let anchor = AbsoluteSystemPath::new(&output_dir_path)?; @@ -365,7 +365,7 @@ mod tests { for (tar_bytes, is_compressed) in [(&uncompressed_tar[..], false), (&compressed_tar[..], true)] { - let mut cache_reader = CacheReader::new(&tar_bytes[..], is_compressed)?; + let mut cache_reader = CacheReader::new(tar_bytes, is_compressed)?; let output_dir = tempdir()?; let output_dir_path = output_dir.path().to_string_lossy(); let anchor = AbsoluteSystemPath::new(&output_dir_path)?; diff --git a/crates/turborepo-cache/src/signature_authentication.rs b/crates/turborepo-cache/src/signature_authentication.rs index b5071cfa2aaec..9ab7dc12839ca 100644 --- a/crates/turborepo-cache/src/signature_authentication.rs +++ b/crates/turborepo-cache/src/signature_authentication.rs @@ -101,7 +101,7 @@ impl ArtifactSignatureAuthenticator { let mut mac = HmacSha256::new_from_slice(&self.secret_key()?)?; let message = self.construct_metadata(hash)?; mac.update(&message); - mac.update(&artifact_body); + mac.update(artifact_body); let expected_bytes = BASE64_STANDARD.decode(expected_tag)?; Ok(mac.verify_slice(&expected_bytes).is_ok()) @@ -124,7 +124,7 @@ mod tests { let mut mac = HmacSha256::new_from_slice(&self.secret_key()?)?; let message = self.construct_metadata(hash)?; mac.update(&message); - mac.update(&artifact_body); + mac.update(artifact_body); Ok(mac.verify_slice(expected_tag).is_ok()) } diff --git a/crates/turborepo-globwalk/src/lib.rs b/crates/turborepo-globwalk/src/lib.rs index 4a10aa9a143f5..34dbe55d8d603 100644 --- a/crates/turborepo-globwalk/src/lib.rs +++ b/crates/turborepo-globwalk/src/lib.rs @@ -1,5 +1,4 @@ #![feature(assert_matches)] -#![feature(once_cell)] mod empty_glob; @@ -324,7 +323,7 @@ fn collapse_path(path: &str) -> Option<(Cow, usize)> { Some((Cow::Borrowed(path), lowest_index)) } else { let string = if is_root { - std::iter::once("").chain(stack.into_iter()).join("/") + std::iter::once("").chain(stack).join("/") } else { stack.join("/") }; @@ -502,7 +501,7 @@ mod test { let expected = format!( "{}{}", ROOT, - base_path_exp.replace("/", std::path::MAIN_SEPARATOR_STR) + base_path_exp.replace('/', std::path::MAIN_SEPARATOR_STR) ); assert_eq!(result_path.to_string_lossy(), expected); @@ -1316,7 +1315,7 @@ mod test { .iter() .map(|p| { p.trim_start_matches('/') - .replace("/", std::path::MAIN_SEPARATOR_STR) + .replace('/', std::path::MAIN_SEPARATOR_STR) }) .sorted() .collect::>(); @@ -1427,17 +1426,14 @@ mod test { relative.to_string() }) .collect::>(); - let expected: HashSet = HashSet::from_iter( - [ - "docs/package.json" - .replace("/", std::path::MAIN_SEPARATOR_STR) - .to_string(), - "apps/some-app/package.json" - .replace("/", std::path::MAIN_SEPARATOR_STR) - .to_string(), - ] - .into_iter(), - ); + let expected: HashSet = HashSet::from_iter([ + "docs/package.json" + .replace('/', std::path::MAIN_SEPARATOR_STR) + .to_string(), + "apps/some-app/package.json" + .replace('/', std::path::MAIN_SEPARATOR_STR) + .to_string(), + ]); assert_eq!(paths, expected); } } diff --git a/crates/turborepo-lib/src/cli.rs b/crates/turborepo-lib/src/cli.rs index e3cc5b7eddc11..6fcd93adf3d49 100644 --- a/crates/turborepo-lib/src/cli.rs +++ b/crates/turborepo-lib/src/cli.rs @@ -651,6 +651,7 @@ pub async fn run( Ok(Payload::Rust(Ok(0))) } + #[allow(unused_variables)] Command::Daemon { command, idle_time } => { let base = CommandBase::new(cli_args.clone(), repo_root, version, ui)?; diff --git a/crates/turborepo-lib/src/config/turbo.rs b/crates/turborepo-lib/src/config/turbo.rs index 8c44507b27e3f..669923d912e1f 100644 --- a/crates/turborepo-lib/src/config/turbo.rs +++ b/crates/turborepo-lib/src/config/turbo.rs @@ -342,8 +342,7 @@ impl TryFrom for TurboJson { pipeline: raw_turbo .pipeline .into_iter() - .map(|p| p.0) - .flatten() + .flat_map(|p| p.0) .map(|(task_name, task_definition)| Ok((task_name, task_definition.try_into()?))) .collect::, Error>>()?, // copy these over, we don't need any changes here. diff --git a/crates/turborepo-lib/src/globwatcher/mod.rs b/crates/turborepo-lib/src/globwatcher/mod.rs index 05f833d68a3e9..145de65913ce6 100644 --- a/crates/turborepo-lib/src/globwatcher/mod.rs +++ b/crates/turborepo-lib/src/globwatcher/mod.rs @@ -415,11 +415,7 @@ mod test { println!("{:?} {:?}", include, exclude); watcher - .watch_globs( - hash.clone(), - include.clone().into_iter(), - exclude.clone().into_iter(), - ) + .watch_globs(hash.clone(), include.clone(), exclude.clone()) .await .unwrap(); @@ -532,19 +528,15 @@ mod test { let globs2_exclusion = ["my-pkg/.next/cache/**".to_string()]; watcher - .watch_globs( - hash1.clone(), - globs1_inclusion.clone().into_iter(), - vec![].into_iter(), - ) + .watch_globs(hash1.clone(), globs1_inclusion.clone(), vec![]) .await .unwrap(); watcher .watch_globs( hash2.clone(), - globs2_inclusion.clone().into_iter(), - globs2_exclusion.clone().into_iter(), + globs2_inclusion.clone(), + globs2_exclusion.clone(), ) .await .unwrap(); @@ -650,11 +642,7 @@ mod test { let inclusions = ["my-pkg/.next/next-file".to_string()]; watcher - .watch_globs( - hash.clone(), - inclusions.clone().into_iter(), - vec![].into_iter(), - ) + .watch_globs(hash.clone(), inclusions.clone(), vec![]) .await .unwrap(); diff --git a/crates/turborepo-lib/src/package_graph/builder.rs b/crates/turborepo-lib/src/package_graph/builder.rs index f7c95b06bff79..1238e4b80fd20 100644 --- a/crates/turborepo-lib/src/package_graph/builder.rs +++ b/crates/turborepo-lib/src/package_graph/builder.rs @@ -452,7 +452,7 @@ impl Dependencies { .map_or(false, |workspace_version| { DependencyVersion::new(version).matches_workspace_package( workspace_version, - &workspace_dir, + workspace_dir, repo_root, ) }); diff --git a/crates/turborepo-lib/src/package_graph/mod.rs b/crates/turborepo-lib/src/package_graph/mod.rs index f3b314330756a..ad36eb87a7370 100644 --- a/crates/turborepo-lib/src/package_graph/mod.rs +++ b/crates/turborepo-lib/src/package_graph/mod.rs @@ -239,13 +239,13 @@ mod test { { match key { "key:a" => Ok(Some( - vec![("c", "1")] + [("c", "1")] .iter() .map(|(k, v)| (k.to_string(), v.to_string())) .collect(), )), "key:b" => Ok(Some( - vec![("c", "1")] + [("c", "1")] .iter() .map(|(k, v)| (k.to_string(), v.to_string())) .collect(), diff --git a/crates/turborepo-lib/src/package_manager/mod.rs b/crates/turborepo-lib/src/package_manager/mod.rs index 2b8ef60c4a1de..c06632a70eddd 100644 --- a/crates/turborepo-lib/src/package_manager/mod.rs +++ b/crates/turborepo-lib/src/package_manager/mod.rs @@ -461,40 +461,34 @@ mod tests { let examples = root.join_component("examples"); let with_yarn = examples.join_component("with-yarn"); - let with_yarn_expected: HashSet = HashSet::from_iter( - [ - with_yarn.join_components(&["apps", "docs", "package.json"]), - with_yarn.join_components(&["apps", "web", "package.json"]), - with_yarn.join_components(&["packages", "eslint-config-custom", "package.json"]), - with_yarn.join_components(&["packages", "tsconfig", "package.json"]), - with_yarn.join_components(&["packages", "ui", "package.json"]), - ] - .into_iter(), - ); + let with_yarn_expected: HashSet = HashSet::from_iter([ + with_yarn.join_components(&["apps", "docs", "package.json"]), + with_yarn.join_components(&["apps", "web", "package.json"]), + with_yarn.join_components(&["packages", "eslint-config-custom", "package.json"]), + with_yarn.join_components(&["packages", "tsconfig", "package.json"]), + with_yarn.join_components(&["packages", "ui", "package.json"]), + ]); for mgr in &[ PackageManager::Berry, PackageManager::Yarn, PackageManager::Npm, ] { let found = mgr.get_package_jsons(&with_yarn).unwrap(); - let found: HashSet = HashSet::from_iter(found.into_iter()); + let found: HashSet = HashSet::from_iter(found); assert_eq!(found, with_yarn_expected); } let basic = examples.join_component("basic"); - let basic_expected: HashSet = HashSet::from_iter( - [ - basic.join_components(&["apps", "docs", "package.json"]), - basic.join_components(&["apps", "web", "package.json"]), - basic.join_components(&["packages", "eslint-config-custom", "package.json"]), - basic.join_components(&["packages", "tsconfig", "package.json"]), - basic.join_components(&["packages", "ui", "package.json"]), - ] - .into_iter(), - ); + let basic_expected: HashSet = HashSet::from_iter([ + basic.join_components(&["apps", "docs", "package.json"]), + basic.join_components(&["apps", "web", "package.json"]), + basic.join_components(&["packages", "eslint-config-custom", "package.json"]), + basic.join_components(&["packages", "tsconfig", "package.json"]), + basic.join_components(&["packages", "ui", "package.json"]), + ]); for mgr in &[PackageManager::Pnpm, PackageManager::Pnpm6] { let found = mgr.get_package_jsons(&basic).unwrap(); - let found: HashSet = HashSet::from_iter(found.into_iter()); + let found: HashSet = HashSet::from_iter(found); assert_eq!(found, basic_expected); } } @@ -517,7 +511,7 @@ mod tests { PackageManager::Pnpm6, ] { let globs = mgr.get_workspace_globs(&fixtures).unwrap(); - let ignores: HashSet = HashSet::from_iter(globs.raw_exclusions.into_iter()); + let ignores: HashSet = HashSet::from_iter(globs.raw_exclusions); let expected: &[&str] = match mgr { PackageManager::Npm => &["**/node_modules/**"], PackageManager::Berry => &["**/node_modules", "**/.git", "**/.yarn"], diff --git a/crates/turborepo-lib/src/run/scope/filter.rs b/crates/turborepo-lib/src/run/scope/filter.rs index 5aa3e18a2ed9a..9cffcdeaa0ac4 100644 --- a/crates/turborepo-lib/src/run/scope/filter.rs +++ b/crates/turborepo-lib/src/run/scope/filter.rs @@ -25,7 +25,7 @@ impl PackageInference { ); let full_inference_path = turbo_root.resolve(pkg_inference_path); for (workspace_name, workspace_entry) in pkg_graph.workspaces() { - let pkg_path = turbo_root.resolve(&workspace_entry.package_json_path()); + let pkg_path = turbo_root.resolve(workspace_entry.package_json_path()); let inferred_path_is_below = pkg_path.contains(&full_inference_path); // We skip over the root package as the inferred path will always be below it if inferred_path_is_below && (&pkg_path as &AbsoluteSystemPath) != turbo_root { diff --git a/crates/turborepo-lib/src/run/scope/mod.rs b/crates/turborepo-lib/src/run/scope/mod.rs index 660cad5c5138d..958b936b4909c 100644 --- a/crates/turborepo-lib/src/run/scope/mod.rs +++ b/crates/turborepo-lib/src/run/scope/mod.rs @@ -16,7 +16,7 @@ pub fn resolve_packages( _scm: &SCM, ) -> Result> { let _pkg_inference = opts.pkg_inference_root.as_ref().map(|pkg_inference_path| { - PackageInference::calculate(&base.repo_root, &pkg_inference_path, pkg_graph) + PackageInference::calculate(&base.repo_root, pkg_inference_path, pkg_graph) }); warn!("resolve packages not implemented yet"); Ok(HashSet::new()) diff --git a/crates/turborepo-lockfiles/src/lib.rs b/crates/turborepo-lockfiles/src/lib.rs index 6c59cbbe6f2ea..bc6c53e089620 100644 --- a/crates/turborepo-lockfiles/src/lib.rs +++ b/crates/turborepo-lockfiles/src/lib.rs @@ -1,5 +1,3 @@ -#![feature(once_cell)] - mod berry; mod error; mod npm; diff --git a/crates/turborepo-lockfiles/src/yarn1/de.rs b/crates/turborepo-lockfiles/src/yarn1/de.rs index 436cc6eedbf40..b0da7d08e3089 100644 --- a/crates/turborepo-lockfiles/src/yarn1/de.rs +++ b/crates/turborepo-lockfiles/src/yarn1/de.rs @@ -109,7 +109,7 @@ fn multikey_property_statement( Ok(( i, std::iter::once(property) - .chain(others.into_iter()) + .chain(others) .map(|key| (key, value.clone())) .collect(), )) diff --git a/crates/turborepo-scm/src/git.rs b/crates/turborepo-scm/src/git.rs index 4d0e5de623e89..2a3149093393f 100644 --- a/crates/turborepo-scm/src/git.rs +++ b/crates/turborepo-scm/src/git.rs @@ -79,7 +79,7 @@ impl Git { let output = self.execute_git_command(&["diff", "--name-only", to_commit], pathspec)?; - self.add_files_from_stdout(&mut files, &turbo_root, output); + self.add_files_from_stdout(&mut files, turbo_root, output); if let Some(from_commit) = from_commit { let output = self.execute_git_command( @@ -91,13 +91,13 @@ impl Git { pathspec, )?; - self.add_files_from_stdout(&mut files, &turbo_root, output); + self.add_files_from_stdout(&mut files, turbo_root, output); } let output = self.execute_git_command(&["ls-files", "--others", "--exclude-standard"], pathspec)?; - self.add_files_from_stdout(&mut files, &turbo_root, output); + self.add_files_from_stdout(&mut files, turbo_root, output); Ok(files) } @@ -126,7 +126,7 @@ impl Git { turbo_root: &AbsoluteSystemPath, stdout: Vec, ) { - let turbo_root = turbo_root.as_ref(); + let turbo_root = turbo_root; let stdout = String::from_utf8(stdout).unwrap(); for line in stdout.lines() { let path = RelativeUnixPath::new(line).unwrap(); @@ -194,7 +194,7 @@ pub fn previous_content( // Note that we assume any relative file path is relative to the git root // FIXME: this is probably wrong. We should know the path to the lockfile // exactly - let absolute_file_path = AbsoluteSystemPathBuf::from_unknown(&git_root, &file_path); + let absolute_file_path = AbsoluteSystemPathBuf::from_unknown(&git_root, file_path); scm.previous_content(from_commit, &absolute_file_path) } diff --git a/crates/turborepo-scm/src/hash_object.rs b/crates/turborepo-scm/src/hash_object.rs index feebd4938e058..a98ac36fd8ee0 100644 --- a/crates/turborepo-scm/src/hash_object.rs +++ b/crates/turborepo-scm/src/hash_object.rs @@ -87,7 +87,7 @@ mod test { let git_to_pkg_path = git_root.anchor(pkg_path).unwrap(); let pkg_prefix = git_to_pkg_path.to_unix().unwrap(); - let expected_hashes = GitHashes::from_iter(file_hashes.into_iter()); + let expected_hashes = GitHashes::from_iter(file_hashes); let mut hashes = GitHashes::new(); let to_hash = expected_hashes.keys().map(|k| pkg_prefix.join(k)).collect(); hash_objects(&git_root, pkg_path, to_hash, &mut hashes).unwrap(); @@ -110,8 +110,8 @@ mod test { .collect(); let mut hashes = GitHashes::new(); - let result = hash_objects(&git_root, &pkg_path, to_hash, &mut hashes); - assert_eq!(result.is_err(), true); + let result = hash_objects(&git_root, pkg_path, to_hash, &mut hashes); + assert!(result.is_err()); } } } diff --git a/crates/turborepo-scm/src/ls_tree.rs b/crates/turborepo-scm/src/ls_tree.rs index 3f84b82b557c9..92602bb2d0c1b 100644 --- a/crates/turborepo-scm/src/ls_tree.rs +++ b/crates/turborepo-scm/src/ls_tree.rs @@ -85,7 +85,7 @@ mod tests { fn to_hash_map(pairs: &[(&str, &str)]) -> GitHashes { HashMap::from_iter( pairs - .into_iter() + .iter() .map(|(path, hash)| (RelativeUnixPathBuf::new(*path).unwrap(), hash.to_string())), ) } diff --git a/crates/turborepo-scm/src/manual.rs b/crates/turborepo-scm/src/manual.rs index 97cce37f437f4..354bf5912c33e 100644 --- a/crates/turborepo-scm/src/manual.rs +++ b/crates/turborepo-scm/src/manual.rs @@ -76,7 +76,7 @@ pub(crate) fn get_package_file_hashes_from_processing_gitignore>( let exclude_pattern = if excludes.is_empty() { None } else { - Some(any(excludes.into_iter())?) + Some(any(excludes)?) }; let walker = walker_builder .follow_links(false) @@ -213,7 +213,7 @@ mod tests { let mut expected = GitHashes::new(); for (raw_unix_path, contents, expected_hash) in file_hash.iter() { - let unix_path = RelativeUnixPath::new(&raw_unix_path).unwrap(); + let unix_path = RelativeUnixPath::new(raw_unix_path).unwrap(); let file_path = turbo_root.join_unix_path(unix_path).unwrap(); file_path.ensure_dir().unwrap(); file_path.create_with_contents(contents).unwrap(); @@ -237,7 +237,7 @@ mod tests { expected = GitHashes::new(); for (raw_unix_path, contents, expected_hash) in file_hash.iter() { - let unix_path = RelativeUnixPath::new(&raw_unix_path).unwrap(); + let unix_path = RelativeUnixPath::new(raw_unix_path).unwrap(); let file_path = turbo_root.join_unix_path(unix_path).unwrap(); file_path.ensure_dir().unwrap(); file_path.create_with_contents(contents).unwrap(); diff --git a/crates/turborepo-scm/src/package_deps.rs b/crates/turborepo-scm/src/package_deps.rs index 69f67b3df2209..dbb9d496a8aa9 100644 --- a/crates/turborepo-scm/src/package_deps.rs +++ b/crates/turborepo-scm/src/package_deps.rs @@ -328,13 +328,13 @@ mod tests { ), ]; for (inputs, expected_files) in input_tests { - let expected: GitHashes = HashMap::from_iter(expected_files.into_iter().map(|key| { + let expected: GitHashes = HashMap::from_iter(expected_files.iter().map(|key| { let key = RelativeUnixPathBuf::new(*key).unwrap(); let value = all_expected.get(&key).unwrap().clone(); (key, value) })); let hashes = git - .get_package_file_hashes(&repo_root, &package_path, &inputs) + .get_package_file_hashes(&repo_root, &package_path, inputs) .unwrap(); assert_eq!(hashes, expected); } @@ -344,7 +344,7 @@ mod tests { fn to_hash_map(pairs: &[(&str, &str)]) -> GitHashes { HashMap::from_iter( pairs - .into_iter() + .iter() .map(|(path, hash)| (RelativeUnixPathBuf::new(*path).unwrap(), hash.to_string())), ) } diff --git a/crates/turborepo-scm/src/status.rs b/crates/turborepo-scm/src/status.rs index abf42c62e2df3..99c196083007a 100644 --- a/crates/turborepo-scm/src/status.rs +++ b/crates/turborepo-scm/src/status.rs @@ -142,7 +142,7 @@ mod tests { fn to_hash_map(pairs: &[(&str, &str)]) -> GitHashes { HashMap::from_iter( pairs - .into_iter() + .iter() .map(|(path, hash)| (RelativeUnixPathBuf::new(*path).unwrap(), hash.to_string())), ) }