From c0a33713083af16c97972259fd07475eb2b6e05e Mon Sep 17 00:00:00 2001 From: Isabel Atkinson Date: Fri, 14 Feb 2025 12:52:34 -0700 Subject: [PATCH 1/3] bump version --- .evergreen/check-clippy.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.evergreen/check-clippy.sh b/.evergreen/check-clippy.sh index a12a2662e..29e6324d1 100755 --- a/.evergreen/check-clippy.sh +++ b/.evergreen/check-clippy.sh @@ -5,7 +5,7 @@ set -o errexit source ./.evergreen/env.sh # Pin clippy to the latest version. This should be updated when new versions of Rust are released. -CLIPPY_VERSION=1.83.0 +CLIPPY_VERSION=1.84.0 rustup install $CLIPPY_VERSION From 120cf8dc19dfe7e2219d0aadb0c06a04754d1dfd Mon Sep 17 00:00:00 2001 From: Isabel Atkinson Date: Tue, 18 Feb 2025 09:12:54 -0700 Subject: [PATCH 2/3] fixes --- src/action/find_and_modify.rs | 4 ++-- src/client.rs | 4 ++-- src/client/action/perf.rs | 2 +- src/client/auth/aws.rs | 2 +- src/client/auth/oidc.rs | 2 +- src/client/csfle/client_encryption.rs | 2 +- src/client/options/test.rs | 2 +- src/client/session/action.rs | 2 +- src/cmap/conn/stream_description.rs | 2 +- src/cmap/establish/handshake.rs | 4 ++-- src/operation/aggregate/change_stream.rs | 4 ++-- src/operation/create_indexes.rs | 2 +- src/sdam/description/topology/server_selection/test.rs | 5 +---- src/sdam/srv_polling.rs | 5 +---- src/test/client.rs | 2 +- src/test/csfle.rs | 2 +- src/test/spec/v2_runner.rs | 6 +++--- src/test/util/event_buffer.rs | 4 ++-- 18 files changed, 25 insertions(+), 31 deletions(-) diff --git a/src/action/find_and_modify.rs b/src/action/find_and_modify.rs index 0fec48c0c..c21a9cee1 100644 --- a/src/action/find_and_modify.rs +++ b/src/action/find_and_modify.rs @@ -27,12 +27,12 @@ use crate::{ use super::{action_impl, deeplink, export_doc, option_setters, options_doc}; impl Collection { - async fn find_and_modify<'a>( + async fn find_and_modify( &self, filter: Document, modification: Modification, mut options: Option, - session: Option<&'a mut ClientSession>, + session: Option<&mut ClientSession>, ) -> Result> { resolve_write_concern_with_session!(self, options, session.as_ref())?; diff --git a/src/client.rs b/src/client.rs index c92ad72a5..b34b6edf8 100644 --- a/src/client.rs +++ b/src/client.rs @@ -261,7 +261,7 @@ impl Client { .read() .await .as_ref() - .map_or(false, |cs| cs.exec().mongocryptd_spawned()) + .is_some_and(|cs| cs.exec().mongocryptd_spawned()) } #[cfg(all(test, feature = "in-use-encryption"))] @@ -271,7 +271,7 @@ impl Client { .read() .await .as_ref() - .map_or(false, |cs| cs.exec().has_mongocryptd_client()) + .is_some_and(|cs| cs.exec().has_mongocryptd_client()) } fn test_command_event_channel(&self) -> Option<&options::TestEventSender> { diff --git a/src/client/action/perf.rs b/src/client/action/perf.rs index 725080c1f..1d2ab780c 100644 --- a/src/client/action/perf.rs +++ b/src/client/action/perf.rs @@ -10,7 +10,7 @@ impl<'a> Action for crate::action::WarmConnectionPool<'a> { .inner .options .min_pool_size - .map_or(false, |s| s > 0) + .is_some_and(|size| size > 0) { // No-op when min_pool_size is zero. return; diff --git a/src/client/auth/aws.rs b/src/client/auth/aws.rs index dfe32ee50..b8a49681c 100644 --- a/src/client/auth/aws.rs +++ b/src/client/auth/aws.rs @@ -542,7 +542,7 @@ impl ServerFirst { MECH_NAME, "sts host must be non-empty", )) - } else if self.sts_host.as_bytes().len() > 255 { + } else if self.sts_host.len() > 255 { Err(Error::authentication_error( MECH_NAME, "sts host cannot be more than 255 bytes", diff --git a/src/client/auth/oidc.rs b/src/client/auth/oidc.rs index b481ccb37..075f1290c 100644 --- a/src/client/auth/oidc.rs +++ b/src/client/auth/oidc.rs @@ -968,7 +968,7 @@ pub(super) fn validate_credential(credential: &Credential) -> Result<()> { if credential .source .as_ref() - .map_or(false, |s| s != "$external") + .is_some_and(|source| source != "$external") { return Err(Error::invalid_argument(format!( "source must be $external for {} authentication, found: {:?}", diff --git a/src/client/csfle/client_encryption.rs b/src/client/csfle/client_encryption.rs index 05aadc751..519ccfd3e 100644 --- a/src/client/csfle/client_encryption.rs +++ b/src/client/csfle/client_encryption.rs @@ -183,7 +183,7 @@ impl ClientEncryption { /// Decrypts an encrypted value (BSON binary of subtype 6). /// Returns the original BSON value. - pub async fn decrypt<'a>(&self, value: RawBinaryRef<'a>) -> Result { + pub async fn decrypt(&self, value: RawBinaryRef<'_>) -> Result { if value.subtype != BinarySubtype::Encrypted { return Err(Error::invalid_argument(format!( "Invalid binary subtype for decrypt: expected {:?}, got {:?}", diff --git a/src/client/options/test.rs b/src/client/options/test.rs index 22626ab2f..ab804d8e1 100644 --- a/src/client/options/test.rs +++ b/src/client/options/test.rs @@ -155,7 +155,7 @@ async fn run_tests(path: &[&str], skipped_files: &[&str]) { let (_, actual_value) = actual_options .iter() .find(|(actual_key, _)| { - actual_key.to_ascii_lowercase() == expected_key.to_ascii_lowercase() + actual_key.eq_ignore_ascii_case(expected_key) }) .unwrap_or_else(|| { panic!( diff --git a/src/client/session/action.rs b/src/client/session/action.rs index fccaabbae..7be9a1047 100644 --- a/src/client/session/action.rs +++ b/src/client/session/action.rs @@ -99,7 +99,7 @@ impl<'a> Action for StartTransaction<&'a mut ClientSession> { } } -impl<'a> StartTransaction<&'a mut ClientSession> { +impl StartTransaction<&mut ClientSession> { /// Starts a transaction, runs the given callback, and commits or aborts the transaction. /// Transient transaction errors will cause the callback or the commit to be retried; /// other errors will cause the transaction to be aborted and the error returned to the diff --git a/src/cmap/conn/stream_description.rs b/src/cmap/conn/stream_description.rs index 405806ab9..a12a7f2f6 100644 --- a/src/cmap/conn/stream_description.rs +++ b/src/cmap/conn/stream_description.rs @@ -76,6 +76,6 @@ impl StreamDescription { pub(crate) fn supports_retryable_writes(&self) -> bool { self.initial_server_type != ServerType::Standalone && self.logical_session_timeout.is_some() - && self.max_wire_version.map_or(false, |version| version >= 6) + && self.max_wire_version.is_some_and(|version| version >= 6) } } diff --git a/src/cmap/establish/handshake.rs b/src/cmap/establish/handshake.rs index c9b75a538..15b0acb2f 100644 --- a/src/cmap/establish/handshake.rs +++ b/src/cmap/establish/handshake.rs @@ -217,7 +217,7 @@ impl RuntimeEnvironment { } fn var_set(name: &str) -> bool { - env::var_os(name).map_or(false, |v| !v.is_empty()) + env::var_os(name).is_some_and(|v| !v.is_empty()) } impl FaasEnvironmentName { @@ -225,7 +225,7 @@ impl FaasEnvironmentName { use FaasEnvironmentName::*; let mut found: Option = None; let lambda_env = env::var_os("AWS_EXECUTION_ENV") - .map_or(false, |v| v.to_string_lossy().starts_with("AWS_Lambda_")); + .is_some_and(|v| v.to_string_lossy().starts_with("AWS_Lambda_")); if lambda_env || var_set("AWS_LAMBDA_RUNTIME_API") { found = Some(AwsLambda); } diff --git a/src/operation/aggregate/change_stream.rs b/src/operation/aggregate/change_stream.rs index e77f72a7e..00d56e56d 100644 --- a/src/operation/aggregate/change_stream.rs +++ b/src/operation/aggregate/change_stream.rs @@ -61,7 +61,7 @@ impl OperationWithDefaults for ChangeStreamAggregate { .start_at_operation_time .as_ref() .or(data.initial_operation_time.as_ref()); - if saved_time.is_some() && description.max_wire_version.map_or(false, |v| v >= 7) { + if saved_time.is_some() && description.max_wire_version.is_some_and(|v| v >= 7) { new_opts.start_at_operation_time = saved_time.cloned(); } } @@ -109,7 +109,7 @@ impl OperationWithDefaults for ChangeStreamAggregate { let description = context.connection.stream_description()?; if self.args.options.as_ref().map_or(true, has_no_time) - && description.max_wire_version.map_or(false, |v| v >= 7) + && description.max_wire_version.is_some_and(|v| v >= 7) && spec.initial_buffer.is_empty() && spec.post_batch_resume_token.is_none() { diff --git a/src/operation/create_indexes.rs b/src/operation/create_indexes.rs index 5bae53b57..8441933ba 100644 --- a/src/operation/create_indexes.rs +++ b/src/operation/create_indexes.rs @@ -48,7 +48,7 @@ impl OperationWithDefaults for CreateIndexes { && self .options .as_ref() - .map_or(false, |options| options.commit_quorum.is_some()) + .is_some_and(|options| options.commit_quorum.is_some()) { return Err(ErrorKind::InvalidArgument { message: "Specifying a commit quorum to create_index(es) is not supported on \ diff --git a/src/sdam/description/topology/server_selection/test.rs b/src/sdam/description/topology/server_selection/test.rs index 91e6bb671..0ecc74655 100644 --- a/src/sdam/description/topology/server_selection/test.rs +++ b/src/sdam/description/topology/server_selection/test.rs @@ -75,10 +75,7 @@ struct TestServerDescription { impl TestServerDescription { fn into_server_description(self) -> Option { - let server_type = match self.server_type.into_server_type() { - Some(server_type) => server_type, - None => return None, - }; + let server_type = self.server_type.into_server_type()?; let server_address = ServerAddress::parse(self.address).ok()?; let tags = self.tags; diff --git a/src/sdam/srv_polling.rs b/src/sdam/srv_polling.rs index cbdf71a4f..8ad686f07 100644 --- a/src/sdam/srv_polling.rs +++ b/src/sdam/srv_polling.rs @@ -33,10 +33,7 @@ impl SrvPollingMonitor { topology_watcher: TopologyWatcher, mut client_options: ClientOptions, ) -> Option { - let initial_info = match client_options.original_srv_info.take() { - Some(info) => info, - None => return None, - }; + let initial_info = client_options.original_srv_info.take()?; Some(Self { initial_hostname: initial_info.hostname, diff --git a/src/test/client.rs b/src/test/client.rs index 652874110..9da3b6c26 100644 --- a/src/test/client.rs +++ b/src/test/client.rs @@ -888,7 +888,7 @@ async fn warm_connection_pool() { client.list_database_names().await.unwrap(); } -async fn get_end_session_event_count<'a>(event_stream: &mut EventStream<'a, Event>) -> usize { +async fn get_end_session_event_count(event_stream: &mut EventStream<'_, Event>) -> usize { // Use collect_successful_command_execution to assert that the call to endSessions succeeded. event_stream .collect_successful_command_execution(Duration::from_millis(500), "endSessions") diff --git a/src/test/csfle.rs b/src/test/csfle.rs index 9a4df1841..62a7900ac 100644 --- a/src/test/csfle.rs +++ b/src/test/csfle.rs @@ -217,7 +217,7 @@ static EXTRA_OPTIONS: Lazy = static KV_NAMESPACE: Lazy = Lazy::new(|| Namespace::from_str("keyvault.datakeys").unwrap()); static DISABLE_CRYPT_SHARED: Lazy = - Lazy::new(|| env::var("DISABLE_CRYPT_SHARED").map_or(false, |s| s == "true")); + Lazy::new(|| env::var("DISABLE_CRYPT_SHARED").is_ok_and(|s| s == "true")); fn check_env(name: &str, kmip: bool) -> bool { if env::var("CSFLE_LOCAL_KEY").is_err() { diff --git a/src/test/spec/v2_runner.rs b/src/test/spec/v2_runner.rs index b6834f241..c21c41501 100644 --- a/src/test/spec/v2_runner.rs +++ b/src/test/spec/v2_runner.rs @@ -351,11 +351,11 @@ pub(crate) struct OpRunner<'a> { fail_point_guards: &'a mut Vec, } -impl<'a> OpRunner<'a> { - pub(crate) async fn run_operation<'b>( +impl OpRunner<'_> { + pub(crate) async fn run_operation( &mut self, operation: &Operation, - mut sessions: OpSessions<'b>, + mut sessions: OpSessions<'_>, ) -> Option, crate::error::Error>> { if operation.name == "withTransaction" { if !matches!(&operation.object, Some(OperationObject::Session0)) { diff --git a/src/test/util/event_buffer.rs b/src/test/util/event_buffer.rs index 1e67b8825..37c85d978 100644 --- a/src/test/util/event_buffer.rs +++ b/src/test/util/event_buffer.rs @@ -261,7 +261,7 @@ pub(crate) struct EventStream<'a, T> { generation: Generation, } -impl<'a, T: Clone> EventStream<'a, T> { +impl EventStream<'_, T> { fn try_next(&mut self) -> Option { let events = self.buffer.inner.events.lock().unwrap(); if events.generation != self.generation { @@ -372,7 +372,7 @@ impl<'a, T: Clone> EventStream<'a, T> { } } -impl<'a> EventStream<'a, Event> { +impl EventStream<'_, Event> { /// Gets the next unread CommandStartedEvent/CommandFailedEvent pair. /// If the next CommandStartedEvent is associated with a CommandFailedEvent, this method will /// panic. From 37965d310a50c12d46b97c33c387118834763346 Mon Sep 17 00:00:00 2001 From: Isabel Atkinson Date: Tue, 18 Feb 2025 16:01:19 -0700 Subject: [PATCH 3/3] fmt --- src/client/options/test.rs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/client/options/test.rs b/src/client/options/test.rs index ab804d8e1..c9b80d998 100644 --- a/src/client/options/test.rs +++ b/src/client/options/test.rs @@ -154,9 +154,7 @@ async fn run_tests(path: &[&str], skipped_files: &[&str]) { let (_, actual_value) = actual_options .iter() - .find(|(actual_key, _)| { - actual_key.eq_ignore_ascii_case(expected_key) - }) + .find(|(actual_key, _)| actual_key.eq_ignore_ascii_case(expected_key)) .unwrap_or_else(|| { panic!( "{}: parsed options missing {} key",