Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

minor: fix clippy errors on 1.49 #281

Merged
merged 1 commit into from
Jan 6, 2021
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
7 changes: 4 additions & 3 deletions src/client/options/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -681,9 +681,10 @@ impl ClientOptions {
/// used in the SRV tests.
#[cfg(test)]
pub(crate) fn new_srv() -> Self {
let mut options = Self::default();
options.original_srv_hostname = Some("localhost.test.test.build.10gen.cc".into());
options
Self {
original_srv_hostname: Some("localhost.test.test.build.10gen.cc".into()),
..Default::default()
}
}

/// Parses a MongoDB connection string into a ClientOptions struct. If the string is malformed
Expand Down
26 changes: 14 additions & 12 deletions src/cmap/test/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,20 +122,22 @@ async fn concurrent_connections() {
});
futures::future::join_all(tasks).await;

// ensure all three ConnectionCreatedEvents were emitted before one ConnectionReadyEvent.
let events = handler.events.read().unwrap();
let mut consecutive_creations = 0;
for event in events.iter() {
match event {
Event::ConnectionCreated(_) => {
consecutive_creations += 1;
}
Event::ConnectionReady(_) => {
if consecutive_creations < 2 {
panic!("connections not created concurrently");
{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tried using drop(events) on line 141 instead of using a block, but clippy strangely still gave the error about events being held across an await point

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this appears to be a bug in clippy: rust-lang/rust-clippy#6446

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, nice catch

// ensure all three ConnectionCreatedEvents were emitted before one ConnectionReadyEvent.
let events = handler.events.read().unwrap();
let mut consecutive_creations = 0;
for event in events.iter() {
match event {
Event::ConnectionCreated(_) => {
consecutive_creations += 1;
}
Event::ConnectionReady(_) => {
if consecutive_creations < 2 {
panic!("connections not created concurrently");
}
}
_ => (),
}
_ => (),
}
}

Expand Down