From 97b2a692348419abbeb55a4861a4786ae6642d90 Mon Sep 17 00:00:00 2001 From: Maxime Bedard Date: Thu, 12 Aug 2021 11:06:43 -0400 Subject: [PATCH] fmt --- Makefile | 1 - crates/cli/build.rs | 16 ++++------------ crates/cli/src/opt.rs | 13 ++++++++++--- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 877339b4..dfdc56d6 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,6 @@ core: && cargo build --target=wasm32-wasi \ && cd - - tests: core cd crates/cli \ && cargo test \ diff --git a/crates/cli/build.rs b/crates/cli/build.rs index 0f47dbac..badda4c6 100644 --- a/crates/cli/build.rs +++ b/crates/cli/build.rs @@ -18,8 +18,7 @@ fn main() { // When using clippy, we need to write a stubbed engine.wasm file to ensure compilation succeeds. This // skips building the actual engine.wasm binary that would be injected into the CLI binary. fn stub_engine_for_clippy() { - let engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("engine.wasm"); + let engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("engine.wasm"); if !engine_path.exists() { std::fs::write(engine_path, &[]).expect("failed to write empty engine.wasm stub"); @@ -59,8 +58,7 @@ fn copy_engine_binary() { println!("cargo:rerun-if-changed={:?}", engine_path); if engine_path.exists() { - let copied_engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("engine.wasm"); + let copied_engine_path = PathBuf::from(env::var("OUT_DIR").unwrap()).join("engine.wasm"); fs::copy(&engine_path, &copied_engine_path).unwrap(); optimize_engine(&copied_engine_path); @@ -78,10 +76,7 @@ fn optimize_engine(engine_path: impl AsRef) { fn run_wasm_strip(engine_path: impl AsRef) { let wasm_strip = which::which("wasm-strip") - .unwrap_or_else(|_| { - PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("vendor/wasm-opt") - }); + .unwrap_or_else(|_| PathBuf::from(env::var("OUT_DIR").unwrap()).join("vendor/wasm-opt")); let output = Command::new(wasm_strip) .arg(engine_path.as_ref()) @@ -96,10 +91,7 @@ fn run_wasm_strip(engine_path: impl AsRef) { fn run_wasm_opt(engine_path: impl AsRef) { let wasm_opt = which::which("wasm-opt") - .unwrap_or_else(|_| { - PathBuf::from(env::var("OUT_DIR").unwrap()) - .join("vendor/wasm-opt") - }); + .unwrap_or_else(|_| PathBuf::from(env::var("OUT_DIR").unwrap()).join("vendor/wasm-opt")); let output = Command::new(wasm_opt) .arg(engine_path.as_ref()) diff --git a/crates/cli/src/opt.rs b/crates/cli/src/opt.rs index b26ccbd9..1abf9ed6 100644 --- a/crates/cli/src/opt.rs +++ b/crates/cli/src/opt.rs @@ -1,5 +1,5 @@ use anyhow::{bail, Error, Result}; -use std::path::{PathBuf, Path}; +use std::path::{Path, PathBuf}; use std::process::Command; use wizer::Wizer; @@ -14,7 +14,12 @@ pub(crate) struct Optimizer<'a> { impl<'a> Optimizer<'a> { pub fn new(wasm: &'a [u8], script: PathBuf) -> Self { - Self { wasm, script, strip: false, optimize: false } + Self { + wasm, + script, + strip: false, + optimize: false, + } } pub fn strip(self, strip: bool) -> Self { @@ -26,7 +31,9 @@ impl<'a> Optimizer<'a> { } pub fn write_optimized_wasm(self, dest: impl AsRef) -> Result<(), Error> { - let dir = self.script.parent() + let dir = self + .script + .parent() .filter(|p| p.is_dir()) .ok_or(anyhow::anyhow!("input script is not a file"))?;