Skip to content

Commit

Permalink
refactor(lib): add missing feature flags (#8)
Browse files Browse the repository at this point in the history
* fix: add missing feature flags

* chore: score some easy clippy wins

* fix: make client tests compile
  • Loading branch information
tomkarw authored Aug 22, 2022
1 parent 9214294 commit 85aade4
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 5 deletions.
6 changes: 5 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,16 @@ tower-service = "0.3"
tower = { version = "0.4", features = ["util"] }

[dev-dependencies]
tokio = { version = "1", features = ["macros"] }
tokio = { version = "1", features = ["macros", "test-util"] }

[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dev-dependencies]
pnet_datalink = "0.27.2"

[features]
runtime = []
tcp = []
http1 = []
http2 = []

# internal features used in CI
__internal_happy_eyeballs_tests = []
4 changes: 2 additions & 2 deletions src/client/connect/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@ fn bind_local_address(
) -> io::Result<()> {
match (*dst_addr, local_addr_ipv4, local_addr_ipv6) {
(SocketAddr::V4(_), Some(addr), _) => {
socket.bind(&SocketAddr::new(addr.clone().into(), 0).into())?;
socket.bind(&SocketAddr::new((*addr).into(), 0).into())?;
}
(SocketAddr::V6(_), _, Some(addr)) => {
socket.bind(&SocketAddr::new(addr.clone().into(), 0).into())?;
socket.bind(&SocketAddr::new((*addr).into(), 0).into())?;
}
_ => {
if cfg!(windows) {
Expand Down
2 changes: 1 addition & 1 deletion src/client/connect/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ impl Connected {
#[cfg(feature = "http2")]
pub(super) fn clone(&self) -> Connected {
Connected {
alpn: self.alpn.clone(),
alpn: self.alpn,
is_proxied: self.is_proxied,
extra: self.extra.clone(),
}
Expand Down
1 change: 0 additions & 1 deletion src/client/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -935,7 +935,6 @@ mod tests {
#[cfg(feature = "runtime")]
#[tokio::test]
async fn test_pool_timer_removes_expired() {
let _ = pretty_env_logger::try_init();
tokio::time::pause();

let pool = Pool::new(
Expand Down
3 changes: 3 additions & 0 deletions src/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ macro_rules! ready {

pub(crate) use ready;
pub(crate) mod exec;
pub(crate) mod never;

pub(crate) use never::Never;
21 changes: 21 additions & 0 deletions src/common/never.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
//! An uninhabitable type meaning it can never happen.
//!
//! To be replaced with `!` once it is stable.

use std::error::Error;
use std::fmt;

#[derive(Debug)]
pub(crate) enum Never {}

impl fmt::Display for Never {
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {}
}
}

impl Error for Never {
fn description(&self) -> &str {
match *self {}
}
}

0 comments on commit 85aade4

Please sign in to comment.