Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Enable the unused_result_ok lint #2333

Merged
merged 8 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ pedantic = { level = "warn", priority = -1 }
if_then_some_else_none = "warn"
get_unwrap = "warn"
pathbuf_init_then_push = "warn"
unused_result_ok = "warn"

# Optimize build dependencies, because bindgen and proc macros / style
# compilation take more to run than to build otherwise.
Expand Down
17 changes: 4 additions & 13 deletions neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -738,7 +738,7 @@ impl Http3Connection {
return Ok(ReceiveOutput::NoOutput);
}
// set incoming WebTransport streams to be fair (share bandwidth)
conn.stream_fairness(stream_id, true).ok();
conn.stream_fairness(stream_id, true);
qinfo!(
[self],
"A new WebTransport stream {} for session {}.",
Expand Down Expand Up @@ -1024,17 +1024,8 @@ impl Http3Connection {
/// Set the stream Fairness. Fair streams will share bandwidth with other
/// streams of the same sendOrder group (or the unordered group). Unfair streams
/// will give bandwidth preferentially to the lowest streamId with data to send.
///
/// # Errors
///
/// Returns `InvalidStreamId` if the stream id doesn't exist
pub fn stream_set_fairness(
conn: &mut Connection,
stream_id: StreamId,
fairness: bool,
) -> Res<()> {
conn.stream_fairness(stream_id, fairness)
.map_err(|_| Error::InvalidStreamId)
pub fn stream_set_fairness(conn: &mut Connection, stream_id: StreamId, fairness: bool) {
conn.stream_fairness(stream_id, fairness);
}

pub fn cancel_fetch(
Expand Down Expand Up @@ -1284,7 +1275,7 @@ impl Http3Connection {
.map_err(|e| Error::map_stream_create_errors(&e))?;
// Set outgoing WebTransport streams to be fair (share bandwidth)
// This really can't fail, panics if it does
conn.stream_fairness(stream_id, true).unwrap();
conn.stream_fairness(stream_id, true);

self.webtransport_create_stream_internal(
wt,
Expand Down
12 changes: 2 additions & 10 deletions neqo-http3/src/connection_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -808,16 +808,8 @@ impl Http3Client {
}

/// Sets the `Fairness` for a given stream
///
/// # Errors
///
/// It may return `InvalidStreamId` if a stream does not exist anymore.
///
/// # Panics
///
/// This cannot panic.
pub fn webtransport_set_fairness(&mut self, stream_id: StreamId, fairness: bool) -> Res<()> {
Http3Connection::stream_set_fairness(&mut self.conn, stream_id, fairness)
pub fn webtransport_set_fairness(&mut self, stream_id: StreamId, fairness: bool) {
Http3Connection::stream_set_fairness(&mut self.conn, stream_id, fairness);
}

/// Returns the current `SendStreamStats` of a `WebTransportSendStream`.
Expand Down
9 changes: 3 additions & 6 deletions neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1559,7 +1559,7 @@ impl Connection {
);
path.borrow_mut().add_received(d.len());
let res = self.input_path(&path, d, received);
self.capture_error(Some(path), now, 0, res).ok();
_ = self.capture_error(Some(path), now, 0, res);
}

fn input_path(
Expand Down Expand Up @@ -3331,11 +3331,8 @@ impl Connection {
}

/// Set the Fairness of a stream
///
/// # Errors
/// When the stream does not exist.
pub fn stream_fairness(&mut self, stream_id: StreamId, fairness: bool) -> Res<()> {
self.streams.set_fairness(stream_id, fairness)
pub fn stream_fairness(&mut self, stream_id: StreamId, fairness: bool) {
self.streams.set_fairness(stream_id, fairness);
}

/// # Errors
Expand Down
4 changes: 2 additions & 2 deletions neqo-transport/src/connection/tests/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ fn sendorder_test(order_of_sendorder: &[Option<SendOrder>]) {
streams.push(id);
ordered.push((id, *sendorder));
// must be set before sendorder
client.streams.set_fairness(id, true).ok();
client.streams.set_sendorder(id, *sendorder).ok();
client.streams.set_fairness(id, true);
client.streams.set_sendorder(id, *sendorder).unwrap();
}
// Write some data to all the streams
for stream_id in streams {
Expand Down
14 changes: 6 additions & 8 deletions neqo-transport/src/send_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1565,10 +1565,8 @@ impl SendStreams {
}
}

#[allow(clippy::missing_panics_doc)]
#[allow(clippy::missing_errors_doc)]
pub fn set_sendorder(&mut self, stream_id: StreamId, sendorder: Option<SendOrder>) -> Res<()> {
self.set_fairness(stream_id, true)?;
self.set_fairness(stream_id, true);
if let Some(stream) = self.map.get_mut(&stream_id) {
// don't grab stream here; causes borrow errors
let old_sendorder = stream.sendorder();
Expand All @@ -1591,10 +1589,11 @@ impl SendStreams {
}
}

#[allow(clippy::missing_panics_doc)]
#[allow(clippy::missing_errors_doc)]
pub fn set_fairness(&mut self, stream_id: StreamId, make_fair: bool) -> Res<()> {
let stream: &mut SendStream = self.map.get_mut(&stream_id).ok_or(Error::InvalidStreamId)?;
pub fn set_fairness(&mut self, stream_id: StreamId, make_fair: bool) {
let Some(stream) = self.map.get_mut(&stream_id) else {
// We can get called with an invalid stream ID, and that is OK.
return;
};
larseggert marked this conversation as resolved.
Show resolved Hide resolved
let was_fair = stream.fair;
stream.set_fairness(make_fair);
if !was_fair && make_fair {
Expand Down Expand Up @@ -1626,7 +1625,6 @@ impl SendStreams {
};
group.remove(stream_id);
}
Ok(())
}

pub fn acked(&mut self, token: &SendStreamRecoveryToken) {
Expand Down
6 changes: 2 additions & 4 deletions neqo-transport/src/streams.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,8 @@ impl Streams {
self.send.set_sendorder(stream_id, sendorder)
}

/// # Errors
/// When the stream does not exist.
pub fn set_fairness(&mut self, stream_id: StreamId, fairness: bool) -> Res<()> {
self.send.set_fairness(stream_id, fairness)
pub fn set_fairness(&mut self, stream_id: StreamId, fairness: bool) {
self.send.set_fairness(stream_id, fairness);
}

/// # Errors
Expand Down
4 changes: 2 additions & 2 deletions neqo-transport/tests/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,8 +283,8 @@ fn handshake_mlkem768x25519() {

client
.set_groups(&[neqo_crypto::TLS_GRP_KEM_MLKEM768X25519])
.ok();
client.send_additional_key_shares(0).ok();
.unwrap();
client.send_additional_key_shares(0).unwrap();

test_fixture::handshake(&mut client, &mut server);
assert_eq!(*client.state(), State::Confirmed);
Expand Down
Loading