From 07554ded40b7e135c9fca6b03e3e85a0ae51b984 Mon Sep 17 00:00:00 2001 From: tottoto Date: Fri, 15 Dec 2023 23:40:20 +0900 Subject: [PATCH] refactor(error): remove lint config to allow unused code (#3486) --- src/error.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/error.rs b/src/error.rs index ae5bff3a4e..cd650e9fa3 100644 --- a/src/error.rs +++ b/src/error.rs @@ -42,7 +42,7 @@ pub(super) enum Kind { Parse(Parse), User(User), /// A message reached EOF, but is not complete. - #[allow(unused)] + #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] IncompleteMessage, /// A connection received a message (or bytes) when not waiting for one. #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] @@ -100,7 +100,7 @@ pub(super) enum Parse { #[cfg(any(feature = "http1", feature = "http2"))] TooLarge, Status, - #[cfg_attr(debug_assertions, allow(unused))] + #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] Internal, } @@ -215,6 +215,10 @@ impl Error { /// Returns true if the connection closed before a message could complete. pub fn is_incomplete_message(&self) -> bool { + #[cfg(not(all(any(feature = "client", feature = "server"), feature = "http1")))] + return false; + + #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] matches!(self.inner.kind, Kind::IncompleteMessage) } @@ -437,9 +441,11 @@ impl Error { #[cfg(any(feature = "http1", feature = "http2"))] Kind::Parse(Parse::TooLarge) => "message head is too large", Kind::Parse(Parse::Status) => "invalid HTTP status-code parsed", + #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] Kind::Parse(Parse::Internal) => { "internal error inside Hyper and/or its dependencies, please report" } + #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] Kind::IncompleteMessage => "connection closed before message completed", #[cfg(all(any(feature = "client", feature = "server"), feature = "http1"))] Kind::UnexpectedMessage => "received unexpected message from connection",