From 2b16de261709ff13f7ab2e4c63b925b5859c7dfe Mon Sep 17 00:00:00 2001 From: Miles Johnson Date: Thu, 3 Nov 2022 11:44:06 -0700 Subject: [PATCH] build: Upgrade to Rust v1.65. (#416) * Bump version. * Enable fix. * Lint pass. * Enable let-else. --- .github/workflows/benchmark.yml | 2 +- .github/workflows/moon.yml | 2 +- .github/workflows/rust.yml | 6 ++-- Makefile.toml | 2 +- crates/cli/src/commands/docker/scaffold.rs | 2 +- crates/cli/src/commands/init/mod.rs | 5 ++-- crates/cli/src/commands/project.rs | 2 +- crates/cli/tests/init_node_test.rs | 20 ++++++------- crates/cli/tests/init_test.rs | 16 +++++------ crates/core/archive/src/tar.rs | 18 ++++++------ crates/core/archive/src/zip.rs | 4 +-- crates/core/archive/tests/tar_test.rs | 28 ++++++------------- crates/core/archive/tests/zip_test.rs | 28 ++++++------------- .../core/cache/src/items/run_target_state.rs | 2 +- .../core/config/src/project/global_config.rs | 4 +-- .../core/config/src/project/local_config.rs | 6 ++-- crates/core/config/src/template/config.rs | 6 ++-- .../core/config/src/template/frontmatter.rs | 6 ++-- crates/core/config/src/workspace/config.rs | 6 ++-- crates/core/generator/src/filters.rs | 3 ++ crates/core/logger/src/color.rs | 2 +- crates/core/project-graph/src/graph.rs | 5 ++-- crates/core/runner/src/actions/run_target.rs | 2 +- crates/core/task/src/file_group.rs | 6 ++-- crates/core/task/src/target.rs | 5 ++-- crates/core/task/src/token.rs | 23 +++++---------- crates/core/toolchain/src/pms/npm.rs | 7 ++--- crates/core/toolchain/src/pms/pnpm.rs | 7 ++--- crates/core/toolchain/src/pms/yarn.rs | 7 ++--- crates/core/utils/src/fs.rs | 2 +- crates/core/utils/src/process.rs | 2 +- crates/core/utils/src/shell.rs | 5 ++-- crates/core/workspace/src/workspace.rs | 11 ++++---- .../node/platform/src/actions/install_deps.rs | 4 +-- .../node/platform/src/actions/sync_project.rs | 4 +-- crates/node/platform/src/lib.rs | 6 ++-- packages/cli/CHANGELOG.md | 4 +++ rust-toolchain.toml | 2 +- scripts/Dockerfile | 2 +- 39 files changed, 117 insertions(+), 157 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index 7c43cd0ab5f..d4bf68d987a 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -35,7 +35,7 @@ jobs: # ref: ${{ github.event.pull_request.head.sha }} - uses: actions-rs/toolchain@v1 with: - toolchain: 1.64.0 + toolchain: 1.65.0 profile: minimal - uses: Swatinem/rust-cache@v1 - name: Run benchmarks diff --git a/.github/workflows/moon.yml b/.github/workflows/moon.yml index 267ae6793e6..d1e1b883cc1 100644 --- a/.github/workflows/moon.yml +++ b/.github/workflows/moon.yml @@ -43,7 +43,7 @@ jobs: restore-keys: ${{ runner.os }}-moon-node@${{ matrix.node-version }}- - uses: actions-rs/toolchain@v1 with: - toolchain: 1.64.0 + toolchain: 1.65.0 profile: minimal - uses: Swatinem/rust-cache@v2 - uses: moonrepo/tool-version-action@v1 diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index cbe09dc85df..066da4a5cff 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -25,7 +25,7 @@ jobs: - uses: actions-rs/toolchain@v1 name: Setup toolchain with: - toolchain: 1.64.0 + toolchain: 1.65.0 profile: minimal components: rustfmt - uses: Swatinem/rust-cache@v2 @@ -46,7 +46,7 @@ jobs: - uses: actions-rs/toolchain@v1 name: Setup toolchain with: - toolchain: 1.64.0 + toolchain: 1.65.0 profile: minimal components: clippy - uses: Swatinem/rust-cache@v2 @@ -65,7 +65,7 @@ jobs: - uses: actions-rs/toolchain@v1 name: Setup toolchain with: - toolchain: 1.64.0 + toolchain: 1.65.0 profile: minimal components: llvm-tools-preview - uses: Swatinem/rust-cache@v2 diff --git a/Makefile.toml b/Makefile.toml index 72e3fa5fb2b..3c5c3d5d6cf 100644 --- a/Makefile.toml +++ b/Makefile.toml @@ -25,7 +25,7 @@ args = ["fmt", "--all", "--", "--emit=files"] [tasks.lint] command = "cargo" -args = ["clippy", "--workspace", "--all-targets"] +args = ["clippy", "--workspace", "--all-targets", "--fix"] # TESTING diff --git a/crates/cli/src/commands/docker/scaffold.rs b/crates/cli/src/commands/docker/scaffold.rs index 99868204ded..f9e86ed9c4b 100644 --- a/crates/cli/src/commands/docker/scaffold.rs +++ b/crates/cli/src/commands/docker/scaffold.rs @@ -52,7 +52,7 @@ async fn scaffold_workspace(workspace: &Workspace, docker_root: &Path) -> Result // Copy each project and mimic the folder structure for project_source in workspace.projects.projects_map.values() { - let docker_project_root = docker_workspace_root.join(&project_source); + let docker_project_root = docker_workspace_root.join(project_source); fs::create_dir_all(&docker_project_root).await?; diff --git a/crates/cli/src/commands/init/mod.rs b/crates/cli/src/commands/init/mod.rs index a9b5fe53498..f1b268a2081 100644 --- a/crates/cli/src/commands/init/mod.rs +++ b/crates/cli/src/commands/init/mod.rs @@ -138,9 +138,8 @@ pub async fn init( } // Extract template variables - let moon_dir = match verify_dest_dir(&dest_dir, &options, &theme).await? { - Some(dir) => dir, - None => return Ok(()), + let Some(moon_dir) = verify_dest_dir(&dest_dir, &options, &theme).await? else { + return Ok(()) }; let mut context = create_default_context(); diff --git a/crates/cli/src/commands/project.rs b/crates/cli/src/commands/project.rs index 505a2b057bc..bd7a89cce8f 100644 --- a/crates/cli/src/commands/project.rs +++ b/crates/cli/src/commands/project.rs @@ -23,7 +23,7 @@ pub async fn project(id: &str, json: bool) -> Result<(), Box TarArchiver<'l> { debug!( target: LOG_TARGET, "Packing tar archive from {} to {}", - color::path(&self.input_root), - color::path(&self.output_file), + color::path(self.input_root), + color::path(self.output_file), ); // Create .tar - let tar = File::create(&self.output_file) + let tar = File::create(self.output_file) .map_err(|e| map_io_to_fs_error(e, self.output_file.to_owned()))?; // Compress to .tar.gz @@ -76,24 +76,24 @@ impl<'l> TarArchiver<'l> { trace!( target: LOG_TARGET, "Source file {} does not exist, skipping", - color::path(&source) + color::path(source) ); continue; } if source.is_file() { - trace!(target: LOG_TARGET, "Packing file {}", color::path(&source)); + trace!(target: LOG_TARGET, "Packing file {}", color::path(source)); let mut fh = - File::open(&source).map_err(|e| map_io_to_fs_error(e, source.to_path_buf()))?; + File::open(source).map_err(|e| map_io_to_fs_error(e, source.to_path_buf()))?; archive.append_file(prepend_name(file, self.prefix), &mut fh)?; } else { trace!( target: LOG_TARGET, "Packing directory {}", - color::path(&source) + color::path(source) ); archive.append_dir_all(prepend_name(file, self.prefix), source)?; @@ -159,12 +159,12 @@ pub fn untar, O: AsRef>( for entry_result in archive.entries()? { let mut entry = entry_result?; - let mut path: PathBuf = entry.path()?.to_owned().to_path_buf(); + let mut path: PathBuf = entry.path()?.into_owned(); // Remove the prefix if let Some(prefix) = remove_prefix { if path.starts_with(prefix) { - path = path.strip_prefix(&prefix).unwrap().to_owned(); + path = path.strip_prefix(prefix).unwrap().to_owned(); } } diff --git a/crates/core/archive/src/zip.rs b/crates/core/archive/src/zip.rs index f841adc8d47..54e5b679065 100644 --- a/crates/core/archive/src/zip.rs +++ b/crates/core/archive/src/zip.rs @@ -32,7 +32,7 @@ fn zip_contents>( options = options.unix_permissions(path.metadata()?.permissions().mode()); } - trace!(target: LOG_TARGET, "Zipping file {}", color::path(&path)); + trace!(target: LOG_TARGET, "Zipping file {}", color::path(path)); archive.start_file(prepend_name(&name, prefix), options)?; archive.write_all(&fs::read(path)?)?; @@ -128,7 +128,7 @@ pub fn unzip, O: AsRef>( // Remove the prefix if let Some(prefix) = remove_prefix { if path.starts_with(prefix) { - path = path.strip_prefix(&prefix).unwrap().to_owned(); + path = path.strip_prefix(prefix).unwrap().to_owned(); } } diff --git a/crates/core/archive/tests/tar_test.rs b/crates/core/archive/tests/tar_test.rs index def63274f14..d9dbe1e433e 100644 --- a/crates/core/archive/tests/tar_test.rs +++ b/crates/core/archive/tests/tar_test.rs @@ -16,7 +16,7 @@ fn tars_file() { let input = fixture.path(); let archive = fixture.path().join("out.tar.gz"); - tar(&input, &string_vec!["file.txt"], &archive, None).unwrap(); + tar(input, &string_vec!["file.txt"], &archive, None).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); @@ -45,7 +45,7 @@ fn tars_file_with_prefix() { let archive = fixture.path().join("out.tar.gz"); tar( - &input, + input, &string_vec!["file.txt"], &archive, Some("some/prefix"), @@ -79,7 +79,7 @@ fn tars_file_with_prefix_thats_removed() { let archive = fixture.path().join("out.tar.gz"); tar( - &input, + input, &string_vec!["file.txt"], &archive, Some("some/prefix"), @@ -113,7 +113,7 @@ fn tars_nested_file_and_preserves_path() { let archive = fixture.path().join("out.tar.gz"); tar( - &input, + input, &string_vec!["folder/nested/other.js"], &archive, None, @@ -147,7 +147,7 @@ fn tars_file_and_dir_explicitly() { let archive = fixture.path().join("out.tar.gz"); tar( - &input, + input, &string_vec!["folder/nested", "file.txt"], &archive, None, @@ -186,7 +186,7 @@ fn tars_dir() { let input = fixture.path(); let archive = fixture.path().join("out.tar.gz"); - tar(&input, &string_vec!["folder"], &archive, None).unwrap(); + tar(input, &string_vec!["folder"], &archive, None).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); @@ -219,13 +219,7 @@ fn tars_dir_with_prefix() { let input = fixture.path(); let archive = fixture.path().join("out.tar.gz"); - tar( - &input, - &string_vec!["folder"], - &archive, - Some("some/prefix"), - ) - .unwrap(); + tar(input, &string_vec!["folder"], &archive, Some("some/prefix")).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); @@ -258,13 +252,7 @@ fn tars_dir_with_prefix_thats_removed() { let input = fixture.path(); let archive = fixture.path().join("out.tar.gz"); - tar( - &input, - &string_vec!["folder"], - &archive, - Some("some/prefix"), - ) - .unwrap(); + tar(input, &string_vec!["folder"], &archive, Some("some/prefix")).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); diff --git a/crates/core/archive/tests/zip_test.rs b/crates/core/archive/tests/zip_test.rs index 337f538c82c..612f837b3fe 100644 --- a/crates/core/archive/tests/zip_test.rs +++ b/crates/core/archive/tests/zip_test.rs @@ -16,7 +16,7 @@ fn zips_file() { let input = fixture.path(); let archive = fixture.path().join("out.zip"); - zip(&input, &string_vec!["file.txt"], &archive, None).unwrap(); + zip(input, &string_vec!["file.txt"], &archive, None).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); @@ -45,7 +45,7 @@ fn zips_file_with_prefix() { let archive = fixture.path().join("out.zip"); zip( - &input, + input, &string_vec!["file.txt"], &archive, Some("some/prefix"), @@ -79,7 +79,7 @@ fn zips_file_with_prefix_thats_removed() { let archive = fixture.path().join("out.zip"); zip( - &input, + input, &string_vec!["file.txt"], &archive, Some("some/prefix"), @@ -113,7 +113,7 @@ fn zips_nested_file_and_preserves_path() { let archive = fixture.path().join("out.zip"); zip( - &input, + input, &string_vec!["folder/nested/other.js"], &archive, None, @@ -147,7 +147,7 @@ fn zips_file_and_dir_explicitly() { let archive = fixture.path().join("out.zip"); zip( - &input, + input, &string_vec!["folder/nested", "file.txt"], &archive, None, @@ -186,7 +186,7 @@ fn zips_dir() { let input = fixture.path(); let archive = fixture.path().join("out.zip"); - zip(&input, &string_vec!["folder"], &archive, None).unwrap(); + zip(input, &string_vec!["folder"], &archive, None).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); @@ -219,13 +219,7 @@ fn zips_dir_with_prefix() { let input = fixture.path(); let archive = fixture.path().join("out.zip"); - zip( - &input, - &string_vec!["folder"], - &archive, - Some("some/prefix"), - ) - .unwrap(); + zip(input, &string_vec!["folder"], &archive, Some("some/prefix")).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); @@ -258,13 +252,7 @@ fn zips_dir_with_prefix_thats_removed() { let input = fixture.path(); let archive = fixture.path().join("out.zip"); - zip( - &input, - &string_vec!["folder"], - &archive, - Some("some/prefix"), - ) - .unwrap(); + zip(input, &string_vec!["folder"], &archive, Some("some/prefix")).unwrap(); assert!(archive.exists()); assert_ne!(archive.metadata().unwrap().len(), 0); diff --git a/crates/core/cache/src/items/run_target_state.rs b/crates/core/cache/src/items/run_target_state.rs index bc070a06c19..32b490f7cc9 100644 --- a/crates/core/cache/src/items/run_target_state.rs +++ b/crates/core/cache/src/items/run_target_state.rs @@ -64,7 +64,7 @@ impl RunTargetState { project_root: &Path, ) -> Result { if is_readable() && archive_file.exists() { - untar(&archive_file, project_root, None) + untar(archive_file, project_root, None) .map_err(|e| MoonError::Generic(e.to_string()))?; let cache_logs = self.get_output_logs(); diff --git a/crates/core/config/src/project/global_config.rs b/crates/core/config/src/project/global_config.rs index 96d9cfda8c3..a7a42f3e1d4 100644 --- a/crates/core/config/src/project/global_config.rs +++ b/crates/core/config/src/project/global_config.rs @@ -69,8 +69,8 @@ impl GlobalProjectConfig { let mut config = GlobalProjectConfig::default(); for source in gather_extended_sources(&path)? { - let figment = Figment::from(YamlExtended::file(source).profile(&profile_name)); - let extended_config = GlobalProjectConfig::load_config(figment.select(&profile_name))?; + let figment = Figment::from(YamlExtended::file(source).profile(profile_name)); + let extended_config = GlobalProjectConfig::load_config(figment.select(profile_name))?; // Figment does not merge hash maps but replaces entirely, // so we need to manually handle this here! diff --git a/crates/core/config/src/project/local_config.rs b/crates/core/config/src/project/local_config.rs index edcdb249dfe..d3888a9dc42 100644 --- a/crates/core/config/src/project/local_config.rs +++ b/crates/core/config/src/project/local_config.rs @@ -179,9 +179,9 @@ impl ProjectConfig { let path = path.as_ref(); let profile_name = "project"; let figment = - Figment::from(Serialized::defaults(ProjectConfig::default()).profile(&profile_name)) - .merge(YamlExtended::file(path).profile(&profile_name)) - .select(&profile_name); + Figment::from(Serialized::defaults(ProjectConfig::default()).profile(profile_name)) + .merge(YamlExtended::file(path).profile(profile_name)) + .select(profile_name); let mut config: ProjectConfig = figment.extract()?; diff --git a/crates/core/config/src/template/config.rs b/crates/core/config/src/template/config.rs index a91c3b1e3d0..f2c87940dc5 100644 --- a/crates/core/config/src/template/config.rs +++ b/crates/core/config/src/template/config.rs @@ -85,9 +85,9 @@ impl TemplateConfig { let path = path.as_ref(); let profile_name = "template"; let figment = - Figment::from(Serialized::defaults(TemplateConfig::default()).profile(&profile_name)) - .merge(YamlExtended::file(path).profile(&profile_name)) - .select(&profile_name); + Figment::from(Serialized::defaults(TemplateConfig::default()).profile(profile_name)) + .merge(YamlExtended::file(path).profile(profile_name)) + .select(profile_name); let config: TemplateConfig = figment.extract()?; diff --git a/crates/core/config/src/template/frontmatter.rs b/crates/core/config/src/template/frontmatter.rs index d5937c39e7d..663c2208c30 100644 --- a/crates/core/config/src/template/frontmatter.rs +++ b/crates/core/config/src/template/frontmatter.rs @@ -34,10 +34,10 @@ impl TemplateFrontmatterConfig { let profile_name = "frontmatter"; let figment = Figment::from( - Serialized::defaults(TemplateFrontmatterConfig::default()).profile(&profile_name), + Serialized::defaults(TemplateFrontmatterConfig::default()).profile(profile_name), ) - .merge(YamlExtended::string(content).profile(&profile_name)) - .select(&profile_name); + .merge(YamlExtended::string(content).profile(profile_name)) + .select(profile_name); let config: TemplateFrontmatterConfig = figment.extract()?; diff --git a/crates/core/config/src/workspace/config.rs b/crates/core/config/src/workspace/config.rs index e3391f49fa0..2071e3a2bfe 100644 --- a/crates/core/config/src/workspace/config.rs +++ b/crates/core/config/src/workspace/config.rs @@ -110,13 +110,13 @@ impl WorkspaceConfig { pub fn load(path: PathBuf) -> Result { let profile_name = "workspace"; let mut figment = - Figment::from(Serialized::defaults(WorkspaceConfig::default()).profile(&profile_name)); + Figment::from(Serialized::defaults(WorkspaceConfig::default()).profile(profile_name)); for source in gather_extended_sources(&path)? { - figment = figment.merge(YamlExtended::file(source).profile(&profile_name)); + figment = figment.merge(YamlExtended::file(source).profile(profile_name)); } - let mut config = WorkspaceConfig::load_config(figment.select(&profile_name))?; + let mut config = WorkspaceConfig::load_config(figment.select(profile_name))?; config.extends = None; if let Some(node_config) = &mut config.node { diff --git a/crates/core/generator/src/filters.rs b/crates/core/generator/src/filters.rs index 93b360bf5bf..31ecbbb10b4 100644 --- a/crates/core/generator/src/filters.rs +++ b/crates/core/generator/src/filters.rs @@ -1,3 +1,6 @@ +// HashMap is required for Tera +#![allow(clippy::disallowed_types)] + use convert_case::{Case, Casing}; use serde_json::value::{to_value, Value}; use std::collections::HashMap; diff --git a/crates/core/logger/src/color.rs b/crates/core/logger/src/color.rs index eeb47ad489f..1f301c22ddf 100644 --- a/crates/core/logger/src/color.rs +++ b/crates/core/logger/src/color.rs @@ -158,7 +158,7 @@ fn clean_path>(path: T) -> String { if let Some(home_dir) = get_home_dir() { let home_dir_str = home_dir.to_str().unwrap_or_default(); - if !home_dir_str.is_empty() && path.starts_with(&home_dir_str) { + if !home_dir_str.is_empty() && path.starts_with(home_dir_str) { path_str = path_str.replace(home_dir_str, "~"); } } diff --git a/crates/core/project-graph/src/graph.rs b/crates/core/project-graph/src/graph.rs index 9e3f4623aea..83328964c2a 100644 --- a/crates/core/project-graph/src/graph.rs +++ b/crates/core/project-graph/src/graph.rs @@ -439,9 +439,8 @@ impl ProjectGraph { ); // Create project based on ID and source - let source = match self.projects_map.get(&id) { - Some(path) => path, - None => return Err(ProjectError::UnconfiguredID(id)), + let Some(source) = self.projects_map.get(&id) else { + return Err(ProjectError::UnconfiguredID(id)); }; let project = self.create_project(&id, source)?; diff --git a/crates/core/runner/src/actions/run_target.rs b/crates/core/runner/src/actions/run_target.rs index dfeb7e733d4..f46d31a3f8e 100644 --- a/crates/core/runner/src/actions/run_target.rs +++ b/crates/core/runner/src/actions/run_target.rs @@ -418,7 +418,7 @@ impl<'a> TargetRunner<'a> { attempt_total, )?; - self.print_target_command(&context)?; + self.print_target_command(context)?; self.flush_output()?; diff --git a/crates/core/task/src/file_group.rs b/crates/core/task/src/file_group.rs index dd510c53b8e..bfd45ae202c 100644 --- a/crates/core/task/src/file_group.rs +++ b/crates/core/task/src/file_group.rs @@ -47,7 +47,7 @@ impl FileGroup { for file in &self.files { let result = path::expand_root_path(file, workspace_root, project_root); - if glob::is_glob(&file) { + if glob::is_glob(file) { globs.push(glob::normalize(result)?); } else { paths.push(result); @@ -111,8 +111,8 @@ impl FileGroup { if !dirs.is_empty() { let paths: Vec<&Path> = dirs .iter() - .filter(|d| d.starts_with(&project_root)) - .map(|d| d.strip_prefix(&project_root).unwrap()) + .filter(|d| d.starts_with(project_root)) + .map(|d| d.strip_prefix(project_root).unwrap()) .collect(); let common_dir = common_path_all(paths); diff --git a/crates/core/task/src/target.rs b/crates/core/task/src/target.rs index 612a0084c39..1107ccd6ec4 100644 --- a/crates/core/task/src/target.rs +++ b/crates/core/task/src/target.rs @@ -77,9 +77,8 @@ impl Target { return Err(TargetError::TooWild); } - let matches = match TARGET_PATTERN.captures(target_id) { - Some(result) => result, - None => return Err(TargetError::InvalidFormat(target_id.to_owned())), + let Some(matches) = TARGET_PATTERN.captures(target_id) else { + return Err(TargetError::InvalidFormat(target_id.to_owned())); }; let mut project_id = None; diff --git a/crates/core/task/src/token.rs b/crates/core/task/src/token.rs index 5c134779882..068ba778a01 100644 --- a/crates/core/task/src/token.rs +++ b/crates/core/task/src/token.rs @@ -194,7 +194,7 @@ impl<'a> TokenResolver<'a> { self.data.project_root, ); - if glob::is_glob(&value) { + if glob::is_glob(value) { globs.push(glob::normalize(resolved)?); } else { paths.push(resolved); @@ -260,11 +260,8 @@ impl<'a> TokenResolver<'a> { } pub fn resolve_var(&self, value: &str, task: &Task) -> Result { - let matches = match TOKEN_VAR_PATTERN.captures(value) { - Some(value) => value, - None => { - return Ok(value.to_owned()); - } + let Some(matches) = TOKEN_VAR_PATTERN.captures(value) else { + return Ok(value.to_owned()); }; let token = matches.get(0).unwrap().as_str(); // $var @@ -360,11 +357,8 @@ impl<'a> TokenResolver<'a> { if let TokenType::In(token, index) = token_type { let error = TokenError::InvalidInIndex(token, index); - let input = match task.inputs.get(index as usize) { - Some(i) => i, - None => { - return Err(error); - } + let Some(input) = task.inputs.get(index as usize) else { + return Err(error); }; if glob::is_glob(input) { @@ -407,11 +401,8 @@ impl<'a> TokenResolver<'a> { if let TokenType::Out(token, index) = token_type { let error = TokenError::InvalidOutIndex(token, index); - let output = match task.outputs.get(index as usize) { - Some(i) => i, - None => { - return Err(error); - } + let Some(output) = task.outputs.get(index as usize) else { + return Err(error); }; if glob::is_glob(output) { diff --git a/crates/core/toolchain/src/pms/npm.rs b/crates/core/toolchain/src/pms/npm.rs index 00223fb603c..8834920ce7e 100644 --- a/crates/core/toolchain/src/pms/npm.rs +++ b/crates/core/toolchain/src/pms/npm.rs @@ -263,11 +263,8 @@ impl PackageManager for NpmTool { &self, project_root: &Path, ) -> Result { - let lockfile_path = match fs::find_upwards(NPM.lock_filename, project_root) { - Some(path) => path, - None => { - return Ok(FxHashMap::default()); - } + let Some(lockfile_path) = fs::find_upwards(NPM.lock_filename, project_root) else { + return Ok(FxHashMap::default()); }; Ok(npm::load_lockfile_dependencies(lockfile_path)?) diff --git a/crates/core/toolchain/src/pms/pnpm.rs b/crates/core/toolchain/src/pms/pnpm.rs index 3b06cc6bee9..0f5bfabf300 100644 --- a/crates/core/toolchain/src/pms/pnpm.rs +++ b/crates/core/toolchain/src/pms/pnpm.rs @@ -191,11 +191,8 @@ impl PackageManager for PnpmTool { &self, project_root: &Path, ) -> Result { - let lockfile_path = match fs::find_upwards(PNPM.lock_filename, project_root) { - Some(path) => path, - None => { - return Ok(FxHashMap::default()); - } + let Some(lockfile_path) = fs::find_upwards(PNPM.lock_filename, project_root) else { + return Ok(FxHashMap::default()); }; Ok(pnpm::load_lockfile_dependencies(lockfile_path)?) diff --git a/crates/core/toolchain/src/pms/yarn.rs b/crates/core/toolchain/src/pms/yarn.rs index 7f5f544a3d6..8037a03442d 100644 --- a/crates/core/toolchain/src/pms/yarn.rs +++ b/crates/core/toolchain/src/pms/yarn.rs @@ -272,11 +272,8 @@ impl PackageManager for YarnTool { &self, project_root: &Path, ) -> Result { - let lockfile_path = match fs::find_upwards(YARN.lock_filename, project_root) { - Some(path) => path, - None => { - return Ok(FxHashMap::default()); - } + let Some(lockfile_path) = fs::find_upwards(YARN.lock_filename, project_root) else { + return Ok(FxHashMap::default()); }; Ok(yarn::load_lockfile_dependencies(lockfile_path).await?) diff --git a/crates/core/utils/src/fs.rs b/crates/core/utils/src/fs.rs index bace24a1a27..fc6715fe1af 100644 --- a/crates/core/utils/src/fs.rs +++ b/crates/core/utils/src/fs.rs @@ -404,7 +404,7 @@ pub mod sync { P: AsRef, { let path = path.as_ref(); - let data = read_to_string(&path).map_err(|e| map_io_to_fs_error(e, path.to_path_buf()))?; + let data = read_to_string(path).map_err(|e| map_io_to_fs_error(e, path.to_path_buf()))?; Ok(data) } diff --git a/crates/core/utils/src/process.rs b/crates/core/utils/src/process.rs index 64084bc0be3..f99b3e0e63a 100644 --- a/crates/core/utils/src/process.rs +++ b/crates/core/utils/src/process.rs @@ -87,7 +87,7 @@ impl Command { let mut command = Command { bin: String::from(bin.to_string_lossy()), - cmd: TokioCommand::new(&bin), + cmd: TokioCommand::new(bin), error_on_nonzero: true, input: vec![], log_command: false, diff --git a/crates/core/utils/src/shell.rs b/crates/core/utils/src/shell.rs index 7d8b273890c..32ad3fe4806 100644 --- a/crates/core/utils/src/shell.rs +++ b/crates/core/utils/src/shell.rs @@ -5,9 +5,8 @@ use tokio::process::Command as TokioCommand; #[cached] #[inline] fn is_program_on_path(program_name: String) -> bool { - let system_path = match env::var_os("PATH") { - Some(x) => x, - None => return false, + let Some(system_path) = env::var_os("PATH") else { + return false; }; for path_dir in env::split_paths(&system_path) { diff --git a/crates/core/workspace/src/workspace.rs b/crates/core/workspace/src/workspace.rs index eb0e8a2c301..fd8e36c9c55 100644 --- a/crates/core/workspace/src/workspace.rs +++ b/crates/core/workspace/src/workspace.rs @@ -28,10 +28,10 @@ fn find_workspace_root>(current_dir: P) -> Option { trace!( target: "moon:workspace", "Attempting to find workspace root at {}", - color::path(¤t_dir), + color::path(current_dir), ); - fs::find_upwards(constants::CONFIG_DIRNAME, ¤t_dir) + fs::find_upwards(constants::CONFIG_DIRNAME, current_dir) .map(|dir| dir.parent().unwrap().to_path_buf()) } @@ -133,16 +133,15 @@ impl Workspace { pub async fn load_from>(working_dir: P) -> Result { let working_dir = working_dir.as_ref(); - let root_dir = match find_workspace_root(working_dir) { - Some(dir) => dir, - None => return Err(WorkspaceError::MissingConfigDir), + let Some(root_dir) = find_workspace_root(working_dir) else { + return Err(WorkspaceError::MissingConfigDir); }; debug!( target: LOG_TARGET, "Creating workspace at {} (from working directory {})", color::path(&root_dir), - color::path(&working_dir) + color::path(working_dir) ); // Load configs diff --git a/crates/node/platform/src/actions/install_deps.rs b/crates/node/platform/src/actions/install_deps.rs index 8f015b5642f..cba0cb4aac2 100644 --- a/crates/node/platform/src/actions/install_deps.rs +++ b/crates/node/platform/src/actions/install_deps.rs @@ -47,7 +47,7 @@ fn add_package_manager(node: &NodeTool, package_json: &mut PackageJson) -> bool debug!( target: LOG_TARGET, "Adding package manager version to root {}", - color::file(&NPM.manifest_filename) + color::file(NPM.manifest_filename) ); return true; @@ -62,7 +62,7 @@ fn add_engines_constraint(node: &NodeTool, package_json: &mut PackageJson) -> bo debug!( target: LOG_TARGET, "Adding engines version constraint to root {}", - color::file(&NPM.manifest_filename) + color::file(NPM.manifest_filename) ); return true; diff --git a/crates/node/platform/src/actions/sync_project.rs b/crates/node/platform/src/actions/sync_project.rs index c6fb70752d1..61fd9790365 100644 --- a/crates/node/platform/src/actions/sync_project.rs +++ b/crates/node/platform/src/actions/sync_project.rs @@ -186,10 +186,10 @@ pub async fn sync_project( if let Some(dep_package_json) = PackageJson::read(&dep_project.root)? { if let Some(dep_package_name) = &dep_package_json.name { for index in ["src/index.ts", "src/index.tsx", "index.ts", "index.tsx"] { - if dep_project.root.join(&index).exists() { + if dep_project.root.join(index).exists() { tsconfig_paths.insert( dep_package_name.clone(), - vec![path::to_virtual_string(dep_relative_path.join(&index))?], + vec![path::to_virtual_string(dep_relative_path.join(index))?], ); tsconfig_paths.insert( diff --git a/crates/node/platform/src/lib.rs b/crates/node/platform/src/lib.rs index e83c8bb3dfc..24f09da21aa 100644 --- a/crates/node/platform/src/lib.rs +++ b/crates/node/platform/src/lib.rs @@ -93,7 +93,7 @@ impl Platform for NodePlatform { target: LOG_TARGET, "Project {} not within root {} workspaces, will be handled externally", color::id(project_id), - color::file(&NPM.manifest_filename) + color::file(NPM.manifest_filename) ); } @@ -120,7 +120,7 @@ impl Platform for NodePlatform { debug!( target: LOG_TARGET, "Loading names (aliases) from project {}'s", - color::file(&NPM.manifest_filename) + color::file(NPM.manifest_filename) ); for (project_id, project_source) in projects_map { @@ -239,7 +239,7 @@ impl Platform for NodePlatform { target: LOG_TARGET, "Inferring {} tasks from {}", color::id(project_id), - color::file(&NPM.manifest_filename) + color::file(NPM.manifest_filename) ); if let Some(package_json) = PackageJson::read(project_root)? { diff --git a/packages/cli/CHANGELOG.md b/packages/cli/CHANGELOG.md index f208a26142c..5ed13c5df5a 100644 --- a/packages/cli/CHANGELOG.md +++ b/packages/cli/CHANGELOG.md @@ -7,6 +7,10 @@ - Fixed an issue where passthrough args were incorrectly being passed to non-primary targets when using `moon run`. +#### ⚙️ Internal + +- Updated Rust to v1.65. + ## 0.18.2 #### 🐞 Fixes diff --git a/rust-toolchain.toml b/rust-toolchain.toml index ab814cc630c..2dfd5e72d91 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -2,4 +2,4 @@ # The default profile includes rustc, rust-std, cargo, rust-docs, rustfmt and clippy. # https://rust-lang.github.io/rustup/concepts/profiles.html profile = "default" -channel = "1.64.0" +channel = "1.65.0" diff --git a/scripts/Dockerfile b/scripts/Dockerfile index eeb6bac497c..9af300c0b3f 100644 --- a/scripts/Dockerfile +++ b/scripts/Dockerfile @@ -5,7 +5,7 @@ # glibc -FROM rust:1.64.0 AS base-gnu +FROM rust:1.65.0 AS base-gnu RUN cargo install cargo-chef --version ^0.1 WORKDIR /app COPY .cargo .cargo