From 96eb17a9632fef1326082306a5b6e70886e13ea3 Mon Sep 17 00:00:00 2001 From: Valentin Tolmer Date: Fri, 10 Feb 2023 11:37:36 +0100 Subject: [PATCH] server: fix clippy warning The clippy::uninlined_format_args warning in 1.67 was downgraded to pedantic in 1.67.1 due to lack of support in rust-analyzer, so we're not updating that one yet. --- app/src/lib.rs | 3 ++- migration-tool/src/main.rs | 2 ++ server/src/domain/sql_migrations.rs | 15 +++++++-------- server/src/main.rs | 3 ++- 4 files changed, 13 insertions(+), 10 deletions(-) diff --git a/app/src/lib.rs b/app/src/lib.rs index 3937693..c079976 100644 --- a/app/src/lib.rs +++ b/app/src/lib.rs @@ -1,6 +1,7 @@ #![recursion_limit = "256"] #![forbid(non_ascii_idents)] -#![allow(clippy::nonstandard_macro_braces)] +#![allow(clippy::uninlined_format_args)] + pub mod components; pub mod infra; diff --git a/migration-tool/src/main.rs b/migration-tool/src/main.rs index 7685a9c..cf1358e 100644 --- a/migration-tool/src/main.rs +++ b/migration-tool/src/main.rs @@ -1,3 +1,5 @@ +#![allow(clippy::uninlined_format_args)] + use std::collections::HashSet; use anyhow::{anyhow, Result}; diff --git a/server/src/domain/sql_migrations.rs b/server/src/domain/sql_migrations.rs index e4ed092..deb82c7 100644 --- a/server/src/domain/sql_migrations.rs +++ b/server/src/domain/sql_migrations.rs @@ -336,15 +336,14 @@ pub async fn migrate_from_version( pool: &DbConnection, version: SchemaVersion, ) -> anyhow::Result<()> { - if version > LAST_SCHEMA_VERSION { - anyhow::bail!("DB version downgrading is not supported"); - } else if version == LAST_SCHEMA_VERSION { - return Ok(()); + match version.cmp(&LAST_SCHEMA_VERSION) { + std::cmp::Ordering::Less => info!( + "Upgrading DB schema from {} to {}", + version.0, LAST_SCHEMA_VERSION.0 + ), + std::cmp::Ordering::Equal => return Ok(()), + std::cmp::Ordering::Greater => anyhow::bail!("DB version downgrading is not supported"), } - info!( - "Upgrading DB schema from {} to {}", - version.0, LAST_SCHEMA_VERSION.0 - ); let builder = pool.get_database_backend(); if version < SchemaVersion(2) { // Drop the not_null constraint on display_name. Due to Sqlite, this is more complicated: diff --git a/server/src/main.rs b/server/src/main.rs index 2c67bd9..712d0a9 100644 --- a/server/src/main.rs +++ b/server/src/main.rs @@ -1,6 +1,7 @@ #![forbid(unsafe_code)] #![forbid(non_ascii_idents)] -#![allow(clippy::nonstandard_macro_braces)] +// TODO: Remove next line once ubuntu upgrades rustc to >=1.67.1 +#![allow(clippy::uninlined_format_args)] use std::time::Duration;