From 33e510e7bae5c39452cea4a0c92a9f2e696db324 Mon Sep 17 00:00:00 2001 From: Datong Sun Date: Fri, 19 Nov 2021 10:45:13 -0800 Subject: [PATCH] fix(fake-tcp) remove unneeded `State::Closed` as it is not in a reachable code path --- fake-tcp/src/lib.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/fake-tcp/src/lib.rs b/fake-tcp/src/lib.rs index 3a1025d..6874eee 100644 --- a/fake-tcp/src/lib.rs +++ b/fake-tcp/src/lib.rs @@ -57,7 +57,6 @@ pub enum State { SynSent, SynReceived, Established, - Closed, } pub struct Socket { @@ -116,12 +115,10 @@ impl Socket { tokio::select! { res = self.tun.send(&buf) => { - res.unwrap(); - Some(()) + res.ok().and(Some(())) }, } } - State::Closed => None, _ => unreachable!(), } } @@ -148,7 +145,6 @@ impl Socket { Some(payload.len()) }) } - State::Closed => None, _ => unreachable!(), } } @@ -252,8 +248,6 @@ impl Socket { impl Drop for Socket { fn drop(&mut self) { - self.state = State::Closed; - let tuple = AddrTuple::new(self.local_addr, self.remote_addr); // dissociates ourself from the dispatch map assert!(self.shared.tuples.write().unwrap().remove(&tuple).is_some());