From 5675f2fd7cbf784f472816dedb91cc2127b433fe Mon Sep 17 00:00:00 2001 From: katelyn martin Date: Mon, 20 May 2024 17:36:05 -0400 Subject: [PATCH] =?UTF-8?q?transport:=20=F0=9F=9A=AA=20`HttpsUriWithoutTls?= =?UTF-8?q?Support`=20is=20gated=20on=20`tls`=20feature?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- tonic/src/transport/service/connector.rs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tonic/src/transport/service/connector.rs b/tonic/src/transport/service/connector.rs index b672f3bf3..af6a77629 100644 --- a/tonic/src/transport/service/connector.rs +++ b/tonic/src/transport/service/connector.rs @@ -3,7 +3,6 @@ use super::io::BoxedIo; #[cfg(feature = "tls")] use super::tls::TlsConnector; use http::Uri; -use std::fmt; use std::task::{Context, Poll}; use tower::make::MakeConnection; use tower_service::Service; @@ -104,14 +103,17 @@ where } /// Error returned when trying to connect to an HTTPS endpoint without TLS enabled. +#[cfg(feature = "tls")] #[derive(Debug)] pub(crate) struct HttpsUriWithoutTlsSupport(()); -impl fmt::Display for HttpsUriWithoutTlsSupport { - fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { +#[cfg(feature = "tls")] +impl std::fmt::Display for HttpsUriWithoutTlsSupport { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "Connecting to HTTPS without TLS enabled") } } // std::error::Error only requires a type to impl Debug and Display +#[cfg(feature = "tls")] impl std::error::Error for HttpsUriWithoutTlsSupport {}