From 831bf1e0528e6f4887c7bb718fb5c0e444f343c4 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Thu, 8 Jun 2023 09:34:29 +0800 Subject: [PATCH 1/6] Address `#[warn(clippy::redundant_field_names)]` Signed-off-by: hi-rustin --- src/cli/download_tracker.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/download_tracker.rs b/src/cli/download_tracker.rs index 0842dc77e5..0c5023fc2f 100644 --- a/src/cli/download_tracker.rs +++ b/src/cli/download_tracker.rs @@ -61,7 +61,7 @@ impl DownloadTracker { term: process().stdout().terminal(), displayed_charcount: None, units: vec![Unit::B], - display_progress: display_progress, + display_progress, })) } From 9acc0dc307f5ff6718268daf9a05deeecef6542a Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 17 Jul 2023 08:39:06 +0800 Subject: [PATCH 2/6] Address `#[warn(clippy::redundant_pattern_matching)]` Signed-off-by: hi-rustin --- src/cli/self_update/shell.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index 205b6b614c..22b754681c 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -175,7 +175,7 @@ impl UnixShell for Zsh { fn does_exist(&self) -> bool { // zsh has to either be the shell or be callable for zsh setup. matches!(process().var("SHELL"), Ok(sh) if sh.contains("zsh")) - || matches!(utils::find_cmd(&["zsh"]), Some(_)) + || utils::find_cmd(&["zsh"]).is_some() } fn rcfiles(&self) -> Vec { From d63b6e5f7608369934a4774611af9a83104d3a78 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 17 Jul 2023 08:40:36 +0800 Subject: [PATCH 3/6] Address `#[warn(clippy::useless_conversion)]` Signed-off-by: hi-rustin --- src/cli/self_update/shell.rs | 2 +- src/test/mock/clitools.rs | 13 +++++-------- src/test/mock/dist.rs | 2 +- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/cli/self_update/shell.rs b/src/cli/self_update/shell.rs index 22b754681c..195dbea2bd 100644 --- a/src/cli/self_update/shell.rs +++ b/src/cli/self_update/shell.rs @@ -195,7 +195,7 @@ impl UnixShell for Zsh { self.rcfiles() .into_iter() .filter(|env| env.is_file()) - .chain(self.rcfiles().into_iter()) + .chain(self.rcfiles()) .take(1) .collect() } diff --git a/src/test/mock/clitools.rs b/src/test/mock/clitools.rs index 1c9aa76ede..fe5f834844 100644 --- a/src/test/mock/clitools.rs +++ b/src/test/mock/clitools.rs @@ -1194,14 +1194,11 @@ fn build_mock_channel( // Convert the mock installers to mock package definitions for the // mock dist server let mut all = MockChannelContent::default(); - all.std.extend( - vec![ - (std, host_triple.clone()), - (cross_std1, CROSS_ARCH1.to_string()), - (cross_std2, CROSS_ARCH2.to_string()), - ] - .into_iter(), - ); + all.std.extend(vec![ + (std, host_triple.clone()), + (cross_std1, CROSS_ARCH1.to_string()), + (cross_std2, CROSS_ARCH2.to_string()), + ]); all.rustc.push((rustc, host_triple.clone())); all.cargo.push((cargo, host_triple.clone())); diff --git a/src/test/mock/dist.rs b/src/test/mock/dist.rs index 0b42a9ceb6..04268abacf 100644 --- a/src/test/mock/dist.rs +++ b/src/test/mock/dist.rs @@ -131,7 +131,7 @@ impl MockDistServer { let mut hashes = HashMap::new(); for package in &channel.packages { let new_hashes = self.build_package(channel, package, enable_xz, enable_zst); - hashes.extend(new_hashes.into_iter()); + hashes.extend(new_hashes); } for v in vs { match *v { From 9b1ec7729d4670c731865b02e6883f45bd09e3ec Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 17 Jul 2023 08:53:45 +0800 Subject: [PATCH 4/6] Address `#[warn(clippy::needless_borrow)]` Signed-off-by: hi-rustin --- tests/suite/cli_rustup.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/suite/cli_rustup.rs b/tests/suite/cli_rustup.rs index 304ff48bfd..9a6adde7a4 100644 --- a/tests/suite/cli_rustup.rs +++ b/tests/suite/cli_rustup.rs @@ -2178,7 +2178,7 @@ fn non_utf8_arg() { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run( "rustc", - &[ + [ OsStr::new("--echo-args"), OsStr::new("echoed non-utf8 arg:"), OsStr::from_bytes(b"\xc3\x28"), @@ -2224,7 +2224,7 @@ fn non_utf8_toolchain() { config.expect_ok(&["rustup", "default", "nightly"]); let out = config.run( "rustc", - &[OsStr::from_bytes(b"+\xc3\x28")], + [OsStr::from_bytes(b"+\xc3\x28")], &[("RUST_BACKTRACE", "1")], ); assert!(out.stderr.contains("toolchain '�(' is not installable")); From a3b67ded4877fd250378d54f3add9cadd36af503 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Mon, 17 Jul 2023 08:54:37 +0800 Subject: [PATCH 5/6] Address `#[warn(clippy::useless_vec)]` Signed-off-by: hi-rustin --- src/env_var.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/env_var.rs b/src/env_var.rs index 7397e12ac6..78d81c07b1 100644 --- a/src/env_var.rs +++ b/src/env_var.rs @@ -52,7 +52,7 @@ mod tests { let mut vars = HashMap::new(); vars.env( "PATH", - env::join_paths(vec!["/home/a/.cargo/bin", "/home/b/.cargo/bin"].iter()).unwrap(), + env::join_paths(["/home/a/.cargo/bin", "/home/b/.cargo/bin"].iter()).unwrap(), ); let tp = currentprocess::TestProcess { vars, @@ -84,7 +84,7 @@ mod tests { OsStr::new("PATH"), Some( env::join_paths( - vec![ + [ "/home/z/.cargo/bin", "/home/a/.cargo/bin", "/home/b/.cargo/bin" From 0c76ab36e57b44dd00594dcd21ed6f1cf4ba2fc4 Mon Sep 17 00:00:00 2001 From: hi-rustin Date: Tue, 18 Jul 2023 08:31:49 +0800 Subject: [PATCH 6/6] allow `clippy::arc_with_non_send_sync` Signed-off-by: hi-rustin --- src/lib.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib.rs b/src/lib.rs index 2305183470..af9875c969 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,8 +4,9 @@ clippy::type_complexity, clippy::upper_case_acronyms, // see https://github.com/rust-lang/rust-clippy/issues/6974 clippy::vec_init_then_push, // uses two different styles of initialization - clippy::box_default, // its ugly and outside of inner loops irrelevant + clippy::box_default, // its ugly and outside of inner loops irrelevant clippy::result_large_err, // 288 bytes is our 'large' variant today, which is unlikely to be a performance problem + clippy::arc_with_non_send_sync, // will get resolved as we move further into async )] #![recursion_limit = "1024"]