Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .evergreen/check-clippy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/action/find_and_modify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ use crate::{
use super::{action_impl, deeplink, export_doc, option_setters, options_doc};

impl<T: DeserializeOwned + Send + Sync> Collection<T> {
async fn find_and_modify<'a>(
async fn find_and_modify(
&self,
filter: Document,
modification: Modification,
mut options: Option<FindAndModifyOptions>,
session: Option<&'a mut ClientSession>,
session: Option<&mut ClientSession>,
) -> Result<Option<T>> {
resolve_write_concern_with_session!(self, options, session.as_ref())?;

Expand Down
4 changes: 2 additions & 2 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand All @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion src/client/action/perf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/client/auth/aws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/client/auth/oidc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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: {:?}",
Expand Down
2 changes: 1 addition & 1 deletion src/client/csfle/client_encryption.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<bson::RawBson> {
pub async fn decrypt(&self, value: RawBinaryRef<'_>) -> Result<bson::RawBson> {
if value.subtype != BinarySubtype::Encrypted {
return Err(Error::invalid_argument(format!(
"Invalid binary subtype for decrypt: expected {:?}, got {:?}",
Expand Down
4 changes: 1 addition & 3 deletions src/client/options/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,9 +154,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()
})
.find(|(actual_key, _)| actual_key.eq_ignore_ascii_case(expected_key))
.unwrap_or_else(|| {
panic!(
"{}: parsed options missing {} key",
Expand Down
2 changes: 1 addition & 1 deletion src/client/session/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/cmap/conn/stream_description.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
4 changes: 2 additions & 2 deletions src/cmap/establish/handshake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,15 +217,15 @@ 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 {
pub(crate) fn new() -> Option<Self> {
use FaasEnvironmentName::*;
let mut found: Option<Self> = 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);
}
Expand Down
4 changes: 2 additions & 2 deletions src/operation/aggregate/change_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down Expand Up @@ -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()
{
Expand Down
2 changes: 1 addition & 1 deletion src/operation/create_indexes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
5 changes: 1 addition & 4 deletions src/sdam/description/topology/server_selection/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,7 @@ struct TestServerDescription {

impl TestServerDescription {
fn into_server_description(self) -> Option<ServerDescription> {
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;
Expand Down
5 changes: 1 addition & 4 deletions src/sdam/srv_polling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ impl SrvPollingMonitor {
topology_watcher: TopologyWatcher,
mut client_options: ClientOptions,
) -> Option<Self> {
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,
Expand Down
2 changes: 1 addition & 1 deletion src/test/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion src/test/csfle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ static EXTRA_OPTIONS: Lazy<Document> =
static KV_NAMESPACE: Lazy<Namespace> =
Lazy::new(|| Namespace::from_str("keyvault.datakeys").unwrap());
static DISABLE_CRYPT_SHARED: Lazy<bool> =
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() {
Expand Down
6 changes: 3 additions & 3 deletions src/test/spec/v2_runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,11 +351,11 @@ pub(crate) struct OpRunner<'a> {
fail_point_guards: &'a mut Vec<FailPointGuard>,
}

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<Result<Option<bson::Bson>, crate::error::Error>> {
if operation.name == "withTransaction" {
if !matches!(&operation.object, Some(OperationObject::Session0)) {
Expand Down
4 changes: 2 additions & 2 deletions src/test/util/event_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ pub(crate) struct EventStream<'a, T> {
generation: Generation,
}

impl<'a, T: Clone> EventStream<'a, T> {
impl<T: Clone> EventStream<'_, T> {
fn try_next(&mut self) -> Option<T> {
let events = self.buffer.inner.events.lock().unwrap();
if events.generation != self.generation {
Expand Down Expand Up @@ -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.
Expand Down