Skip to content

Commit

Permalink
chore: Enable the unused_result_ok lint (#2333)
Browse files Browse the repository at this point in the history
* chore: Enable the `unused_result_ok` lint

This also exposed an unneeded `Result` being returned from `stream_fairness`,
which this PR also removes.

* Restore error handling around `stream_fairness`

* Fix

* Remove old comment

---------

Signed-off-by: Lars Eggert <[email protected]>
  • Loading branch information
larseggert authored Jan 10, 2025
1 parent 648863b commit e664280
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ renamed_function_params = "warn"
semicolon_inside_block = "warn"
try_err = "warn"
unneeded_field_pattern = "warn"
unused_result_ok = "warn"
unused_trait_names = "warn"

# Optimize build dependencies, because bindgen and proc macros / style
Expand Down
11 changes: 7 additions & 4 deletions neqo-http3/src/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -737,8 +737,12 @@ impl Http3Connection {
conn.stream_stop_sending(stream_id, Error::HttpStreamCreation.code())?;
return Ok(ReceiveOutput::NoOutput);
}
// set incoming WebTransport streams to be fair (share bandwidth)
conn.stream_fairness(stream_id, true).ok();
// Set incoming WebTransport streams to be fair (share bandwidth).
// We may call this with an invalid stream ID, so ignore that error.
match conn.stream_fairness(stream_id, true) {
Ok(()) | Err(neqo_transport::Error::InvalidStreamId) => (),
Err(e) => return Err(Error::from(e)),
};
qinfo!(
[self],
"A new WebTransport stream {} for session {}.",
Expand Down Expand Up @@ -1283,8 +1287,7 @@ impl Http3Connection {
.stream_create(stream_type)
.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
4 changes: 0 additions & 4 deletions neqo-http3/src/connection_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -812,10 +812,6 @@ impl Http3Client {
/// # 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)
}
Expand Down
2 changes: 1 addition & 1 deletion neqo-transport/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1557,7 +1557,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
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).unwrap();
client.streams.set_sendorder(id, *sendorder).unwrap();
}
// Write some data to all the streams
for stream_id in streams {
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

0 comments on commit e664280

Please sign in to comment.