Skip to content

Commit ad5dbfa

Browse files
committed
Clippy fixes
1 parent cd1718a commit ad5dbfa

File tree

16 files changed

+34
-69
lines changed

16 files changed

+34
-69
lines changed

src/bindgen.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ pub fn wasm_bindgen_build(
2121
reference_types: bool,
2222
target: Target,
2323
profile: BuildProfile,
24-
extra_options: &Vec<String>,
24+
extra_options: &[String],
2525
) -> Result<()> {
2626
let profile_name = match profile.clone() {
2727
BuildProfile::Release | BuildProfile::Profiling => "release",

src/build/wasm_target.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ pub fn check_for_wasm32_target() -> Result<()> {
6868
/// Get rustc's sysroot as a PathBuf
6969
fn get_rustc_sysroot() -> Result<PathBuf> {
7070
let command = Command::new("rustc")
71-
.args(&["--print", "sysroot"])
71+
.args(["--print", "sysroot"])
7272
.output()?;
7373

7474
if command.status.success() {
@@ -84,7 +84,7 @@ fn get_rustc_sysroot() -> Result<PathBuf> {
8484
/// Get wasm32-unknown-unknown target libdir
8585
fn get_rustc_wasm32_unknown_unknown_target_libdir() -> Result<PathBuf> {
8686
let command = Command::new("rustc")
87-
.args(&[
87+
.args([
8888
"--target",
8989
"wasm32-unknown-unknown",
9090
"--print",

src/command/build.rs

Lines changed: 3 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ pub struct Build {
4545

4646
/// What sort of output we're going to be generating and flags we're invoking
4747
/// `wasm-bindgen` with.
48-
#[derive(Clone, Copy, Debug)]
48+
#[derive(Clone, Copy, Debug, Default)]
4949
pub enum Target {
5050
/// Default output mode or `--target bundler`, indicates output will be
5151
/// used with a bundle in a later step.
52+
#[default]
5253
Bundler,
5354
/// Correspond to `--target web` where the output is natively usable as an
5455
/// ES module in a browser and the wasm is manually instantiated.
@@ -65,12 +66,6 @@ pub enum Target {
6566
Deno,
6667
}
6768

68-
impl Default for Target {
69-
fn default() -> Target {
70-
Target::Bundler
71-
}
72-
}
73-
7469
impl fmt::Display for Target {
7570
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
7671
let s = match self {
@@ -115,6 +110,7 @@ pub enum BuildProfile {
115110
/// Everything required to configure and run the `wasm-pack build` command.
116111
#[derive(Debug, Args)]
117112
#[command(allow_hyphen_values = true, trailing_var_arg = true)]
113+
#[derive(Default)]
118114
pub struct BuildOptions {
119115
/// The path to the Rust crate. If not set, searches up the path from the current directory.
120116
#[clap()]
@@ -186,30 +182,6 @@ pub struct BuildOptions {
186182
pub extra_options: Vec<String>,
187183
}
188184

189-
impl Default for BuildOptions {
190-
fn default() -> Self {
191-
Self {
192-
path: None,
193-
scope: None,
194-
mode: InstallMode::default(),
195-
disable_dts: false,
196-
weak_refs: false,
197-
reference_types: false,
198-
target: Target::default(),
199-
debug: false,
200-
dev: false,
201-
no_pack: false,
202-
no_opt: false,
203-
release: false,
204-
profiling: false,
205-
profile: None,
206-
out_dir: String::new(),
207-
out_name: None,
208-
extra_options: Vec::new(),
209-
}
210-
}
211-
}
212-
213185
type BuildStep = fn(&mut Build) -> Result<()>;
214186

215187
impl Build {

src/command/login.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ pub fn login(
1616
&scope, &registry, &auth_type
1717
);
1818
info!("npm info located in the npm debug log");
19-
npm::npm_login(&registry, &scope, &auth_type)?;
19+
npm::npm_login(&registry, scope, auth_type)?;
2020
info!("Logged you in!");
2121

22-
PBAR.info(&"👋 logged you in!".to_string());
22+
PBAR.info("👋 logged you in!");
2323
Ok(())
2424
}

src/command/test.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl Test {
121121
} = test_opts;
122122

123123
let first_arg_is_path = path_and_extra_options
124-
.get(0)
124+
.first()
125125
.map(|first_arg| !first_arg.starts_with("-"))
126126
.unwrap_or(false);
127127

@@ -295,7 +295,7 @@ impl Test {
295295
let status = install::download_prebuilt_or_cargo_install(
296296
Tool::WasmBindgen,
297297
&self.cache,
298-
&bindgen_version,
298+
bindgen_version,
299299
self.mode.install_permitted(),
300300
)?;
301301

src/command/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ fn find_manifest_from_cwd() -> Result<PathBuf> {
3838
/// Construct our `pkg` directory in the crate.
3939
pub fn create_pkg_dir(out_dir: &Path) -> Result<()> {
4040
let _ = fs::remove_file(out_dir.join("package.json")); // Clean up package.json from previous runs
41-
fs::create_dir_all(&out_dir)?;
41+
fs::create_dir_all(out_dir)?;
4242
fs::write(out_dir.join(".gitignore"), "*")?;
4343
Ok(())
4444
}
@@ -53,7 +53,7 @@ pub fn find_pkg_directory(path: &Path, pkg_directory: &Path) -> Option<PathBuf>
5353
WalkDir::new(path)
5454
.into_iter()
5555
.filter_map(|x| x.ok().map(|e| e.into_path()))
56-
.find(|x| is_pkg_directory(&x, pkg_directory))
56+
.find(|x| is_pkg_directory(x, pkg_directory))
5757
}
5858

5959
fn is_pkg_directory(path: &Path, pkg_directory: &Path) -> bool {

src/generate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ pub fn generate(template: &str, name: &str, install_status: &install::Status) ->
1313
.binary(&Tool::CargoGenerate.to_string())?;
1414
let mut cmd = Command::new(&bin_path);
1515
cmd.arg("generate");
16-
cmd.arg("--git").arg(&template);
17-
cmd.arg("--name").arg(&name);
16+
cmd.arg("--git").arg(template);
17+
cmd.arg("--name").arg(name);
1818

1919
println!(
2020
"{} Generating a new rustwasm project with name '{}'...",

src/install/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ pub fn get_cli_version(tool: &Tool, path: &Path) -> Result<String> {
110110
let mut cmd = Command::new(path);
111111
cmd.arg("--version");
112112
let stdout = child::run_capture_stdout(cmd, tool)?;
113-
let version = stdout.trim().split_whitespace().nth(1);
113+
let version = stdout.split_whitespace().nth(1);
114114
match version {
115115
Some(v) => Ok(v.to_string()),
116116
None => bail!("Something went wrong! We couldn't determine your version of the wasm-bindgen CLI. We were supposed to set that up for you, so it's likely not your fault! You should file an issue: https://github.com/drager/wasm-pack/issues/new?template=bug_report.md.")

src/install/mode.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use std::str::FromStr;
33

44
/// The `InstallMode` determines which mode of initialization we are running, and
55
/// what install steps we perform.
6-
#[derive(Clone, Copy, Debug)]
6+
#[derive(Clone, Copy, Debug, Default)]
77
pub enum InstallMode {
88
/// Perform all the install steps.
9+
#[default]
910
Normal,
1011
/// Don't install tools like `wasm-bindgen`, just use the global
1112
/// environment's existing versions to do builds.
@@ -14,12 +15,6 @@ pub enum InstallMode {
1415
Force,
1516
}
1617

17-
impl Default for InstallMode {
18-
fn default() -> InstallMode {
19-
InstallMode::Normal
20-
}
21-
}
22-
2318
impl FromStr for InstallMode {
2419
type Err = Error;
2520
fn from_str(s: &str) -> Result<Self> {

src/installer.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ use std::path::Path;
2424
use std::process;
2525

2626
use anyhow::{anyhow, bail, Context, Result};
27-
use which;
2827

2928
pub fn install() -> ! {
3029
if let Err(e) = do_install() {

0 commit comments

Comments
 (0)