diff --git a/Cargo.toml b/Cargo.toml index b80d4004..b98b56fa 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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 = [] diff --git a/src/client/connect/http.rs b/src/client/connect/http.rs index a0c00af4..97a0b340 100644 --- a/src/client/connect/http.rs +++ b/src/client/connect/http.rs @@ -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) { diff --git a/src/client/connect/mod.rs b/src/client/connect/mod.rs index 36e9720b..492f80c8 100644 --- a/src/client/connect/mod.rs +++ b/src/client/connect/mod.rs @@ -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(), } diff --git a/src/client/pool.rs b/src/client/pool.rs index 65291003..95521d21 100644 --- a/src/client/pool.rs +++ b/src/client/pool.rs @@ -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( diff --git a/src/common/mod.rs b/src/common/mod.rs index 294040eb..52b99174 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -11,3 +11,6 @@ macro_rules! ready { pub(crate) use ready; pub(crate) mod exec; +pub(crate) mod never; + +pub(crate) use never::Never; diff --git a/src/common/never.rs b/src/common/never.rs new file mode 100644 index 00000000..f143caf6 --- /dev/null +++ b/src/common/never.rs @@ -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 {} + } +}