Skip to content

Commit 85aade4

Browse files
authored
refactor(lib): add missing feature flags (#8)
* fix: add missing feature flags * chore: score some easy clippy wins * fix: make client tests compile
1 parent 9214294 commit 85aade4

File tree

6 files changed

+32
-5
lines changed

6 files changed

+32
-5
lines changed

Cargo.toml

+5-1
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,16 @@ tower-service = "0.3"
2727
tower = { version = "0.4", features = ["util"] }
2828

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

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

3535
[features]
36+
runtime = []
37+
tcp = []
38+
http1 = []
39+
http2 = []
3640

3741
# internal features used in CI
3842
__internal_happy_eyeballs_tests = []

src/client/connect/http.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,10 @@ fn bind_local_address(
549549
) -> io::Result<()> {
550550
match (*dst_addr, local_addr_ipv4, local_addr_ipv6) {
551551
(SocketAddr::V4(_), Some(addr), _) => {
552-
socket.bind(&SocketAddr::new(addr.clone().into(), 0).into())?;
552+
socket.bind(&SocketAddr::new((*addr).into(), 0).into())?;
553553
}
554554
(SocketAddr::V6(_), _, Some(addr)) => {
555-
socket.bind(&SocketAddr::new(addr.clone().into(), 0).into())?;
555+
socket.bind(&SocketAddr::new((*addr).into(), 0).into())?;
556556
}
557557
_ => {
558558
if cfg!(windows) {

src/client/connect/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ impl Connected {
169169
#[cfg(feature = "http2")]
170170
pub(super) fn clone(&self) -> Connected {
171171
Connected {
172-
alpn: self.alpn.clone(),
172+
alpn: self.alpn,
173173
is_proxied: self.is_proxied,
174174
extra: self.extra.clone(),
175175
}

src/client/pool.rs

-1
Original file line numberDiff line numberDiff line change
@@ -935,7 +935,6 @@ mod tests {
935935
#[cfg(feature = "runtime")]
936936
#[tokio::test]
937937
async fn test_pool_timer_removes_expired() {
938-
let _ = pretty_env_logger::try_init();
939938
tokio::time::pause();
940939

941940
let pool = Pool::new(

src/common/mod.rs

+3
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,6 @@ macro_rules! ready {
1111

1212
pub(crate) use ready;
1313
pub(crate) mod exec;
14+
pub(crate) mod never;
15+
16+
pub(crate) use never::Never;

src/common/never.rs

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
//! An uninhabitable type meaning it can never happen.
2+
//!
3+
//! To be replaced with `!` once it is stable.
4+
5+
use std::error::Error;
6+
use std::fmt;
7+
8+
#[derive(Debug)]
9+
pub(crate) enum Never {}
10+
11+
impl fmt::Display for Never {
12+
fn fmt(&self, _: &mut fmt::Formatter<'_>) -> fmt::Result {
13+
match *self {}
14+
}
15+
}
16+
17+
impl Error for Never {
18+
fn description(&self) -> &str {
19+
match *self {}
20+
}
21+
}

0 commit comments

Comments
 (0)