Skip to content

Commit

Permalink
build: Upgrade to Rust v1.65. (#416)
Browse files Browse the repository at this point in the history
* Bump version.

* Enable fix.

* Lint pass.

* Enable let-else.
  • Loading branch information
milesj committed Nov 14, 2022
1 parent 9bdba32 commit 2b16de2
Show file tree
Hide file tree
Showing 39 changed files with 117 additions and 157 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/benchmark.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/moon.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/docker/scaffold.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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?;

Expand Down
5 changes: 2 additions & 3 deletions crates/cli/src/commands/init/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down
2 changes: 1 addition & 1 deletion crates/cli/src/commands/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ pub async fn project(id: &str, json: bool) -> Result<(), Box<dyn std::error::Err
term.render_entry("ID", color::id(&project.id))?;

if let Some(alias) = &project.alias {
term.render_entry("Alias", color::id(&alias))?;
term.render_entry("Alias", color::id(alias))?;
}

term.render_entry("Source", color::file(&project.source))?;
Expand Down
20 changes: 10 additions & 10 deletions crates/cli/tests/init_node_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -38,7 +38,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand Down Expand Up @@ -68,7 +68,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand Down Expand Up @@ -98,7 +98,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -121,7 +121,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -145,7 +145,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -166,7 +166,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -190,7 +190,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -211,7 +211,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand All @@ -235,7 +235,7 @@ mod init_node {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand Down
16 changes: 8 additions & 8 deletions crates/cli/tests/init_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fn creates_files_in_dest() {
let assert = create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

assert.success().code(0).stdout(predicate::str::contains(
Expand All @@ -44,7 +44,7 @@ fn creates_workspace_config_from_template() {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

assert!(
Expand All @@ -65,7 +65,7 @@ fn creates_project_config_from_template() {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

assert!(
Expand All @@ -84,7 +84,7 @@ fn creates_gitignore_file() {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

assert_eq!(
Expand All @@ -105,7 +105,7 @@ fn appends_existing_gitignore_file() {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

assert_eq!(
Expand All @@ -123,14 +123,14 @@ fn does_overwrite_existing_config_if_force_passed() {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

// Run again
let assert = create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.arg("--force")
.assert();

Expand All @@ -157,7 +157,7 @@ mod vcs {
create_moon_command(root)
.arg("init")
.arg("--yes")
.arg(&root)
.arg(root)
.assert();

let content = fs::read_to_string(workspace_config).unwrap();
Expand Down
18 changes: 9 additions & 9 deletions crates/core/archive/src/tar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,12 +57,12 @@ impl<'l> 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
Expand All @@ -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)?;
Expand Down Expand Up @@ -159,12 +159,12 @@ pub fn untar<I: AsRef<Path>, O: AsRef<Path>>(

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();
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/core/archive/src/zip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ fn zip_contents<P: AsRef<str>>(
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)?)?;
Expand Down Expand Up @@ -128,7 +128,7 @@ pub fn unzip<I: AsRef<Path>, O: AsRef<Path>>(
// 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();
}
}

Expand Down
Loading

0 comments on commit 2b16de2

Please sign in to comment.