From ad1e5837856441b4de4e0f9c49f887f3131f9ff5 Mon Sep 17 00:00:00 2001
From: Yuki Okushi <huyuumi.dev@gmail.com>
Date: Thu, 14 Nov 2019 22:12:27 +0900
Subject: [PATCH] Fix clippy warnings

---
 actix-codec/src/framed_write.rs | 4 ++--
 actix-rt/src/arbiter.rs         | 2 +-
 actix-rt/src/builder.rs         | 4 ++--
 actix-rt/src/runtime.rs         | 3 +--
 actix-utils/src/framed.rs       | 2 +-
 actix-utils/src/mpsc.rs         | 3 +--
 actix-utils/src/oneshot.rs      | 6 +++---
 router/src/resource.rs          | 9 +++++----
 8 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/actix-codec/src/framed_write.rs b/actix-codec/src/framed_write.rs
index ce60d1eb..2791208a 100644
--- a/actix-codec/src/framed_write.rs
+++ b/actix-codec/src/framed_write.rs
@@ -236,9 +236,9 @@ where
     fn poll_ready(self: Pin<&mut Self>, _: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
         let len = self.buffer.len();
         if len >= self.high_watermark {
-            return Poll::Pending;
+            Poll::Pending
         } else {
-            return Poll::Ready(Ok(()));
+            Poll::Ready(Ok(()))
         }
     }
 
diff --git a/actix-rt/src/arbiter.rs b/actix-rt/src/arbiter.rs
index 0a0456da..31690efc 100644
--- a/actix-rt/src/arbiter.rs
+++ b/actix-rt/src/arbiter.rs
@@ -120,7 +120,7 @@ impl Arbiter {
                 // register arbiter
                 let _ = System::current()
                     .sys()
-                    .unbounded_send(SystemCommand::RegisterArbiter(id, arb.clone()));
+                    .unbounded_send(SystemCommand::RegisterArbiter(id, arb));
 
                 // run loop
                 let _ = match rt.block_on(stop_rx) {
diff --git a/actix-rt/src/builder.rs b/actix-rt/src/builder.rs
index 1083b53a..b7d5b466 100644
--- a/actix-rt/src/builder.rs
+++ b/actix-rt/src/builder.rs
@@ -229,12 +229,12 @@ impl SystemRunner {
     where
         F: Future<Output = O>,
     {
-        let _ = self.rt.block_on(async {
+        self.rt.block_on(async {
             Arbiter::run_system();
         });
 
         let res = self.rt.block_on(fut);
-        let _ = self.rt.block_on(async {
+        self.rt.block_on(async {
             Arbiter::stop_system();
         });
 
diff --git a/actix-rt/src/runtime.rs b/actix-rt/src/runtime.rs
index ac1a6f6e..8e3c6f7b 100644
--- a/actix-rt/src/runtime.rs
+++ b/actix-rt/src/runtime.rs
@@ -125,8 +125,7 @@ impl Runtime {
     {
         self.enter(|executor| {
             // Run the provided future
-            let ret = executor.block_on(f);
-            ret
+            executor.block_on(f)
         })
     }
 
diff --git a/actix-utils/src/framed.rs b/actix-utils/src/framed.rs
index 0951c3db..ccdbabb5 100644
--- a/actix-utils/src/framed.rs
+++ b/actix-utils/src/framed.rs
@@ -221,7 +221,7 @@ where
         }
         TransportState::Error(err) => {
             let is_empty = framed.is_write_buf_empty();
-            if is_empty || (poll_write(cx, state, framed, rx, inner) || is_empty) {
+            if is_empty || poll_write(cx, state, framed, rx, inner) {
                 Poll::Ready(Err(err))
             } else {
                 *state = TransportState::Error(err);
diff --git a/actix-utils/src/mpsc.rs b/actix-utils/src/mpsc.rs
index fe88ebc8..9ada3e7e 100644
--- a/actix-utils/src/mpsc.rs
+++ b/actix-utils/src/mpsc.rs
@@ -133,8 +133,7 @@ impl<T> Receiver<T> {
         let items = match self.state {
             State::Open(ref state) => {
                 let mut state = state.borrow_mut();
-                let items = mem::replace(&mut state.buffer, VecDeque::new());
-                items
+                mem::replace(&mut state.buffer, VecDeque::new())
             }
             State::Closed(_) => return,
         };
diff --git a/actix-utils/src/oneshot.rs b/actix-utils/src/oneshot.rs
index 08e4841b..a8432f28 100644
--- a/actix-utils/src/oneshot.rs
+++ b/actix-utils/src/oneshot.rs
@@ -135,7 +135,7 @@ impl<T> Sender<T> {
     /// non-futures related thread, though, which would otherwise panic if
     /// `poll_cancel` were called.
     pub fn is_canceled(&self) -> bool {
-        !self.inner.upgrade().is_some()
+        self.inner.upgrade().is_none()
     }
 }
 
@@ -166,7 +166,7 @@ impl<T> Receiver<T> {
 
                 self.state = State::Closed(value);
             }
-            State::Closed(_) => return,
+            State::Closed(_) => {},
         };
     }
 }
@@ -180,7 +180,7 @@ impl<T> Future for Receiver<T> {
         let inner = match this.state {
             State::Open(ref mut inner) => inner,
             State::Closed(ref mut item) => match item.take() {
-                Some(item) => return Poll::Ready(Ok(item.into())),
+                Some(item) => return Poll::Ready(Ok(item)),
                 None => return Poll::Ready(Err(Canceled)),
             },
         };
diff --git a/router/src/resource.rs b/router/src/resource.rs
index ec96554f..02d803bc 100644
--- a/router/src/resource.rs
+++ b/router/src/resource.rs
@@ -89,9 +89,9 @@ impl ResourceDef {
                 .collect();
             PatternType::Dynamic(re, names, len)
         } else if for_prefix {
-            PatternType::Prefix(pattern.clone())
+            PatternType::Prefix(pattern)
         } else {
-            PatternType::Static(pattern.clone())
+            PatternType::Static(pattern)
         };
 
         ResourceDef {
@@ -99,7 +99,7 @@ impl ResourceDef {
             elements,
             id: 0,
             name: String::new(),
-            pattern: path.to_owned(),
+            pattern: path,
         }
     }
 
@@ -234,7 +234,8 @@ impl ResourceDef {
                 } else {
                     return false;
                 };
-                path.skip(min(rpath.len(), len) as u16);
+                let rpath_len = rpath.len();
+                path.skip(min(rpath_len, len) as u16);
                 true
             }
         }