Skip to content

Commit 224bb96

Browse files
authored
chore: update toolchain to 1.84.1. apply clippy fixes & rustfmt (#1026)
* chore: update to stable toolchain. apply clippy fixes & rustfmt * Bump MSRV * Try MSRV without the patch version * fix: pin toolchain to MSRV * trying again * fix dead code warning --------- Co-authored-by: Dan Sully <[email protected]>
1 parent 9a6fe8e commit 224bb96

22 files changed

+105
-129
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ categories = ["os"]
55
keywords = ["upgrade", "update"]
66
license = "GPL-3.0"
77
repository = "https://github.com/topgrade-rs/topgrade"
8-
rust-version = "1.76.0"
8+
rust-version = "1.84.1"
99
version = "16.0.2"
1010
authors = ["Roey Darwish Dror <[email protected]>", "Thomas Schönauer <[email protected]>"]
1111
exclude = ["doc/screenshot.gif", "BREAKINGCHANGES_dev.md"]

rust-toolchain.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
[toolchain]
2-
channel = "1.76.0"
2+
channel = "1.84.1"

src/command.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,13 @@ impl TryFrom<&Output> for Utf8Output {
4545
type Error = eyre::Error;
4646

4747
fn try_from(Output { status, stdout, stderr }: &Output) -> Result<Self, Self::Error> {
48-
let stdout = String::from_utf8(stdout.to_vec()).map_err(|err| {
48+
let stdout = String::from_utf8(stdout.clone()).map_err(|err| {
4949
eyre!(
5050
"Stdout contained invalid UTF-8: {}",
5151
String::from_utf8_lossy(err.as_bytes())
5252
)
5353
})?;
54-
let stderr = String::from_utf8(stderr.to_vec()).map_err(|err| {
54+
let stderr = String::from_utf8(stderr.clone()).map_err(|err| {
5555
eyre!(
5656
"Stderr contained invalid UTF-8: {}",
5757
String::from_utf8_lossy(err.as_bytes())
@@ -149,6 +149,7 @@ pub trait CommandExt {
149149
/// Like [`Command::spawn`], but gives a nice error message if the command fails to
150150
/// execute.
151151
#[track_caller]
152+
#[allow(dead_code)]
152153
fn spawn_checked(&mut self) -> eyre::Result<Self::Child>;
153154
}
154155

src/config.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ impl ConfigFile {
561561
];
562562

563563
// Search for the main config file
564-
for path in possible_config_paths.iter() {
564+
for path in &possible_config_paths {
565565
if path.exists() {
566566
debug!("Configuration at {}", path.display());
567567
res.0.clone_from(path);
@@ -1475,8 +1475,7 @@ impl Config {
14751475
.misc
14761476
.as_ref()
14771477
.and_then(|misc| misc.ignore_failures.as_ref())
1478-
.map(|v| v.contains(&step))
1479-
.unwrap_or(false)
1478+
.is_some_and(|v| v.contains(&step))
14801479
}
14811480

14821481
pub fn use_predefined_git_repos(&self) -> bool {
@@ -1694,40 +1693,40 @@ mod test {
16941693

16951694
#[test]
16961695
fn test_should_execute_remote_different_hostname() {
1697-
assert!(config().should_execute_remote(Ok("hostname".to_string()), "remote_hostname"))
1696+
assert!(config().should_execute_remote(Ok("hostname".to_string()), "remote_hostname"));
16981697
}
16991698

17001699
#[test]
17011700
fn test_should_execute_remote_different_hostname_with_user() {
1702-
assert!(config().should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"))
1701+
assert!(config().should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"));
17031702
}
17041703

17051704
#[test]
17061705
fn test_should_execute_remote_unknown_hostname() {
1707-
assert!(config().should_execute_remote(Err(eyre!("failed to get hostname")), "remote_hostname"))
1706+
assert!(config().should_execute_remote(Err(eyre!("failed to get hostname")), "remote_hostname"));
17081707
}
17091708

17101709
#[test]
17111710
fn test_should_not_execute_remote_same_hostname() {
1712-
assert!(!config().should_execute_remote(Ok("hostname".to_string()), "hostname"))
1711+
assert!(!config().should_execute_remote(Ok("hostname".to_string()), "hostname"));
17131712
}
17141713

17151714
#[test]
17161715
fn test_should_not_execute_remote_same_hostname_with_user() {
1717-
assert!(!config().should_execute_remote(Ok("hostname".to_string()), "user@hostname"))
1716+
assert!(!config().should_execute_remote(Ok("hostname".to_string()), "user@hostname"));
17181717
}
17191718

17201719
#[test]
17211720
fn test_should_execute_remote_matching_limit() {
17221721
let mut config = config();
17231722
config.opt = CommandLineArgs::parse_from(["topgrade", "--remote-host-limit", "remote_hostname"]);
1724-
assert!(config.should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"))
1723+
assert!(config.should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"));
17251724
}
17261725

17271726
#[test]
17281727
fn test_should_not_execute_remote_not_matching_limit() {
17291728
let mut config = config();
17301729
config.opt = CommandLineArgs::parse_from(["topgrade", "--remote-host-limit", "other_hostname"]);
1731-
assert!(!config.should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"))
1730+
assert!(!config.should_execute_remote(Ok("hostname".to_string()), "user@remote_hostname"));
17321731
}
17331732
}

src/ctrlc/interrupted.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ pub fn interrupted() -> bool {
1111
/// Clears the interrupted flag
1212
pub fn unset_interrupted() {
1313
debug_assert!(INTERRUPTED.load(Ordering::SeqCst));
14-
INTERRUPTED.store(false, Ordering::SeqCst)
14+
INTERRUPTED.store(false, Ordering::SeqCst);
1515
}
1616

1717
pub fn set_interrupted() {
18-
INTERRUPTED.store(true, Ordering::SeqCst)
18+
INTERRUPTED.store(true, Ordering::SeqCst);
1919
}

src/ctrlc/unix.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use nix::sys::signal::{sigaction, SaFlags, SigAction, SigHandler, SigSet, Signal
44

55
/// Handle SIGINT. Set the interruption flag.
66
extern "C" fn handle_sigint(_: i32) {
7-
set_interrupted()
7+
set_interrupted();
88
}
99

1010
/// Set the necessary signal handlers.

src/executor.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ impl Executor {
188188
pub fn status_checked_with_codes(&mut self, codes: &[i32]) -> Result<()> {
189189
match self {
190190
Executor::Wet(c) => c.status_checked_with(|status| {
191-
if status.success() || status.code().as_ref().map(|c| codes.contains(c)).unwrap_or(false) {
191+
if status.success() || status.code().as_ref().is_some_and(|c| codes.contains(c)) {
192192
Ok(())
193193
} else {
194194
Err(())

src/main.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ use self::config::{CommandLineArgs, Config, Step};
2525
use self::error::StepFailed;
2626
#[cfg(all(windows, feature = "self-update"))]
2727
use self::error::Upgraded;
28+
#[allow(clippy::wildcard_imports)]
2829
use self::steps::{remote::*, *};
30+
#[allow(clippy::wildcard_imports)]
2931
use self::terminal::*;
3032

3133
use self::utils::{hostname, install_color_eyre, install_tracing, update_tracing};
@@ -58,6 +60,7 @@ pub(crate) static WINDOWS_DIRS: Lazy<Windows> = Lazy::new(|| Windows::new().expe
5860
// Init and load the i18n files
5961
i18n!("locales", fallback = "en");
6062

63+
#[allow(clippy::too_many_lines)]
6164
fn run() -> Result<()> {
6265
install_color_eyre()?;
6366
ctrlc::set_handler();
@@ -494,13 +497,13 @@ fn run() -> Result<()> {
494497
print_info(t!("\n(R)eboot\n(S)hell\n(Q)uit"));
495498
loop {
496499
match get_key() {
497-
Ok(Key::Char('s')) | Ok(Key::Char('S')) => {
500+
Ok(Key::Char('s' | 'S')) => {
498501
run_shell().context("Failed to execute shell")?;
499502
}
500-
Ok(Key::Char('r')) | Ok(Key::Char('R')) => {
503+
Ok(Key::Char('r' | 'R')) => {
501504
reboot().context("Failed to reboot")?;
502505
}
503-
Ok(Key::Char('q')) | Ok(Key::Char('Q')) => (),
506+
Ok(Key::Char('q' | 'Q')) => (),
504507
_ => {
505508
continue;
506509
}
@@ -519,7 +522,7 @@ fn run() -> Result<()> {
519522
t!("Topgrade finished successfully")
520523
},
521524
Some(Duration::from_secs(10)),
522-
)
525+
);
523526
}
524527

525528
if failed {

src/self_update.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use rust_i18n::t;
99
use self_update_crate::backends::github::Update;
1010
use self_update_crate::update::UpdateStatus;
1111

12-
use super::terminal::*;
12+
use super::terminal::{print_info, print_separator};
1313
#[cfg(windows)]
1414
use crate::error::Upgraded;
1515

src/steps/containers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ pub fn run_containers(ctx: &ExecutionContext) -> Result<()> {
140140
list_containers(&crt, ctx.config().containers_ignored_tags()).context("Failed to list Docker containers")?;
141141
debug!("Containers to inspect: {:?}", containers);
142142

143-
for container in containers.iter() {
143+
for container in &containers {
144144
debug!("Pulling container '{}'", container);
145145
let args = vec![
146146
"pull",

0 commit comments

Comments
 (0)