Skip to content

Commit

Permalink
Tune up lints for 1.80 Rust
Browse files Browse the repository at this point in the history
  • Loading branch information
tyranron committed Jul 26, 2024
1 parent 65d68a7 commit b3ee2a2
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/allocation/manager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ impl Manager {

/// Returns the [`Allocation`] matching the provided [`FiveTuple`], if any.
pub(crate) fn get_alloc(
&mut self,
&self,
five_tuple: &FiveTuple,
) -> Option<&Allocation> {
self.allocations.get(five_tuple).and_then(|a| a.is_alive().then_some(a))
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
clippy::read_zero_byte_vec,
clippy::redundant_clone,
clippy::redundant_type_annotations,
clippy::renamed_function_params,
clippy::ref_patterns,
clippy::rest_pat_in_fully_bound_structs,
clippy::same_name_method,
Expand Down Expand Up @@ -116,6 +117,7 @@
clippy::use_self,
clippy::useless_let_if_seq,
clippy::verbose_file_reads,
clippy::while_float,
clippy::wildcard_enum_match_arm,
explicit_outlives_requirements,
future_incompatible,
Expand Down
2 changes: 1 addition & 1 deletion src/relay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl Allocator {
/// # Errors
///
/// - With an [`Error::MaxRetriesExceeded`] if the requested port is `0` and
/// failed to find a free port in the specified [`max_retries`].
/// failed to find a free port in the specified [`max_retries`].
/// - With an [`Error::Transport`] if failed to bind to the specified port.
///
/// [`max_retries`]: Allocator::max_retries
Expand Down
8 changes: 4 additions & 4 deletions src/server/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ pub(crate) async fn handle(
async fn handle_data_packet(
data: ChannelData,
five_tuple: FiveTuple,
allocs: &mut Manager,
allocs: &Manager,
) -> Result<(), Error> {
if let Some(alloc) = allocs.get_alloc(&five_tuple) {
let channel = alloc.get_channel_addr(&data.num()).await;
Expand Down Expand Up @@ -616,7 +616,7 @@ async fn handle_refresh_request(
async fn handle_create_permission_request(
msg: Message<Attribute>,
conn: &Arc<dyn Transport + Send + Sync>,
allocs: &mut Manager,
allocs: &Manager,
five_tuple: FiveTuple,
uname: Username,
realm: Realm,
Expand Down Expand Up @@ -690,7 +690,7 @@ async fn handle_create_permission_request(
/// [1]: https://tools.ietf.org/html/rfc5766#section-10.2
async fn handle_send_indication(
msg: Message<Attribute>,
allocs: &mut Manager,
allocs: &Manager,
five_tuple: FiveTuple,
) -> Result<(), Error> {
log::trace!("Received `SendIndication` from {}", five_tuple.src_addr);
Expand Down Expand Up @@ -724,7 +724,7 @@ async fn handle_send_indication(
async fn handle_channel_bind_request(
msg: Message<Attribute>,
conn: &Arc<dyn Transport + Send + Sync>,
allocs: &mut Manager,
allocs: &Manager,
five_tuple: FiveTuple,
channel_bind_lifetime: Duration,
uname: Username,
Expand Down
10 changes: 5 additions & 5 deletions src/transport/tcp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,22 +299,22 @@ impl Decoder for Codec {

fn decode(
&mut self,
buf: &mut BytesMut,
src: &mut BytesMut,
) -> Result<Option<Self::Item>, Self::Error> {
// PANIC: Indexing is OK below, since we guard it with `if` condition.
#![allow(clippy::missing_asserts_for_indexing)] // false positive

if self.current.is_none() && buf.len() >= 4 {
if self.current.is_none() && src.len() >= 4 {
self.current = Some(RequestKind::detect_kind([
buf[0], buf[1], buf[2], buf[3],
src[0], src[1], src[2], src[3],
]));
}

if let Some(current) = self.current {
if buf.len() >= current.length() {
if src.len() >= current.length() {
_ = self.current.take();

let raw = buf.split_to(current.length());
let raw = src.split_to(current.length());
let msg = match current {
RequestKind::Message(_) => {
let msg = self
Expand Down

0 comments on commit b3ee2a2

Please sign in to comment.