Skip to content
Open
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ panic = "allow"
pattern_type_mismatch = "allow"
redundant_closure_for_method_calls = "allow"
redundant_else = "allow"
ref_patterns = "allow" # TODO: perhaps deny?
single_char_lifetime_names = "allow"
struct_excessive_bools = "allow" # TODO: bogus lint?
trivially_copy_pass_by_ref = "allow"
Expand Down
10 changes: 3 additions & 7 deletions benches/end_to_end.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,13 +368,9 @@ impl Opts {
};

let mut send_request = |req| {
let fut = match client {
Client::Http1(ref mut tx) => {
futures_util::future::Either::Left(tx.send_request(req))
}
Client::Http2(ref mut tx) => {
futures_util::future::Either::Right(tx.send_request(req))
}
let fut = match &mut client {
Client::Http1(tx) => futures_util::future::Either::Left(tx.send_request(req)),
Client::Http2(tx) => futures_util::future::Either::Right(tx.send_request(req)),
};
async {
let res = fut.await.expect("client wait");
Expand Down
41 changes: 19 additions & 22 deletions src/body/incoming.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,12 @@ impl Incoming {

#[cfg(feature = "ffi")]
pub(crate) fn as_ffi_mut(&mut self) -> &mut crate::ffi::UserBody {
match self.kind {
Kind::Ffi(ref mut body) => return body,
_ => {
self.kind = Kind::Ffi(crate::ffi::UserBody::new());
}
if !matches!(self.kind, Kind::Ffi(_)) {
self.kind = Kind::Ffi(crate::ffi::UserBody::new());
}

match self.kind {
Kind::Ffi(ref mut body) => body,
match &mut self.kind {
Kind::Ffi(body) => body,
_ => unreachable!(),
}
}
Comment thread
dswij marked this conversation as resolved.
Expand Down Expand Up @@ -208,14 +205,14 @@ impl Body for Incoming {
)]
cx: &mut Context<'_>,
) -> Poll<Option<Result<Frame<Self::Data>, Self::Error>>> {
match self.kind {
match &mut self.kind {
Kind::Empty => Poll::Ready(None),
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
Kind::Chan {
content_length: ref mut len,
ref mut data_rx,
ref mut want_tx,
ref mut trailers_rx,
content_length: len,
data_rx,
want_tx,
trailers_rx,
} => {
want_tx.send(WANT_READY);

Expand All @@ -234,10 +231,10 @@ impl Body for Incoming {
}
#[cfg(all(feature = "http2", any(feature = "client", feature = "server")))]
Kind::H2 {
ref mut data_done,
ref ping,
recv: ref mut h2,
content_length: ref mut len,
data_done,
ping,
recv: h2,
content_length: len,
} => {
if !*data_done {
match ready!(h2.poll_data(cx)) {
Expand Down Expand Up @@ -284,17 +281,17 @@ impl Body for Incoming {
}

#[cfg(feature = "ffi")]
Kind::Ffi(ref mut body) => body.poll_data(cx),
Kind::Ffi(body) => body.poll_data(cx),
}
}

fn is_end_stream(&self) -> bool {
match self.kind {
match &self.kind {
Kind::Empty => true,
#[cfg(all(feature = "http1", any(feature = "client", feature = "server")))]
Kind::Chan { content_length, .. } => content_length == DecodedLength::ZERO,
Kind::Chan { content_length, .. } => *content_length == DecodedLength::ZERO,
#[cfg(all(feature = "http2", any(feature = "client", feature = "server")))]
Kind::H2 { recv: ref h2, .. } => h2.is_end_stream(),
Kind::H2 { recv: h2, .. } => h2.is_end_stream(),
#[cfg(feature = "ffi")]
Kind::Ffi(..) => false,
}
Expand Down Expand Up @@ -633,8 +630,8 @@ mod tests {
drop(rx);
assert!(tx_ready.is_woken(), "dropping rx wakes tx");

match tx_ready.poll() {
Poll::Ready(Err(ref e)) if e.is_closed() => (),
match &tx_ready.poll() {
Poll::Ready(Err(e)) if e.is_closed() => (),
unexpected => panic!("tx poll ready unexpected: {:?}", unexpected),
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/body/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ impl DecodedLength {
any(feature = "client", feature = "server")
))]
pub(crate) fn sub_if(&mut self, amt: u64) {
match *self {
DecodedLength::CHUNKED | DecodedLength::CLOSE_DELIMITED => (),
DecodedLength(ref mut known) => {
match self {
&mut DecodedLength::CHUNKED | &mut DecodedLength::CLOSE_DELIMITED => (),
DecodedLength(known) => {
*known -= amt;
}
}
Expand Down
18 changes: 9 additions & 9 deletions src/client/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -266,30 +266,30 @@ fn dispatch_gone() -> crate::Error {
impl<T, U> Callback<T, U> {
#[cfg(feature = "http2")]
pub(crate) fn is_canceled(&self) -> bool {
match *self {
Callback::Retry(Some(ref tx)) => tx.is_closed(),
Callback::NoRetry(Some(ref tx)) => tx.is_closed(),
match self {
Callback::Retry(Some(tx)) => tx.is_closed(),
Callback::NoRetry(Some(tx)) => tx.is_closed(),
_ => unreachable!(),
}
}

pub(crate) fn poll_canceled(&mut self, cx: &mut Context<'_>) -> Poll<()> {
match *self {
Callback::Retry(Some(ref mut tx)) => tx.poll_closed(cx),
Callback::NoRetry(Some(ref mut tx)) => tx.poll_closed(cx),
match self {
Callback::Retry(Some(tx)) => tx.poll_closed(cx),
Callback::NoRetry(Some(tx)) => tx.poll_closed(cx),
_ => unreachable!(),
}
}

pub(crate) fn send(mut self, val: Result<U, TrySendError<T>>) {
match self {
Callback::Retry(ref mut tx) => {
match &mut self {
Callback::Retry(tx) => {
let _ = tx
.take()
.expect("callback sender not dropped before send")
.send(val);
}
Callback::NoRetry(ref mut tx) => {
Callback::NoRetry(tx) => {
let _ = tx
.take()
.expect("callback sender not dropped before send")
Expand Down
16 changes: 8 additions & 8 deletions src/common/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,37 +32,37 @@ impl fmt::Debug for Time {
impl Time {
#[cfg(all(any(feature = "client", feature = "server"), feature = "http2"))]
pub(crate) fn sleep(&self, duration: Duration) -> Pin<Box<dyn Sleep>> {
match *self {
match &self {
Time::Empty => {
panic!("You must supply a timer.")
}
Time::Timer(ref t) => t.sleep(duration),
Time::Timer(t) => t.sleep(duration),
}
}

#[cfg(all(feature = "server", feature = "http1"))]
pub(crate) fn sleep_until(&self, deadline: Instant) -> Pin<Box<dyn Sleep>> {
match *self {
match &self {
Time::Empty => {
panic!("You must supply a timer.")
}
Time::Timer(ref t) => t.sleep_until(deadline),
Time::Timer(t) => t.sleep_until(deadline),
}
}

pub(crate) fn now(&self) -> Instant {
match *self {
match &self {
Time::Empty => Instant::now(),
Time::Timer(ref t) => t.now(),
Time::Timer(t) => t.now(),
}
}

pub(crate) fn reset(&self, sleep: &mut Pin<Box<dyn Sleep>>, new_deadline: Instant) {
match *self {
match &self {
Time::Empty => {
panic!("You must supply a timer.")
}
Time::Timer(ref t) => t.reset(sleep, new_deadline),
Time::Timer(t) => t.reset(sleep, new_deadline),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ impl fmt::Debug for Error {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let mut f = f.debug_tuple("hyper::Error");
f.field(&self.inner.kind);
if let Some(ref cause) = self.inner.cause {
if let Some(cause) = &self.inner.cause {
f.field(cause);
}
f.finish()
Expand Down
6 changes: 3 additions & 3 deletions src/ffi/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,9 @@ ffi_fn! {
// Update request with original-case map of headers
req.finalize_request();

let fut = match non_null! { &mut *conn ?= ptr::null_mut() }.tx {
Tx::Http1(ref mut tx) => futures_util::future::Either::Left(tx.send_request(req.0)),
Tx::Http2(ref mut tx) => futures_util::future::Either::Right(tx.send_request(req.0)),
let fut = match &mut non_null! { &mut *conn ?= ptr::null_mut() }.tx {
Tx::Http1(tx) => futures_util::future::Either::Left(tx.send_request(req.0)),
Tx::Http2(tx) => futures_util::future::Either::Right(tx.send_request(req.0)),
};

let fut = async move {
Expand Down
4 changes: 2 additions & 2 deletions src/ffi/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ impl hyper_task {
}

fn output_type(&self) -> hyper_task_return_type {
match self.output {
match &self.output {
None => hyper_task_return_type::HYPER_TASK_EMPTY,
Some(ref val) => val.as_task_type(),
Some(val) => val.as_task_type(),
}
}
}
Expand Down
38 changes: 19 additions & 19 deletions src/proto/h1/conn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@ where
if let Some(h1_header_read_timeout) = self.state.h1_header_read_timeout {
let deadline = self.state.timer.now() + h1_header_read_timeout;
self.state.h1_header_read_timeout_running = true;
match self.state.h1_header_read_timeout_fut {
Some(ref mut h1_header_read_timeout_fut) => {
match &mut self.state.h1_header_read_timeout_fut {
Some(h1_header_read_timeout_fut) => {
trace!("resetting h1 header read timeout timer");
self.state.timer.reset(h1_header_read_timeout_fut, deadline);
}
Expand Down Expand Up @@ -254,8 +254,8 @@ where
Poll::Pending => {
#[cfg(feature = "server")]
if self.state.h1_header_read_timeout_running {
if let Some(ref mut h1_header_read_timeout_fut) =
self.state.h1_header_read_timeout_fut
if let Some(h1_header_read_timeout_fut) =
&mut self.state.h1_header_read_timeout_fut
{
if Pin::new(h1_header_read_timeout_fut).poll(cx).is_ready() {
self.state.h1_header_read_timeout_running = false;
Expand Down Expand Up @@ -366,8 +366,8 @@ where
) -> Poll<Option<io::Result<Frame<Bytes>>>> {
debug_assert!(self.can_read_body());

let (reading, ret) = match self.state.reading {
Reading::Body(ref mut decoder) => {
let (reading, ret) = match &mut self.state.reading {
Reading::Body(decoder) => {
match ready!(decoder.decode(cx, &mut self.io)) {
Ok(frame) => {
if frame.is_data() {
Expand Down Expand Up @@ -406,7 +406,7 @@ where
}
}
}
Reading::Continue(ref decoder) => {
Reading::Continue(decoder) => {
// Write the 100 Continue if not already responded...
if let Writing::Init = self.state.writing {
trace!("automatically sending 100 Continue");
Expand Down Expand Up @@ -715,8 +715,8 @@ where
// empty chunks should be discarded at Dispatcher level
debug_assert!(chunk.remaining() != 0);

let state = match self.state.writing {
Writing::Body(ref mut encoder) => {
let state = match &mut self.state.writing {
Writing::Body(encoder) => {
self.io.buffer(encoder.encode(chunk));

if !encoder.is_eof() {
Expand All @@ -742,8 +742,8 @@ where
}
debug_assert!(self.can_write_body() && self.can_buffer_body());

match self.state.writing {
Writing::Body(ref encoder) => {
match &mut self.state.writing {
Writing::Body(encoder) => {
if let Some(enc_buf) =
encoder.encode_trailers(trailers, self.state.title_case_headers)
{
Expand All @@ -765,8 +765,8 @@ where
// empty chunks should be discarded at Dispatcher level
debug_assert!(chunk.remaining() != 0);

let state = match self.state.writing {
Writing::Body(ref encoder) => {
let state = match &mut self.state.writing {
Writing::Body(encoder) => {
let can_keep_alive = encoder.encode_and_end(chunk, self.io.write_buf());
if can_keep_alive {
Writing::KeepAlive
Expand All @@ -783,8 +783,8 @@ where
pub(crate) fn end_body(&mut self) -> crate::Result<()> {
debug_assert!(self.can_write_body());

let encoder = match self.state.writing {
Writing::Body(ref mut enc) => enc,
let encoder = match &mut self.state.writing {
Writing::Body(enc) => enc,
_ => return Ok(()),
};

Expand Down Expand Up @@ -856,7 +856,7 @@ where

/// If the read side can be cheaply drained, do so. Otherwise, close.
pub(super) fn poll_drain_or_close_read(&mut self, cx: &mut Context<'_>) {
if let Reading::Continue(ref decoder) = self.state.reading {
if let Reading::Continue(decoder) = &mut self.state.reading {
// skip sending the 100-continue
// just move forward to a read, in case a tiny body was included
self.state.reading = Reading::Body(decoder.clone());
Expand Down Expand Up @@ -994,7 +994,7 @@ impl fmt::Debug for State {
.field("keep_alive", &self.keep_alive);

// Only show error field if it's interesting...
if let Some(ref error) = self.error {
if let Some(error) = &self.error {
builder.field("error", error);
}

Expand All @@ -1010,9 +1010,9 @@ impl fmt::Debug for State {

impl fmt::Debug for Writing {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match *self {
match self {
Writing::Init => f.write_str("Init"),
Writing::Body(ref enc) => f.debug_tuple("Body").field(enc).finish(),
Writing::Body(enc) => f.debug_tuple("Body").field(enc).finish(),
Writing::KeepAlive => f.write_str("KeepAlive"),
Writing::Closed => f.write_str("Closed"),
}
Expand Down
Loading
Loading