From 70525c018dfd31a27805bb1fb666501b73d43e21 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Thu, 20 Feb 2025 21:37:33 -0500 Subject: Upgrade to Rust 1.85 and Rust 2024 edition. There are a couple of migration suggestions from `cargo fix --edition` that I have deliberately skipped, which are intended to make sure that the changes to `if let` scoping don't bite us. They don't, I'm pretty sure, and if I turn out to be wrong, I'd rather fix the scoping issues (as they arise) than use `match` (`cargo fix --edition`'s suggestion). This change also includes a bulk reformat and a clippy cleanup. NOTA BENE: As this requires a new Rust toolchain, you'll need to update Rust (`rustup update`, normally) or the server won't build. This also applies to the Debian builder Docker image; it'll need to be rebuilt (from scratch, pulling its base image again) as well. --- src/login/create.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/login/create.rs') diff --git a/src/login/create.rs b/src/login/create.rs index 693daaf..c4cb2bb 100644 --- a/src/login/create.rs +++ b/src/login/create.rs @@ -1,9 +1,9 @@ -use sqlx::{sqlite::Sqlite, Transaction}; +use sqlx::{Transaction, sqlite::Sqlite}; -use super::{password::StoredHash, repo::Provider as _, validate, History, Password}; +use super::{History, Password, password::StoredHash, repo::Provider as _, validate}; use crate::{ clock::DateTime, - event::{repo::Provider as _, Broadcaster, Event}, + event::{Broadcaster, Event, repo::Provider as _}, name::Name, }; @@ -51,9 +51,9 @@ pub struct Validated<'a> { created_at: &'a DateTime, } -impl<'a> Validated<'a> { +impl Validated<'_> { #[must_use = "dropping a login creation attempt is likely a mistake"] - pub async fn store<'c>(self, tx: &mut Transaction<'c, Sqlite>) -> Result { + pub async fn store(self, tx: &mut Transaction<'_, Sqlite>) -> Result { let Self { name, password_hash, -- cgit v1.2.3 From 36cadfe00cacc6a6523f9862d3f7a08a9d0ce611 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Fri, 21 Feb 2025 17:10:49 -0500 Subject: Ensure `must_use` warnings fire even after results are unwrapped. --- src/login/create.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/login/create.rs') diff --git a/src/login/create.rs b/src/login/create.rs index c4cb2bb..c5cea08 100644 --- a/src/login/create.rs +++ b/src/login/create.rs @@ -1,12 +1,13 @@ -use sqlx::{Transaction, sqlite::Sqlite}; +use sqlx::{sqlite::Sqlite, Transaction}; -use super::{History, Password, password::StoredHash, repo::Provider as _, validate}; +use super::{password::StoredHash, repo::Provider as _, validate, History, Password}; use crate::{ clock::DateTime, - event::{Broadcaster, Event, repo::Provider as _}, + event::{repo::Provider as _, Broadcaster, Event}, name::Name, }; +#[must_use = "dropping a login creation attempt is likely a mistake"] pub struct Create<'a> { name: &'a Name, password: &'a Password, @@ -14,7 +15,6 @@ pub struct Create<'a> { } impl<'a> Create<'a> { - #[must_use = "dropping a login creation attempt is likely a mistake"] pub fn begin(name: &'a Name, password: &'a Password, created_at: &'a DateTime) -> Self { Self { name, @@ -23,7 +23,6 @@ impl<'a> Create<'a> { } } - #[must_use = "dropping a login creation attempt is likely a mistake"] pub fn validate(self) -> Result, Error> { let Self { name, @@ -45,6 +44,7 @@ impl<'a> Create<'a> { } } +#[must_use = "dropping a login creation attempt is likely a mistake"] pub struct Validated<'a> { name: &'a Name, password_hash: StoredHash, @@ -52,7 +52,6 @@ pub struct Validated<'a> { } impl Validated<'_> { - #[must_use = "dropping a login creation attempt is likely a mistake"] pub async fn store(self, tx: &mut Transaction<'_, Sqlite>) -> Result { let Self { name, @@ -67,6 +66,7 @@ impl Validated<'_> { } } +#[must_use = "dropping a login creation attempt is likely a mistake"] pub struct Stored { login: History, } -- cgit v1.2.3