From 287a6d18528418381dbb28e7bd6728b1ac24b5d3 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Mon, 8 Feb 2021 14:25:09 -0800 Subject: [PATCH] Lint: fix unused `Identity` if only using `default-tls` (#1164) --- src/async_impl/client.rs | 10 ++++++---- src/blocking/client.rs | 11 +++++++++-- 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/async_impl/client.rs b/src/async_impl/client.rs index 1ded448..16ee45a 100644 --- a/src/async_impl/client.rs +++ b/src/async_impl/client.rs @@ -44,7 +44,9 @@ use crate::redirect::{self, remove_sensitive_headers}; #[cfg(feature = "__tls")] use crate::tls::TlsBackend; #[cfg(feature = "__tls")] -use crate::{Certificate, Identity}; +use crate::Certificate; +#[cfg(any(feature = "native-tls", feature = "__rustls"))] +use crate::Identity; use crate::{IntoUrl, Method, Proxy, StatusCode, Url}; /// An asynchronous `Client` to make Requests with. @@ -84,7 +86,7 @@ struct Config { pool_idle_timeout: Option, pool_max_idle_per_host: usize, tcp_keepalive: Option, - #[cfg(feature = "__tls")] + #[cfg(any(feature = "native-tls", feature = "__rustls"))] identity: Option, proxies: Vec, auto_sys_proxy: bool, @@ -149,7 +151,7 @@ impl ClientBuilder { root_certs: Vec::new(), #[cfg(feature = "__tls")] tls_built_in_root_certs: true, - #[cfg(feature = "__tls")] + #[cfg(any(feature = "native-tls", feature = "__rustls"))] identity: None, #[cfg(feature = "__tls")] tls: TlsBackend::default(), @@ -755,7 +757,7 @@ impl ClientBuilder { /// /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be /// enabled. - #[cfg(feature = "__tls")] + #[cfg(any(feature = "native-tls", feature = "__rustls"))] pub fn identity(mut self, identity: Identity) -> ClientBuilder { self.config.identity = Some(identity); self diff --git a/src/blocking/client.rs b/src/blocking/client.rs index e710b12..c2f0e4b 100644 --- a/src/blocking/client.rs +++ b/src/blocking/client.rs @@ -20,7 +20,9 @@ use super::response::Response; use super::wait; use crate::{async_impl, header, IntoUrl, Method, Proxy, redirect}; #[cfg(feature = "__tls")] -use crate::{Certificate, Identity}; +use crate::Certificate; +#[cfg(any(feature = "native-tls", feature = "__rustls"))] +use crate::Identity; /// A `Client` to make Requests with. /// @@ -461,7 +463,12 @@ impl ClientBuilder { } /// Sets the identity to be used for client certificate authentication. - #[cfg(feature = "__tls")] + /// + /// # Optional + /// + /// This requires the optional `native-tls` or `rustls-tls(-...)` feature to be + /// enabled. + #[cfg(any(feature = "native-tls", feature = "__rustls"))] pub fn identity(self, identity: Identity) -> ClientBuilder { self.with_inner(move |inner| inner.identity(identity)) }