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

RUST-1076 Remove conditional module definition #511

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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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