Skip to content

Commit

Permalink
fix: clippy errors on nightly
Browse files Browse the repository at this point in the history
nightly-x86_64-unknown-linux-gnu (default)
rustc 1.86.0-nightly (ae5de6c75 2025-01-29)
  • Loading branch information
josecelano committed Jan 30, 2025
1 parent 8bb376d commit ebdab9a
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 32 deletions.
5 changes: 1 addition & 4 deletions contrib/bencode/src/mutable/bencode_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,7 @@ impl<'a> BRefAccess for BencodeMut<'a> {
fn str(&self) -> Option<&str> {
let bytes = self.bytes()?;

match str::from_utf8(bytes) {
Ok(n) => Some(n),
Err(_) => None,
}
str::from_utf8(bytes).ok()
}

fn int(&self) -> Option<i64> {
Expand Down
5 changes: 1 addition & 4 deletions contrib/bencode/src/reference/bencode_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,7 @@ impl<'a> BRefAccessExt<'a> for BencodeRef<'a> {
fn str_ext(&self) -> Option<&'a str> {
let bytes = self.bytes_ext()?;

match str::from_utf8(bytes) {
Ok(n) => Some(n),
Err(_) => None,
}
str::from_utf8(bytes).ok()
}

fn bytes_ext(&self) -> Option<&'a [u8]> {
Expand Down
3 changes: 2 additions & 1 deletion contrib/bencode/src/reference/decode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ fn decode_dict(
})
}
_ => (),
};
}

curr_pos = next_pos;

let (value, next_pos) = decode(bytes, curr_pos, opts, depth + 1)?;
Expand Down
2 changes: 1 addition & 1 deletion packages/test-helpers/src/configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ pub fn ephemeral_ipv6() -> Configuration {

if let Some(ref mut http_api) = cfg.http_api {
http_api.bind_address.clone_from(&ipv6);
};
}

if let Some(ref mut http_trackers) = cfg.http_trackers {
http_trackers[0].bind_address.clone_from(&ipv6);
Expand Down
2 changes: 1 addition & 1 deletion packages/torrent-repository/tests/common/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ impl Repo {
Repo::DashMapMutexStd(repo) => {
repo.torrents.insert(*info_hash, torrent.into());
}
};
}
self.get(info_hash).await
}
}
2 changes: 1 addition & 1 deletion packages/tracker-api-client/src/v1/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl Client {

if let Some(token) = &self.connection_info.api_token {
query.add_param(QueryParam::new("token", token));
};
}

self.get_request_with_query(path, query, headers).await
}
Expand Down
2 changes: 1 addition & 1 deletion packages/tracker-client/src/udp/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ pub async fn check(remote_addr: &SocketAddr) -> Result<String, String> {
match client.send(connect_request.into()).await {
Ok(_) => (),
Err(e) => tracing::debug!("Error: {e:?}."),
};
}

let process = move |response| {
if matches!(response, Response::Connect(_connect_response)) {
Expand Down
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ pub async fn start(config: &Configuration, app_container: &Arc<AppContainer>) ->
http_tracker::start_job(http_tracker_container, registar.give_form(), servers::http::Version::V1).await
{
jobs.push(job);
};
}
}
} else {
tracing::info!("No HTTP blocks in configuration");
Expand All @@ -111,7 +111,7 @@ pub async fn start(config: &Configuration, app_container: &Arc<AppContainer>) ->

if let Some(job) = tracker_apis::start_job(http_api_container, registar.give_form(), servers::apis::Version::V1).await {
jobs.push(job);
};
}
} else {
tracing::info!("No API block in configuration");
}
Expand Down
2 changes: 1 addition & 1 deletion src/console/ci/e2e/logs_parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl RunningServices {

if !line.contains(INFO_THRESHOLD) {
continue;
};
}

if line.contains(UDP_TRACKER_LOG_TARGET) {
if let Some(captures) = udp_re.captures(&clean_line) {
Expand Down
18 changes: 9 additions & 9 deletions src/servers/apis/v1/context/auth_key/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ use crate::servers::apis::v1::responses::{invalid_auth_key_param_response, ok_re
/// It returns these types of responses:
///
/// - `200` with a json [`AuthKey`]
/// resource. If the key was generated successfully.
/// resource. If the key was generated successfully.
/// - `400` with an error if the key couldn't been added because of an invalid
/// request.
/// request.
/// - `500` with serialized error in debug format. If the key couldn't be
/// generated.
/// generated.
///
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#generate-a-new-authentication-key)
/// for more information about this endpoint.
Expand Down Expand Up @@ -57,9 +57,9 @@ pub async fn add_auth_key_handler(
/// It returns two types of responses:
///
/// - `200` with an json [`AuthKey`]
/// resource. If the key was generated successfully.
/// resource. If the key was generated successfully.
/// - `500` with serialized error in debug format. If the key couldn't be
/// generated.
/// generated.
///
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#generate-a-new-authentication-key)
/// for more information about this endpoint.
Expand Down Expand Up @@ -99,9 +99,9 @@ pub struct KeyParam(String);
/// It returns two types of responses:
///
/// - `200` with an json [`ActionStatus::Ok`](crate::servers::apis::v1::responses::ActionStatus::Ok)
/// response. If the key was deleted successfully.
/// response. If the key was deleted successfully.
/// - `500` with serialized error in debug format. If the key couldn't be
/// deleted.
/// deleted.
///
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#delete-an-authentication-key)
/// for more information about this endpoint.
Expand All @@ -124,9 +124,9 @@ pub async fn delete_auth_key_handler(
/// It returns two types of responses:
///
/// - `200` with an json [`ActionStatus::Ok`](crate::servers::apis::v1::responses::ActionStatus::Ok)
/// response. If the keys were successfully reloaded.
/// response. If the keys were successfully reloaded.
/// - `500` with serialized error in debug format. If the they couldn't be
/// reloaded.
/// reloaded.
///
/// Refer to the [API endpoint documentation](crate::servers::apis::v1::context::auth_key#reload-authentication-keys)
/// for more information about this endpoint.
Expand Down
2 changes: 1 addition & 1 deletion src/servers/udp/server/launcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ impl Launcher {
stats_event_sender
.send_event(statistics::event::Event::UdpRequestAborted)
.await;
};
}
}
} else {
tokio::task::yield_now().await;
Expand Down
12 changes: 6 additions & 6 deletions tests/servers/udp/contract.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn send_connection_request(transaction_id: TransactionId, client: &UdpTrac
match client.send(connect_request.into()).await {
Ok(_) => (),
Err(err) => panic!("{err}"),
};
}

let response = match client.receive().await {
Ok(response) => response,
Expand All @@ -52,7 +52,7 @@ async fn should_return_a_bad_request_response_when_the_client_sends_an_empty_req
match client.client.send(&empty_udp_request()).await {
Ok(_) => (),
Err(err) => panic!("{err}"),
};
}

let response = match client.client.receive().await {
Ok(response) => response,
Expand Down Expand Up @@ -94,7 +94,7 @@ mod receiving_a_connection_request {
match client.send(connect_request.into()).await {
Ok(_) => (),
Err(err) => panic!("{err}"),
};
}

let response = match client.receive().await {
Ok(response) => response,
Expand Down Expand Up @@ -146,7 +146,7 @@ mod receiving_an_announce_request {
match client.send(announce_request.into()).await {
Ok(_) => (),
Err(err) => panic!("{err}"),
};
}

match client.receive().await {
Ok(response) => response,
Expand Down Expand Up @@ -276,7 +276,7 @@ mod receiving_an_announce_request {
match client.send(announce_request.into()).await {
Ok(_) => (),
Err(err) => panic!("{err}"),
};
}

assert!(client.receive().await.is_err());

Expand Down Expand Up @@ -333,7 +333,7 @@ mod receiving_an_scrape_request {
match client.send(scrape_request.into()).await {
Ok(_) => (),
Err(err) => panic!("{err}"),
};
}

let response = match client.receive().await {
Ok(response) => response,
Expand Down

0 comments on commit ebdab9a

Please sign in to comment.