From 8c7e0ada642766ef4192178f10da9cf19e03546c Mon Sep 17 00:00:00 2001 From: Sean Klein Date: Fri, 6 Oct 2023 12:15:16 -0700 Subject: [PATCH] refless --- .../db-queries/src/db/datastore/silo_group.rs | 1 - .../src/db/queries/network_interface.rs | 19 +++++++++---------- nexus/db-queries/src/db/true_or_cast_error.rs | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/nexus/db-queries/src/db/datastore/silo_group.rs b/nexus/db-queries/src/db/datastore/silo_group.rs index 930cd2b0a7..46f4aae7c9 100644 --- a/nexus/db-queries/src/db/datastore/silo_group.rs +++ b/nexus/db-queries/src/db/datastore/silo_group.rs @@ -19,7 +19,6 @@ use async_bb8_diesel::AsyncConnection; use async_bb8_diesel::AsyncRunQueryDsl; use chrono::Utc; use diesel::prelude::*; -use diesel::OptionalExtension; use omicron_common::api::external::CreateResult; use omicron_common::api::external::DataPageParams; use omicron_common::api::external::DeleteResult; diff --git a/nexus/db-queries/src/db/queries/network_interface.rs b/nexus/db-queries/src/db/queries/network_interface.rs index 4bf0b4ffd2..bac2610b41 100644 --- a/nexus/db-queries/src/db/queries/network_interface.rs +++ b/nexus/db-queries/src/db/queries/network_interface.rs @@ -291,7 +291,7 @@ fn decode_database_error( // that colum has been violated. DieselError::DatabaseError( DatabaseErrorKind::NotNullViolation, - ref info, + info, ) if info.message() == IP_EXHAUSTION_ERROR_MESSAGE => { InsertError::NoAvailableIpAddresses } @@ -300,7 +300,7 @@ fn decode_database_error( // `push_ensure_unique_vpc_expression` subquery, which generates a // UUID parsing error if the resource (e.g. instance) we want to attach // to is already associated with another VPC. - DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info) + DieselError::DatabaseError(DatabaseErrorKind::Unknown, info) if info.message() == MULTIPLE_VPC_ERROR_MESSAGE => { InsertError::ResourceSpansMultipleVpcs(interface.parent_id) @@ -308,10 +308,9 @@ fn decode_database_error( // This checks the constraint on the interface slot numbers, used to // limit total number of interfaces per resource to a maximum number. - DieselError::DatabaseError( - DatabaseErrorKind::CheckViolation, - ref info, - ) if info.message() == NO_SLOTS_AVAILABLE_ERROR_MESSAGE => { + DieselError::DatabaseError(DatabaseErrorKind::CheckViolation, info) + if info.message() == NO_SLOTS_AVAILABLE_ERROR_MESSAGE => + { InsertError::NoSlotsAvailable } @@ -320,7 +319,7 @@ fn decode_database_error( // that column has been violated. DieselError::DatabaseError( DatabaseErrorKind::NotNullViolation, - ref info, + info, ) if info.message() == MAC_EXHAUSTION_ERROR_MESSAGE => { InsertError::NoMacAddrressesAvailable } @@ -329,7 +328,7 @@ fn decode_database_error( // `push_ensure_unique_vpc_subnet_expression` subquery, which generates // a UUID parsing error if the resource has another interface in the VPC // Subnet of the one we're trying to insert. - DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info) + DieselError::DatabaseError(DatabaseErrorKind::Unknown, info) if info.message() == NON_UNIQUE_VPC_SUBNET_ERROR_MESSAGE => { InsertError::NonUniqueVpcSubnets @@ -338,7 +337,7 @@ fn decode_database_error( // This catches the UUID-cast failure intentionally introduced by // `push_instance_state_verification_subquery`, which verifies that // the instance is actually stopped when running this query. - DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info) + DieselError::DatabaseError(DatabaseErrorKind::Unknown, info) if info.message() == INSTANCE_BAD_STATE_ERROR_MESSAGE => { assert_eq!(interface.kind, NetworkInterfaceKind::Instance); @@ -347,7 +346,7 @@ fn decode_database_error( // This catches the UUID-cast failure intentionally introduced by // `push_instance_state_verification_subquery`, which verifies that // the instance doesn't even exist when running this query. - DieselError::DatabaseError(DatabaseErrorKind::Unknown, ref info) + DieselError::DatabaseError(DatabaseErrorKind::Unknown, info) if info.message() == NO_INSTANCE_ERROR_MESSAGE => { assert_eq!(interface.kind, NetworkInterfaceKind::Instance); diff --git a/nexus/db-queries/src/db/true_or_cast_error.rs b/nexus/db-queries/src/db/true_or_cast_error.rs index d72e50d249..6d7b2a1dbd 100644 --- a/nexus/db-queries/src/db/true_or_cast_error.rs +++ b/nexus/db-queries/src/db/true_or_cast_error.rs @@ -93,7 +93,7 @@ pub fn matches_sentinel( match e { // Catch the specific errors designed to communicate the failures we // want to distinguish. - Error::DatabaseError(DatabaseErrorKind::Unknown, ref info) => { + Error::DatabaseError(DatabaseErrorKind::Unknown, info) => { for sentinel in sentinels { if info.message() == bool_parse_error(sentinel) { return Some(sentinel);