Skip to content

Commit 1bcbebf

Browse files
committed
replace allow with expect
1 parent b2fa591 commit 1bcbebf

File tree

6 files changed

+23
-27
lines changed

6 files changed

+23
-27
lines changed

src/channels.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use crate::{
2-
discovery_key,
2+
DiscoveryKey, Key, Message, discovery_key,
33
message::ChannelMessage,
44
schema::*,
55
util::{map_channel_err, pretty_hash},
6-
DiscoveryKey, Key, Message,
76
};
87
use async_channel::{Receiver, Sender, TrySendError};
98
use futures_lite::{ready, stream::Stream};
@@ -13,8 +12,8 @@ use std::{
1312
io::{Error, ErrorKind, Result},
1413
pin::Pin,
1514
sync::{
16-
atomic::{AtomicBool, Ordering},
1715
Arc,
16+
atomic::{AtomicBool, Ordering},
1817
},
1918
task::Poll,
2019
};
@@ -315,14 +314,15 @@ impl ChannelHandle {
315314
message: Message,
316315
) -> std::io::Result<()> {
317316
if let Some(inbound_tx) = self.inbound_tx.as_mut()
318-
&& let Err(err) = inbound_tx.try_send(message) {
319-
match err {
320-
TrySendError::Full(e) => {
321-
return Err(error(format!("Sending to channel failed: {e}").as_str()))
322-
}
323-
TrySendError::Closed(_) => {}
317+
&& let Err(err) = inbound_tx.try_send(message)
318+
{
319+
match err {
320+
TrySendError::Full(e) => {
321+
return Err(error(format!("Sending to channel failed: {e}").as_str()));
324322
}
323+
TrySendError::Closed(_) => {}
325324
}
325+
}
326326
Ok(())
327327
}
328328
}
@@ -480,7 +480,6 @@ impl ChannelMap {
480480
Ok(())
481481
}
482482

483-
#[instrument(skip_all)]
484483
fn alloc_local(&mut self) -> usize {
485484
let empty_id = self
486485
.local_id

src/crypto/handshake.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ pub struct HandshakeResult {
6464
}
6565

6666
impl HandshakeResult {
67-
#[instrument(skip_all)]
6867
pub(crate) fn capability(&self, key: &[u8]) -> Option<Vec<u8>> {
6968
Some(replicate_capability(
7069
self.is_initiator,
@@ -81,7 +80,6 @@ impl HandshakeResult {
8180
))
8281
}
8382

84-
#[instrument(skip_all)]
8583
pub(crate) fn verify_remote_capability(
8684
&self,
8785
capability: Option<Vec<u8>>,
@@ -114,8 +112,6 @@ pub struct Handshake {
114112
rx_buf: Vec<u8>,
115113
complete: bool,
116114
did_receive: bool,
117-
#[allow(dead_code)]
118-
pattern: HandshakePattern,
119115
}
120116

121117
impl Handshake {
@@ -138,7 +134,6 @@ impl Handshake {
138134
rx_buf: vec![0u8; 512],
139135
complete: false,
140136
did_receive: false,
141-
pattern: config.pattern,
142137
})
143138
}
144139

src/message.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use crate::schema::*;
22
use compact_encoding::{
3-
decode_usize, take_array, write_array, CompactEncoding, EncodingError, EncodingErrorKind,
4-
VecEncodable,
3+
CompactEncoding, EncodingError, EncodingErrorKind, VecEncodable, decode_usize, take_array,
4+
write_array,
55
};
66
use pretty_hash::fmt as pretty_fmt;
77
use std::{fmt, io};
@@ -116,7 +116,7 @@ fn vec_channel_messages_encoded_size(messages: &[ChannelMessage]) -> Result<usiz
116116

117117
/// A protocol message.
118118
#[derive(Debug, Clone, PartialEq)]
119-
#[allow(missing_docs)]
119+
#[expect(missing_docs)]
120120
pub enum Message {
121121
Open(Open),
122122
Close(Close),

src/sstream/sm2.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ impl SansIoMachine {
201201
Ok(made_progress.then_some(()))
202202
}
203203

204-
#[allow(unused, reason = "vectorized version of 'get_next_sendable_message'")]
204+
// NB: vectorized version of 'get_next_sendable_message'. currently just used in tests
205+
#[cfg(test)]
205206
fn get_sendable_messages(&mut self) -> Result<Vec<Vec<u8>>, IoError> {
206207
self.poll_all_enc_dec()?;
207208
Ok(self.encrypted_tx.drain(..).collect())
@@ -212,7 +213,8 @@ impl SansIoMachine {
212213
Ok(self.encrypted_tx.pop_front())
213214
}
214215

215-
#[allow(unused, reason = "vectorized version of 'receive_next'")]
216+
#[cfg(test)]
217+
// NB: vectorized version of 'receive_next'. currently just used in tests
216218
fn receive_next_messages(&mut self, encrypted_messages: Vec<Vec<u8>>) {
217219
self.encrypted_rx
218220
.extend(encrypted_messages.into_iter().map(Ok));
@@ -222,7 +224,7 @@ impl SansIoMachine {
222224
self.encrypted_rx.push_back(Ok(encrypted_msg));
223225
}
224226

225-
#[allow(unused, reason = "add a new plaintext message to send")]
227+
#[expect(unused, reason = "add a new plaintext message to send")]
226228
fn queue_msg(&mut self, msg: Vec<u8>) {
227229
self.plain_tx.push_back(msg);
228230
}
@@ -641,7 +643,7 @@ mod tests {
641643
}
642644
}
643645

644-
#[allow(clippy::type_complexity)]
646+
#[expect(clippy::type_complexity)]
645647
fn create_mock_io_pair() -> (
646648
MockIo<impl Stream<Item = Result<Vec<u8>, std::io::Error>>>,
647649
mpsc::UnboundedSender<Result<Vec<u8>, std::io::Error>>,

src/test_utils.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![allow(dead_code)]
1+
#![expect(dead_code)]
22
use std::{
33
io::{self},
44
pin::Pin,
@@ -170,7 +170,7 @@ fn result_channel() -> (Sender<Vec<u8>>, impl Stream<Item = io::Result<Vec<u8>>>
170170
(tx, rx.map(Ok))
171171
}
172172

173-
#[allow(clippy::type_complexity)]
173+
#[expect(clippy::type_complexity)]
174174
pub(crate) fn create_result_connected() -> (
175175
Moo<impl Stream<Item = io::Result<Vec<u8>>>, impl Sink<Vec<u8>>>,
176176
Moo<impl Stream<Item = io::Result<Vec<u8>>>, impl Sink<Vec<u8>>>,
@@ -182,10 +182,9 @@ pub(crate) fn create_result_connected() -> (
182182

183183
#[cfg(test)]
184184
mod test {
185-
#![allow(unused_imports)] // test's within tests confused clippy
186-
use futures::{SinkExt, StreamExt};
187185
#[tokio::test]
188186
async fn way_one() {
187+
use futures::{SinkExt, StreamExt};
189188
let mut a = super::Io::default();
190189
let _ = a.send(b"hello".into()).await;
191190
let Some(res) = a.next().await else { panic!() };
@@ -194,6 +193,7 @@ mod test {
194193

195194
#[tokio::test]
196195
async fn split() {
196+
use futures::{SinkExt, StreamExt};
197197
let (mut left, mut right) = (super::TwoWay::default()).split_sides();
198198
left.send(b"hello".to_vec()).await.unwrap();
199199
let Some(res) = right.next().await else {

tests/_util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use async_std::net::TcpStream;
22
use futures_lite::{
3-
io::{AsyncRead, AsyncWrite},
43
StreamExt,
4+
io::{AsyncRead, AsyncWrite},
55
};
66
use hypercore_protocol::{Channel, DiscoveryKey, Duplex, Event, Protocol, ProtocolBuilder};
77
use instant::Duration;

0 commit comments

Comments
 (0)