From f1c1afed961e8f5232d05b93ee27aa9158dbfc47 Mon Sep 17 00:00:00 2001 From: Evan Pratten Date: Wed, 2 Aug 2023 19:50:30 -0400 Subject: [PATCH] appease clippy --- libs/interproto/src/lib.rs | 1 + libs/rfc6052/src/embed.rs | 10 +++++----- libs/rfc6052/src/extract.rs | 3 +++ libs/rfc6052/src/lib.rs | 1 + 4 files changed, 10 insertions(+), 5 deletions(-) diff --git a/libs/interproto/src/lib.rs b/libs/interproto/src/lib.rs index 1486821..f5e4aa0 100644 --- a/libs/interproto/src/lib.rs +++ b/libs/interproto/src/lib.rs @@ -3,6 +3,7 @@ #![allow(clippy::module_name_repetitions)] #![allow(clippy::missing_errors_doc)] #![allow(clippy::missing_panics_doc)] +#![allow(clippy::doc_markdown)] pub mod protocols; pub mod error; \ No newline at end of file diff --git a/libs/rfc6052/src/embed.rs b/libs/rfc6052/src/embed.rs index 483a733..598825a 100644 --- a/libs/rfc6052/src/embed.rs +++ b/libs/rfc6052/src/embed.rs @@ -19,10 +19,10 @@ pub fn embed_ipv4_addr(ipv4_addr: Ipv4Addr, ipv6_prefix: Ipv6Net) -> Result Ipv6Addr { +#[must_use] +#[allow(clippy::cast_lossless)] +#[allow(clippy::cast_possible_truncation)] +pub unsafe fn embed_ipv4_addr_unchecked(ipv4_addr: Ipv4Addr, ipv6_prefix: Ipv6Net) -> Ipv6Addr { // Convert to integer types let ipv4_addr = u32::from(ipv4_addr); let prefix_len = ipv6_prefix.prefix_len() as i16; @@ -33,7 +33,7 @@ pub unsafe fn embed_ipv4_addr_unchecked( // and shift them into place on each side of the boundary Ipv6Addr::from( ipv6_prefix - | (((ipv4_addr as u128 & (0xffff_ffffu128 << (32 + min(0, prefix_len - 64)))) as u128) + | ((ipv4_addr as u128 & (0xffff_ffffu128 << (32 + min(0, prefix_len - 64)))) << (128 - prefix_len - 32)) | (((ipv4_addr as u128) << max(0, 128 - prefix_len - 32 - 8)) & 0x00ff_ffff_ffff_ffff), ) diff --git a/libs/rfc6052/src/extract.rs b/libs/rfc6052/src/extract.rs index 3931820..3b86722 100644 --- a/libs/rfc6052/src/extract.rs +++ b/libs/rfc6052/src/extract.rs @@ -16,6 +16,9 @@ pub fn extract_ipv4_addr(ipv6_addr: Ipv6Addr, prefix_length: u8) -> Result Ipv4Addr { // Convert the IPv6 address to a number for easier manipulation let ipv6_addr = u128::from(ipv6_addr); diff --git a/libs/rfc6052/src/lib.rs b/libs/rfc6052/src/lib.rs index f6203b9..6477eb3 100644 --- a/libs/rfc6052/src/lib.rs +++ b/libs/rfc6052/src/lib.rs @@ -3,6 +3,7 @@ #![allow(clippy::module_name_repetitions)] #![allow(clippy::missing_errors_doc)] #![allow(clippy::missing_panics_doc)] +#![allow(clippy::missing_safety_doc)] pub mod error;