Skip to content

Commit

Permalink
refactor(error): remove lint config to allow unused code (#3486)
Browse files Browse the repository at this point in the history
  • Loading branch information
tottoto authored Dec 15, 2023
1 parent 15d9706 commit 07554de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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"))]
Expand Down Expand Up @@ -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,
}

Expand Down Expand Up @@ -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)
}

Expand Down Expand Up @@ -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",
Expand Down

0 comments on commit 07554de

Please sign in to comment.