One big cleanup pass of clippy lints
Co-authored-by: Mikayla <mikayla@zed.dev>
This commit is contained in:
parent
e7540d2833
commit
8ba2f77148
138 changed files with 1328 additions and 1366 deletions
|
@ -50,6 +50,7 @@ impl Connection {
|
|||
killed,
|
||||
);
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
fn channel(
|
||||
killed: Arc<AtomicBool>,
|
||||
executor: Arc<gpui::executor::Background>,
|
||||
|
@ -76,9 +77,7 @@ impl Connection {
|
|||
|
||||
// Writes to a half-open TCP connection will error.
|
||||
if killed.load(SeqCst) {
|
||||
std::io::Result::Err(
|
||||
Error::new(ErrorKind::Other, "connection lost").into(),
|
||||
)?;
|
||||
std::io::Result::Err(Error::new(ErrorKind::Other, "connection lost"))?;
|
||||
}
|
||||
|
||||
Ok(msg)
|
||||
|
@ -87,7 +86,7 @@ impl Connection {
|
|||
});
|
||||
|
||||
let rx = rx.then({
|
||||
let killed = killed.clone();
|
||||
let killed = killed;
|
||||
let executor = Arc::downgrade(&executor);
|
||||
move |msg| {
|
||||
let killed = killed.clone();
|
||||
|
|
|
@ -94,6 +94,7 @@ pub struct ConnectionState {
|
|||
#[serde(skip)]
|
||||
outgoing_tx: mpsc::UnboundedSender<proto::Message>,
|
||||
next_message_id: Arc<AtomicU32>,
|
||||
#[allow(clippy::type_complexity)]
|
||||
#[serde(skip)]
|
||||
response_channels:
|
||||
Arc<Mutex<Option<HashMap<u32, oneshot::Sender<(proto::Envelope, oneshot::Sender<()>)>>>>>,
|
||||
|
@ -139,7 +140,7 @@ impl Peer {
|
|||
|
||||
let connection_id = ConnectionId(self.next_connection_id.fetch_add(1, SeqCst));
|
||||
let connection_state = ConnectionState {
|
||||
outgoing_tx: outgoing_tx.clone(),
|
||||
outgoing_tx,
|
||||
next_message_id: Default::default(),
|
||||
response_channels: Arc::new(Mutex::new(Some(Default::default()))),
|
||||
};
|
||||
|
|
|
@ -265,7 +265,9 @@ entity_messages!(
|
|||
|
||||
entity_messages!(channel_id, ChannelMessageSent);
|
||||
|
||||
const MAX_BUFFER_LEN: usize = 1 * 1024 * 1024;
|
||||
const KIB: usize = 1024;
|
||||
const MIB: usize = KIB * 1024;
|
||||
const MAX_BUFFER_LEN: usize = MIB;
|
||||
|
||||
/// A stream of protobuf messages.
|
||||
pub struct MessageStream<S> {
|
||||
|
@ -273,6 +275,7 @@ pub struct MessageStream<S> {
|
|||
encoding_buffer: Vec<u8>,
|
||||
}
|
||||
|
||||
#[allow(clippy::large_enum_variant)]
|
||||
#[derive(Debug)]
|
||||
pub enum Message {
|
||||
Envelope(Envelope),
|
||||
|
@ -309,7 +312,7 @@ where
|
|||
self.encoding_buffer.reserve(message.encoded_len());
|
||||
message
|
||||
.encode(&mut self.encoding_buffer)
|
||||
.map_err(|err| io::Error::from(err))?;
|
||||
.map_err(io::Error::from)?;
|
||||
let buffer =
|
||||
zstd::stream::encode_all(self.encoding_buffer.as_slice(), COMPRESSION_LEVEL)
|
||||
.unwrap();
|
||||
|
@ -360,10 +363,10 @@ where
|
|||
}
|
||||
}
|
||||
|
||||
impl Into<SystemTime> for Timestamp {
|
||||
fn into(self) -> SystemTime {
|
||||
impl From<Timestamp> for SystemTime {
|
||||
fn from(val: Timestamp) -> Self {
|
||||
UNIX_EPOCH
|
||||
.checked_add(Duration::new(self.seconds, self.nanos))
|
||||
.checked_add(Duration::new(val.seconds, val.nanos))
|
||||
.unwrap()
|
||||
}
|
||||
}
|
||||
|
@ -451,7 +454,7 @@ mod tests {
|
|||
.unwrap();
|
||||
assert!(sink.encoding_buffer.capacity() <= MAX_BUFFER_LEN);
|
||||
|
||||
let mut stream = MessageStream::new(rx.map(|msg| anyhow::Ok(msg)));
|
||||
let mut stream = MessageStream::new(rx.map(anyhow::Ok));
|
||||
stream.read().await.unwrap();
|
||||
assert!(stream.encoding_buffer.capacity() <= MAX_BUFFER_LEN);
|
||||
stream.read().await.unwrap();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue