Skip to content

Commit e298c5c

Browse files
committed
Make proxy available without the feature
When we introduced the `rustls` feature, we did it like this: ```toml [features] proxy = ["hyper-proxy"] rustls = ["hyper-proxy/rustls", "tokio-rustls", "hyper-rustls"] tls = ["hyper-proxy/tls", "native-tls", "tokio-tls", "hyper-tls"] ``` A problem is hidden here: enabling an optional dependency's feature enabled the dependency. Because of this, `hyper-proxy` is already being downloaded and compiled, even if `proxy` isn't enabled: ``` $ cargo c … Checking hyper-proxy v0.6.0 Checking tbot v0.5.1 (…) ``` But to be able to use it, you have to enable the `proxy` feature, which seems odd. Since cargo doesn't provide a way to enable an optional dependency's feature without enabling the dependency (at least yet; rust-lang/cargo#3494), I think that it's better to always provide proxy functionality.
1 parent e1377c7 commit e298c5c

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ categories = [
2424

2525
[dependencies]
2626
hyper = { version = "0.13.3", default-features = false }
27-
hyper-proxy = { version = "0.6", optional = true, default-features = false }
27+
hyper-proxy = { version = "0.6", default-features = false }
2828
tokio = { version = "0.2", features = ["time", "rt-core", "tcp"] }
2929
serde_json = "1"
3030
serde = { version = "1.0.34", features = ["derive"] }
@@ -41,7 +41,7 @@ tracing-futures = "0.2"
4141
meval = "0.2"
4242

4343
[features]
44-
proxy = ["hyper-proxy"]
44+
proxy = []
4545
rustls = ["hyper-proxy/rustls", "tokio-rustls", "hyper-rustls"]
4646
tls = ["hyper-proxy/tls", "native-tls", "tokio-tls", "hyper-tls"]
4747
default = ["tls"]
@@ -80,7 +80,7 @@ required-features = ["tokio/macros"]
8080

8181
[[example]]
8282
name = "proxy"
83-
required-features = ["tokio/macros", "proxy"]
83+
required-features = ["tokio/macros"]
8484

8585
[[example]]
8686
name = "sticker_packs"

src/connectors.rs

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ use hyper_rustls::HttpsConnector;
1111
#[cfg(feature = "tls")]
1212
use hyper_tls::HttpsConnector;
1313

14-
#[cfg(feature = "proxy")]
1514
pub use hyper_proxy as proxy;
16-
#[cfg(feature = "proxy")]
1715
use proxy::ProxyConnector;
1816

1917
/// The default HTTPS connector.
2018
pub type Https = HttpsConnector<HttpConnector>;
2119

22-
#[cfg(feature = "proxy")]
2320
/// The default proxy connector.
2421
pub type Proxy = ProxyConnector<Https>;
2522

@@ -29,7 +26,6 @@ pub fn https() -> Https {
2926
HttpsConnector::new()
3027
}
3128

32-
#[cfg(feature = "proxy")]
3329
/// Constructs a proxy connector.
3430
pub fn proxy(proxy: proxy::Proxy) -> Proxy {
3531
ProxyConnector::from_proxy(https(), proxy).unwrap_or_else(|error| {

0 commit comments

Comments
 (0)