Skip to content

Commit 23f2a5d

Browse files
committed
minor: fix clippy
1 parent 9881419 commit 23f2a5d

File tree

28 files changed

+85
-84
lines changed

28 files changed

+85
-84
lines changed

Diff for: src/client/auth/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -454,7 +454,7 @@ pub(crate) enum ClientFirst {
454454
impl ClientFirst {
455455
pub(crate) fn to_document(&self) -> Document {
456456
match self {
457-
Self::Scram(version, client_first) => client_first.to_command(&version).body,
457+
Self::Scram(version, client_first) => client_first.to_command(version).body,
458458
Self::X509(command) => command.body.clone(),
459459
}
460460
}

Diff for: src/client/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ impl Client {
285285
message: self
286286
.inner
287287
.topology
288-
.server_selection_timeout_error_message(&criteria)
288+
.server_selection_timeout_error_message(criteria)
289289
.await,
290290
}
291291
.into());

Diff for: src/client/options/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ impl ClientOptionsParser {
11901190
credential.mechanism_properties = Some(doc);
11911191
}
11921192

1193-
mechanism.validate_credential(&credential)?;
1193+
mechanism.validate_credential(credential)?;
11941194
credential.mechanism = options.auth_mechanism.take();
11951195
}
11961196
None => {

Diff for: src/cmap/conn/command.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ impl CommandResponse {
113113
/// Returns whether this response indicates a success or not (i.e. if "ok: 1")
114114
pub(crate) fn is_success(&self) -> bool {
115115
match self.raw_response.get("ok") {
116-
Some(ref b) => bson_util::get_int(b) == Some(1),
116+
Some(b) => bson_util::get_int(b) == Some(1),
117117
_ => false,
118118
}
119119
}

Diff for: src/cmap/test/event.rs

+15-9
Original file line numberDiff line numberDiff line change
@@ -134,34 +134,40 @@ impl EventSubscriber<'_> {
134134
#[derive(Clone, Debug, Deserialize, From, PartialEq)]
135135
#[serde(tag = "type")]
136136
pub enum Event {
137-
#[serde(deserialize_with = "self::deserialize_pool_created")]
138-
ConnectionPoolCreated(PoolCreatedEvent),
139-
ConnectionPoolClosed(PoolClosedEvent),
140-
ConnectionPoolReady(PoolReadyEvent),
137+
#[serde(
138+
deserialize_with = "self::deserialize_pool_created",
139+
rename = "ConnectionPoolCreated"
140+
)]
141+
PoolCreated(PoolCreatedEvent),
142+
#[serde(rename = "ConnectionPoolClosed")]
143+
PoolClosed(PoolClosedEvent),
144+
#[serde(rename = "ConnectionPoolReady")]
145+
PoolReady(PoolReadyEvent),
141146
ConnectionCreated(ConnectionCreatedEvent),
142147
ConnectionReady(ConnectionReadyEvent),
143148
ConnectionClosed(ConnectionClosedEvent),
144149
ConnectionCheckOutStarted(ConnectionCheckoutStartedEvent),
145150
#[serde(deserialize_with = "self::deserialize_checkout_failed")]
146151
ConnectionCheckOutFailed(ConnectionCheckoutFailedEvent),
147152
ConnectionCheckedOut(ConnectionCheckedOutEvent),
148-
ConnectionPoolCleared(PoolClearedEvent),
153+
#[serde(rename = "ConnectionPoolCleared")]
154+
PoolCleared(PoolClearedEvent),
149155
ConnectionCheckedIn(ConnectionCheckedInEvent),
150156
}
151157

152158
impl Event {
153159
pub fn name(&self) -> &'static str {
154160
match self {
155-
Event::ConnectionPoolCreated(_) => "ConnectionPoolCreated",
156-
Event::ConnectionPoolReady(_) => "ConnectionPoolReady",
157-
Event::ConnectionPoolClosed(_) => "ConnectionPoolClosed",
161+
Event::PoolCreated(_) => "ConnectionPoolCreated",
162+
Event::PoolReady(_) => "ConnectionPoolReady",
163+
Event::PoolClosed(_) => "ConnectionPoolClosed",
158164
Event::ConnectionCreated(_) => "ConnectionCreated",
159165
Event::ConnectionReady(_) => "ConnectionReady",
160166
Event::ConnectionClosed(_) => "ConnectionClosed",
161167
Event::ConnectionCheckOutStarted(_) => "ConnectionCheckOutStarted",
162168
Event::ConnectionCheckOutFailed(_) => "ConnectionCheckOutFailed",
163169
Event::ConnectionCheckedOut(_) => "ConnectionCheckedOut",
164-
Event::ConnectionPoolCleared(_) => "ConnectionPoolCleared",
170+
Event::PoolCleared(_) => "ConnectionPoolCleared",
165171
Event::ConnectionCheckedIn(_) => "ConnectionCheckedIn",
166172
}
167173
}

Diff for: src/cmap/test/integration.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ async fn concurrent_connections() {
8282
let client = TestClient::with_options(Some(options), true).await;
8383
let version = VersionReq::parse(">= 4.2.9").unwrap();
8484
// blockConnection failpoint option only supported in 4.2.9+.
85-
if !version.matches(&client.server_version.as_ref().unwrap()) {
85+
if !version.matches(client.server_version.as_ref().unwrap()) {
8686
println!(
8787
"skipping concurrent_connections test due to server not supporting failpoint option"
8888
);

Diff for: src/cmap/test/mod.rs

+6-8
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,7 @@ impl Operation {
309309

310310
// wait for event to be emitted to ensure drop has completed.
311311
subscriber
312-
.wait_for_event(EVENT_TIMEOUT, |e| {
313-
matches!(e, Event::ConnectionPoolClosed(_))
314-
})
312+
.wait_for_event(EVENT_TIMEOUT, |e| matches!(e, Event::PoolClosed(_)))
315313
.await
316314
.expect("did not receive ConnectionPoolClosed event after closing pool");
317315
}
@@ -356,7 +354,7 @@ impl Matchable for ConnectionPoolOptions {
356354
impl Matchable for Event {
357355
fn content_matches(&self, expected: &Event) -> bool {
358356
match (self, expected) {
359-
(Event::ConnectionPoolCreated(actual), Event::ConnectionPoolCreated(ref expected)) => {
357+
(Event::PoolCreated(actual), Event::PoolCreated(ref expected)) => {
360358
actual.options.matches(&expected.options)
361359
}
362360
(Event::ConnectionCreated(actual), Event::ConnectionCreated(ref expected)) => {
@@ -380,9 +378,9 @@ impl Matchable for Event {
380378
Event::ConnectionCheckOutFailed(ref expected),
381379
) => actual.reason == expected.reason,
382380
(Event::ConnectionCheckOutStarted(_), Event::ConnectionCheckOutStarted(_)) => true,
383-
(Event::ConnectionPoolCleared(_), Event::ConnectionPoolCleared(_)) => true,
384-
(Event::ConnectionPoolReady(_), Event::ConnectionPoolReady(_)) => true,
385-
(Event::ConnectionPoolClosed(_), Event::ConnectionPoolClosed(_)) => true,
381+
(Event::PoolCleared(_), Event::PoolCleared(_)) => true,
382+
(Event::PoolReady(_), Event::PoolReady(_)) => true,
383+
(Event::PoolClosed(_), Event::PoolClosed(_)) => true,
386384
_ => false,
387385
}
388386
}
@@ -464,7 +462,7 @@ async fn redact_credential() {
464462

465463
subscriber
466464
.wait_for_event(EVENT_TIMEOUT, |e| {
467-
if let crate::test::Event::CmapEvent(CmapEvent::ConnectionPoolCreated(event)) = e {
465+
if let crate::test::Event::CmapEvent(CmapEvent::PoolCreated(event)) = e {
468466
let event_debug = format!("{:?}", event);
469467
if let Some(ref pass) = credential.password {
470468
assert!(!event_debug.contains(pass))

Diff for: src/error.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ impl Error {
9797
}
9898
match &self.kind.code_and_message() {
9999
Some((code, message)) => {
100-
if RETRYABLE_READ_CODES.contains(&code) {
100+
if RETRYABLE_READ_CODES.contains(code) {
101101
return true;
102102
}
103103
if is_not_master(*code, message) || is_recovering(*code, message) {
@@ -125,7 +125,7 @@ impl Error {
125125
return true;
126126
}
127127
match &self.kind.code_and_message() {
128-
Some((code, _)) => RETRYABLE_WRITE_CODES.contains(&code),
128+
Some((code, _)) => RETRYABLE_WRITE_CODES.contains(code),
129129
None => false,
130130
}
131131
}

Diff for: src/operation/insert/test.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,10 @@ async fn build() {
7373

7474
for (original_doc, cmd_doc) in fixtures.documents.iter().zip(cmd_docs.iter_mut()) {
7575
assert!(cmd_doc.get("_id").is_some());
76-
if original_doc.get("_id").is_some() {
77-
assert_eq!(original_doc, cmd_doc);
78-
} else {
76+
if !original_doc.get("_id").is_some() {
7977
cmd_doc.remove("_id");
80-
assert_eq!(original_doc, cmd_doc);
81-
};
78+
}
79+
assert_eq!(original_doc, cmd_doc);
8280
}
8381

8482
assert_eq!(

Diff for: src/runtime/stream.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ impl AsyncTcpStream {
9292
let socket = Socket::new(domain, Type::stream(), Some(Protocol::tcp()))?;
9393
socket.set_keepalive(Some(KEEPALIVE_TIME))?;
9494

95-
let address: SockAddr = address.clone().into();
95+
let address: SockAddr = (*address).into();
9696
if connect_timeout == Duration::from_secs(0) {
9797
socket.connect(&address)?;
9898
} else {

Diff for: src/sdam/description/topology/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ impl TopologyDescription {
674674
servers: impl Iterator<Item = &'a StreamAddress>,
675675
) {
676676
for server in servers {
677-
if !self.servers.contains_key(&server) {
677+
if !self.servers.contains_key(server) {
678678
self.servers
679679
.insert(server.clone(), ServerDescription::new(server.clone(), None));
680680
}

Diff for: src/sdam/description/topology/server_selection/test/in_window.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ async fn load_balancing_test() {
119119

120120
let version = VersionReq::parse(">= 4.2.9").unwrap();
121121
// blockConnection failpoint option only supported in 4.2.9+.
122-
if !version.matches(&setup_client.server_version.as_ref().unwrap()) {
122+
if !version.matches(setup_client.server_version.as_ref().unwrap()) {
123123
println!(
124124
"skipping load_balancing_test test due to server not supporting blockConnection option"
125125
);

Diff for: src/sdam/state/mod.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,7 @@ impl Topology {
233233
/// an operation.
234234
pub(crate) async fn handle_pre_handshake_error(&self, error: Error, server: &Server) -> bool {
235235
let state_lock = self.state.write().await;
236-
let changed = self
237-
.mark_server_as_unknown(error, &server, state_lock)
238-
.await;
236+
let changed = self.mark_server_as_unknown(error, server, state_lock).await;
239237
if changed {
240238
server.pool.clear();
241239
}
@@ -495,9 +493,9 @@ impl TopologyState {
495493
topology: WeakTopology,
496494
) -> Option<TopologyDescriptionDiff> {
497495
let old_description = self.description.clone();
498-
self.description.sync_hosts(&hosts);
496+
self.description.sync_hosts(hosts);
499497

500-
self.sync_hosts(&hosts, options, &topology);
498+
self.sync_hosts(hosts, options, &topology);
501499

502500
old_description.diff(&self.description)
503501
}

Diff for: src/sdam/test.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ async fn sdam_pool_management() {
118118

119119
subscriber
120120
.wait_for_event(Duration::from_millis(500), |event| {
121-
matches!(event, Event::CmapEvent(CmapEvent::ConnectionPoolReady(_)))
121+
matches!(event, Event::CmapEvent(CmapEvent::PoolReady(_)))
122122
})
123123
.await
124124
.expect("should see pool ready event");
@@ -136,14 +136,14 @@ async fn sdam_pool_management() {
136136

137137
subscriber
138138
.wait_for_event(Duration::from_millis(1000), |event| {
139-
matches!(event, Event::CmapEvent(CmapEvent::ConnectionPoolCleared(_)))
139+
matches!(event, Event::CmapEvent(CmapEvent::PoolCleared(_)))
140140
})
141141
.await
142142
.expect("should see pool cleared event");
143143

144144
subscriber
145145
.wait_for_event(Duration::from_millis(1000), |event| {
146-
matches!(event, Event::CmapEvent(CmapEvent::ConnectionPoolReady(_)))
146+
matches!(event, Event::CmapEvent(CmapEvent::PoolReady(_)))
147147
})
148148
.await
149149
.expect("should see pool ready event");
@@ -196,7 +196,7 @@ async fn sdam_min_pool_size_error() {
196196

197197
subscriber
198198
.wait_for_event(Duration::from_millis(2000), |event| {
199-
matches!(event, Event::CmapEvent(CmapEvent::ConnectionPoolCleared(_)))
199+
matches!(event, Event::CmapEvent(CmapEvent::PoolCleared(_)))
200200
})
201201
.await
202202
.expect("should see pool cleared event");
@@ -231,7 +231,7 @@ async fn sdam_min_pool_size_error() {
231231

232232
subscriber
233233
.wait_for_event(Duration::from_millis(10), |event| {
234-
matches!(event, Event::CmapEvent(CmapEvent::ConnectionPoolReady(_)))
234+
matches!(event, Event::CmapEvent(CmapEvent::PoolReady(_)))
235235
})
236236
.await
237237
.expect("should see pool ready event");

Diff for: src/srv.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ impl SrvResolver {
3939
replica_set: None,
4040
};
4141

42-
self.get_txt_options(&hostname, &mut config).await?;
42+
self.get_txt_options(hostname, &mut config).await?;
4343

4444
Ok(config)
4545
}

Diff for: src/sync/db.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ impl Database {
6767

6868
/// Gets the name of the `Database`.
6969
pub fn name(&self) -> &str {
70-
&self.async_database.name()
70+
self.async_database.name()
7171
}
7272

7373
/// Gets the read preference of the `Database`.

Diff for: src/test/coll.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ async fn insert_err_details() {
8383
let result = doc.get_document("writeConcern");
8484
match result {
8585
Ok(write_concern_doc) => {
86-
assert_eq!(write_concern_doc.contains_key("provenance"), true);
86+
assert!(write_concern_doc.contains_key("provenance"));
8787
}
8888
Err(e) => panic!("{:?}", e),
8989
}
@@ -654,7 +654,7 @@ async fn find_one_and_delete_hint_test(options: Option<FindOneAndDeleteOptions>,
654654
let client = EventClient::new().await;
655655

656656
let req = VersionReq::parse(">= 4.2").unwrap();
657-
if options.is_some() && !req.matches(&client.server_version.as_ref().unwrap()) {
657+
if options.is_some() && !req.matches(client.server_version.as_ref().unwrap()) {
658658
return;
659659
}
660660

@@ -712,13 +712,13 @@ async fn find_one_and_delete_hint_server_version() {
712712

713713
let req1 = VersionReq::parse("< 4.2").unwrap();
714714
let req2 = VersionReq::parse("4.2.*").unwrap();
715-
if req1.matches(&client.server_version.as_ref().unwrap()) {
715+
if req1.matches(client.server_version.as_ref().unwrap()) {
716716
let error = res.expect_err("find one and delete should fail");
717717
assert!(matches!(
718718
error.kind.as_ref(),
719719
ErrorKind::OperationError { .. }
720720
));
721-
} else if req2.matches(&client.server_version.as_ref().unwrap()) {
721+
} else if req2.matches(client.server_version.as_ref().unwrap()) {
722722
let error = res.expect_err("find one and delete should fail");
723723
assert!(matches!(
724724
error.kind.as_ref(),

0 commit comments

Comments
 (0)