From 231d87c47ee2aebcb1cb85aad261e1d762e83da0 Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Sun, 9 Mar 2025 22:27:38 +0000 Subject: [PATCH] chore: update rust toolchain to 1.85 (#2618) * chore: update rust toolchain to 1.85 * nix things * make clippy happy I've replaced a bunch of &Option with Option. They were not in hot loops, so a single clone is really no big deal + keeps things simpler. * fmt --- Cargo.toml | 2 +- crates/atuin-common/src/utils.rs | 2 +- crates/atuin-server/src/handlers/mod.rs | 4 ++-- .../src/command/client/account/change_password.rs | 6 +++--- crates/atuin/src/command/client/account/login.rs | 11 +++++++---- crates/atuin/src/command/client/account/register.rs | 8 ++++---- crates/atuin/src/command/client/import.rs | 2 +- .../atuin/src/command/client/search/history_list.rs | 2 +- crates/atuin/src/sync.rs | 4 ++-- flake.nix | 2 +- rust-toolchain.toml | 2 +- 11 files changed, 24 insertions(+), 21 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7ae91ee9..6d9e5f83 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -7,7 +7,7 @@ exclude = ["ui/backend"] [workspace.package] version = "18.4.0" authors = ["Ellie Huxtable "] -rust-version = "1.82" +rust-version = "1.85" license = "MIT" homepage = "https://atuin.sh" repository = "https://github.com/atuinsh/atuin" diff --git a/crates/atuin-common/src/utils.rs b/crates/atuin-common/src/utils.rs index 7f156d77..fbf2ef82 100644 --- a/crates/atuin-common/src/utils.rs +++ b/crates/atuin-common/src/utils.rs @@ -146,7 +146,7 @@ pub trait Escapable: AsRef { } else { let mut remaining = self.as_ref(); // Not a perfect way to reserve space but should reduce the allocations - let mut buf = String::with_capacity(remaining.as_bytes().len()); + let mut buf = String::with_capacity(remaining.len()); while let Some(i) = remaining.find(|c: char| c.is_ascii_control()) { // safe to index with `..i`, `i` and `i+1..` as part[i] is a single byte ascii char buf.push_str(&remaining[..i]); diff --git a/crates/atuin-server/src/handlers/mod.rs b/crates/atuin-server/src/handlers/mod.rs index 97132c07..a0d7ccc7 100644 --- a/crates/atuin-server/src/handlers/mod.rs +++ b/crates/atuin-server/src/handlers/mod.rs @@ -33,7 +33,7 @@ pub async fn index(state: State>) -> Json IntoResponse for ErrorResponseStatus<'a> { +impl IntoResponse for ErrorResponseStatus<'_> { fn into_response(self) -> axum::response::Response { (self.status, Json(self.error)).into_response() } @@ -57,7 +57,7 @@ impl<'a> RespExt<'a> for ErrorResponse<'a> { } } - fn reply(reason: &'a str) -> ErrorResponse { + fn reply(reason: &'a str) -> ErrorResponse<'a> { Self { reason: reason.into(), } diff --git a/crates/atuin/src/command/client/account/change_password.rs b/crates/atuin/src/command/client/account/change_password.rs index 97ebfa9c..6fee56be 100644 --- a/crates/atuin/src/command/client/account/change_password.rs +++ b/crates/atuin/src/command/client/account/change_password.rs @@ -15,14 +15,14 @@ pub struct Cmd { impl Cmd { pub async fn run(self, settings: &Settings) -> Result<()> { - run(settings, &self.current_password, &self.new_password).await + run(settings, self.current_password, self.new_password).await } } pub async fn run( settings: &Settings, - current_password: &Option, - new_password: &Option, + current_password: Option, + new_password: Option, ) -> Result<()> { let client = api_client::Client::new( &settings.sync_address, diff --git a/crates/atuin/src/command/client/account/login.rs b/crates/atuin/src/command/client/account/login.rs index 57d5f863..3785470f 100644 --- a/crates/atuin/src/command/client/account/login.rs +++ b/crates/atuin/src/command/client/account/login.rs @@ -49,7 +49,7 @@ impl Cmd { return Ok(()); } - let username = or_user_input(&self.username, "username"); + let username = or_user_input(self.username.clone(), "username"); let password = self.password.clone().unwrap_or_else(read_user_password); let key_path = settings.key_path.as_str(); @@ -61,7 +61,10 @@ impl Cmd { println!("Do not share this key with anyone"); println!("\nRead more here: https://docs.atuin.sh/guide/sync/#login \n"); - let key = or_user_input(&self.key, "encryption key [blank to use existing key file]"); + let key = or_user_input( + self.key.clone(), + "encryption key [blank to use existing key file]", + ); // if provided, the key may be EITHER base64, or a bip mnemonic // try to normalize on base64 @@ -152,8 +155,8 @@ impl Cmd { } } -pub(super) fn or_user_input(value: &'_ Option, name: &'static str) -> String { - value.clone().unwrap_or_else(|| read_user_input(name)) +pub(super) fn or_user_input(value: Option, name: &'static str) -> String { + value.unwrap_or_else(|| read_user_input(name)) } pub(super) fn read_user_password() -> String { diff --git a/crates/atuin/src/command/client/account/register.rs b/crates/atuin/src/command/client/account/register.rs index f1479b0c..a62b8f0f 100644 --- a/crates/atuin/src/command/client/account/register.rs +++ b/crates/atuin/src/command/client/account/register.rs @@ -18,15 +18,15 @@ pub struct Cmd { impl Cmd { pub async fn run(self, settings: &Settings) -> Result<()> { - run(settings, &self.username, &self.email, &self.password).await + run(settings, self.username, self.email, self.password).await } } pub async fn run( settings: &Settings, - username: &Option, - email: &Option, - password: &Option, + username: Option, + email: Option, + password: Option, ) -> Result<()> { use super::login::or_user_input; println!("Registering for an Atuin Sync account"); diff --git a/crates/atuin/src/command/client/import.rs b/crates/atuin/src/command/client/import.rs index d7857b9f..46343267 100644 --- a/crates/atuin/src/command/client/import.rs +++ b/crates/atuin/src/command/client/import.rs @@ -145,7 +145,7 @@ impl<'db, DB: Database> HistoryImporter<'db, DB> { } #[async_trait] -impl<'db, DB: Database> Loader for HistoryImporter<'db, DB> { +impl Loader for HistoryImporter<'_, DB> { async fn push(&mut self, hist: History) -> Result<()> { self.pb.inc(1); self.buf.push(hist); diff --git a/crates/atuin/src/command/client/search/history_list.rs b/crates/atuin/src/command/client/search/history_list.rs index 792e89b8..ccffc95c 100644 --- a/crates/atuin/src/command/client/search/history_list.rs +++ b/crates/atuin/src/command/client/search/history_list.rs @@ -48,7 +48,7 @@ impl ListState { } } -impl<'a> StatefulWidget for HistoryList<'a> { +impl StatefulWidget for HistoryList<'_> { type State = ListState; fn render(mut self, area: Rect, buf: &mut Buffer, state: &mut Self::State) { diff --git a/crates/atuin/src/sync.rs b/crates/atuin/src/sync.rs index feca3026..343360b7 100644 --- a/crates/atuin/src/sync.rs +++ b/crates/atuin/src/sync.rs @@ -7,8 +7,8 @@ use atuin_client::{ }; use atuin_common::record::RecordId; -/// This is the only crate that ties together all other crates. -/// Therefore, it's the only crate where functions tying together all stores can live +// This is the only crate that ties together all other crates. +// Therefore, it's the only crate where functions tying together all stores can live /// Rebuild all stores after a sync /// Note: for history, this only does an _incremental_ sync. Hence the need to specify downloaded diff --git a/flake.nix b/flake.nix index 4c9383f0..ec6e7555 100644 --- a/flake.nix +++ b/flake.nix @@ -32,7 +32,7 @@ fenix.packages.${system}.fromToolchainFile { file = ./rust-toolchain.toml; - sha256 = "sha256-yMuSb5eQPO/bHv+Bcf/US8LVMbf/G/0MSfiPwBhiPpk="; + sha256 = "sha256-AJ6LX/Q/Er9kS15bn9iflkUwcgYqRQxiOIL2ToVAXaU="; }; in pkgs.makeRustPlatform { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 76fcadb5..c5794a6b 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,2 +1,2 @@ [toolchain] -channel = "1.82" +channel = "1.85"