Skip to content

Commit

Permalink
RUST-1076 Remove conditional module definition (#511)
Browse files Browse the repository at this point in the history
  • Loading branch information
patrickfreed committed Nov 8, 2021
1 parent 8e55cb2 commit 67d08ef
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 64 deletions.
2 changes: 1 addition & 1 deletion src/client/options/mod.rs
Expand Up @@ -1479,7 +1479,7 @@ impl ClientOptionsParser {
credential.source = options
.auth_source
.clone()
.or(db.clone())
.or_else(|| db.clone())
.or_else(|| Some("admin".into()));
} else if authentication_requested {
return Err(ErrorKind::InvalidArgument {
Expand Down
106 changes: 45 additions & 61 deletions src/lib.rs
Expand Up @@ -304,73 +304,57 @@
#[cfg(all(feature = "aws-auth", feature = "async-std-runtime"))]
compile_error!("The `aws-auth` feature flag is only supported on the tokio runtime.");

macro_rules! define_if_single_runtime_enabled {
( $( $def:item )+ ) => {
$(
#[cfg(any(
all(feature = "tokio-runtime", not(feature = "async-std-runtime")),
all(not(feature = "tokio-runtime"), feature = "async-std-runtime")
))]
$def
)+
}
}
#[macro_use]
pub mod options;

// In the case that neither tokio nor async-std is enabled, we want to disable all compiler errors
// and warnings other than our custom ones.
define_if_single_runtime_enabled! {
#[macro_use]
pub mod options;
pub use ::bson;

pub use ::bson;
mod bson_util;
mod client;
mod cmap;
mod coll;
mod collation;
mod compression;
mod concern;
mod cursor;
mod db;
pub mod error;
pub mod event;
mod index;
mod is_master;
mod operation;
pub mod results;
pub(crate) mod runtime;
mod sdam;
mod selection_criteria;
mod srv;
#[cfg(any(feature = "sync", docsrs))]
#[cfg_attr(docsrs, doc(cfg(feature = "sync")))]
pub mod sync;
#[cfg(test)]
mod test;

mod bson_util;
mod client;
mod cmap;
mod coll;
mod collation;
mod compression;
mod concern;
mod cursor;
mod db;
pub mod error;
pub mod event;
mod index;
mod is_master;
mod operation;
pub mod results;
pub(crate) mod runtime;
mod sdam;
mod selection_criteria;
mod srv;
#[cfg(any(feature = "sync", docsrs))]
#[cfg_attr(docsrs, doc(cfg(feature = "sync")))]
pub mod sync;
#[cfg(test)]
mod test;
#[cfg(test)]
#[macro_use]
extern crate derive_more;

#[cfg(test)]
#[macro_use]
extern crate derive_more;
#[cfg(not(feature = "sync"))]
pub use crate::{
client::{Client, session::ClientSession},
coll::Collection,
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
db::Database,
};

#[cfg(not(feature = "sync"))]
pub use crate::{
client::{Client, session::ClientSession},
coll::Collection,
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
db::Database,
};
#[cfg(feature = "sync")]
pub(crate) use crate::{
client::{Client, session::ClientSession},
coll::Collection,
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
db::Database,
};

#[cfg(feature = "sync")]
pub(crate) use crate::{
client::{Client, session::ClientSession},
coll::Collection,
cursor::{Cursor, session::{SessionCursor, SessionCursorStream}},
db::Database,
};

pub use {coll::Namespace, index::IndexModel, client::session::ClusterTime};
}
pub use {coll::Namespace, index::IndexModel, client::session::ClusterTime};

#[cfg(all(
feature = "tokio-runtime",
Expand Down
2 changes: 0 additions & 2 deletions src/selection_criteria.rs
Expand Up @@ -323,8 +323,6 @@ impl ReadPreference {
where
S: serde::Serializer,
{
use serde::ser::Serialize;

#[derive(serde::Serialize)]
struct ReadPreferenceHelper<'a> {
readpreference: &'a str,
Expand Down

0 comments on commit 67d08ef

Please sign in to comment.