diff --git a/src/iface/ethernet.rs b/src/iface/ethernet.rs index 0a0d13e..1be01c7 100644 --- a/src/iface/ethernet.rs +++ b/src/iface/ethernet.rs @@ -1026,12 +1026,9 @@ impl<'b, 'c, 'e> InterfaceInner<'b, 'c, 'e> { !self.has_multicast_group(ipv4_repr.dst_addr) { // Ignore IP packets not directed at us, or broadcast, or any of the multicast groups. // If AnyIP is enabled, also check if the packet is routed locally. - if !self.any_ip { - return Ok(None); - } else if match self.routes.lookup(&IpAddress::Ipv4(ipv4_repr.dst_addr), timestamp) { - Some(router_addr) => !self.has_ip_addr(router_addr), - None => true, - } { + if !self.any_ip || + self.routes.lookup(&IpAddress::Ipv4(ipv4_repr.dst_addr), timestamp) + .map_or(true, |router_addr| !self.has_ip_addr(router_addr)) { return Ok(None); } } @@ -1188,10 +1185,9 @@ impl<'b, 'c, 'e> InterfaceInner<'b, 'c, 'e> { let ip_addr = ip_repr.src_addr.into(); match lladdr { Some(lladdr) if lladdr.is_unicast() && target_addr.is_unicast() => { - if flags.contains(NdiscNeighborFlags::OVERRIDE) { + if flags.contains(NdiscNeighborFlags::OVERRIDE) || + !self.neighbor_cache.lookup(&ip_addr, timestamp).found() { self.neighbor_cache.fill(ip_addr, lladdr, timestamp) - } else if !self.neighbor_cache.lookup(&ip_addr, timestamp).found() { - self.neighbor_cache.fill(ip_addr, lladdr, timestamp) } }, _ => (), diff --git a/src/lib.rs b/src/lib.rs index 7d18e89..7198b57 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -87,9 +87,6 @@ feature = "socket-tcp")))] compile_error!("at least one socket needs to be enabled"); */ -// FIXME(dlrobertson): clippy fails with this lint -#![allow(clippy::if_same_then_else)] -#![allow(clippy::manual_non_exhaustive)] #![allow(clippy::match_like_matches_macro)] #![allow(clippy::redundant_field_names)] #![allow(clippy::identity_op)] diff --git a/src/phy/mod.rs b/src/phy/mod.rs index adf0597..e21963b 100644 --- a/src/phy/mod.rs +++ b/src/phy/mod.rs @@ -158,6 +158,7 @@ impl Checksum { /// A description of checksum behavior for every supported protocol. #[derive(Debug, Clone, Default)] +#[non_exhaustive] pub struct ChecksumCapabilities { pub ipv4: Checksum, pub udp: Checksum, @@ -166,7 +167,6 @@ pub struct ChecksumCapabilities { pub icmpv4: Checksum, #[cfg(feature = "proto-ipv6")] pub icmpv6: Checksum, - dummy: (), } impl ChecksumCapabilities { @@ -181,7 +181,6 @@ impl ChecksumCapabilities { icmpv4: Checksum::None, #[cfg(feature = "proto-ipv6")] icmpv6: Checksum::None, - ..Self::default() } } } @@ -191,6 +190,7 @@ impl ChecksumCapabilities { /// Higher-level protocols may achieve higher throughput or lower latency if they consider /// the bandwidth or packet size limitations. #[derive(Debug, Clone, Default)] +#[non_exhaustive] pub struct DeviceCapabilities { /// Maximum transmission unit. /// @@ -214,10 +214,6 @@ pub struct DeviceCapabilities { /// If the network device is capable of verifying or computing checksums for some protocols, /// it can request that the stack not do so in software to improve performance. pub checksum: ChecksumCapabilities, - - /// Only present to prevent people from trying to initialize every field of DeviceLimits, - /// which would not let us add new fields in the future. - pub(crate) dummy: () } /// An interface for sending and receiving raw network frames. diff --git a/src/socket/tcp.rs b/src/socket/tcp.rs index 346cd4a..2edccb8 100644 --- a/src/socket/tcp.rs +++ b/src/socket/tcp.rs @@ -1905,6 +1905,7 @@ impl<'a> TcpSocket<'a> { Ok(()) } + #[allow(clippy::if_same_then_else)] pub(crate) fn poll_at(&self) -> PollAt { // The logic here mirrors the beginning of dispatch() closely. if !self.remote_endpoint.is_specified() { diff --git a/src/wire/arp.rs b/src/wire/arp.rs index e213b29..97fcf36 100644 --- a/src/wire/arp.rs +++ b/src/wire/arp.rs @@ -86,6 +86,7 @@ impl> Packet { /// /// [set_hardware_len]: #method.set_hardware_len /// [set_protocol_len]: #method.set_protocol_len + #[allow(clippy::if_same_then_else)] pub fn check_len(&self) -> Result<()> { let len = self.buffer.as_ref().len(); if len < field::OPER.end { diff --git a/src/wire/ipv4.rs b/src/wire/ipv4.rs index aab7e61..6d51d41 100644 --- a/src/wire/ipv4.rs +++ b/src/wire/ipv4.rs @@ -271,6 +271,7 @@ impl> Packet { /// /// [set_header_len]: #method.set_header_len /// [set_total_len]: #method.set_total_len + #[allow(clippy::if_same_then_else)] pub fn check_len(&self) -> Result<()> { let len = self.buffer.as_ref().len(); if len < field::DST_ADDR.end {