528: Fix clippy because of MSV change r=Dirbaio a=thibautvdv

This fixes the clippy warnings from the MSV changes in #526. Should have added this to #526.

Co-authored-by: Thibaut Vandervelden <thvdveld@vub.be>
Co-authored-by: Dario Nieuwenhuis <dirbaio@dirbaio.net>
This commit is contained in:
bors[bot] 2021-09-16 23:08:17 +00:00 committed by GitHub
commit 4638c8d0f3
8 changed files with 71 additions and 12 deletions

48
.github/bors.toml vendored Normal file
View File

@ -0,0 +1,48 @@
status = [
"fuzz",
"test (stable, default)",
"clippy",
"fmt",
"test (stable, std proto-ipv4)",
"test (stable, std medium-ethernet phy-raw_socket proto-ipv6 socket-udp)",
"test (stable, std medium-ethernet phy-tuntap_interface proto-ipv6 socket-udp)",
"test (stable, std medium-ethernet proto-ipv4 proto-igmp socket-raw)",
"test (stable, std medium-ethernet proto-ipv4 socket-udp socket-tcp)",
"test (stable, std medium-ethernet proto-ipv4 proto-dhcpv4 socket-udp)",
"test (stable, std medium-ethernet proto-ipv6 socket-udp)",
"test (stable, std medium-ethernet proto-ipv6 socket-tcp)",
"test (stable, std medium-ethernet proto-ipv4 socket-icmp socket-tcp)",
"test (stable, std medium-ethernet proto-ipv6 socket-icmp socket-tcp)",
"test (stable, std medium-ethernet proto-ipv4 proto-ipv6 socket-raw socket-udp socket-tcp socket-i...",
"test (1.53.0, default)",
"test (1.53.0, std proto-ipv4)",
"test (1.53.0, std medium-ethernet phy-raw_socket proto-ipv6 socket-udp)",
"test (1.53.0, std medium-ethernet phy-tuntap_interface proto-ipv6 socket-udp)",
"test (1.53.0, std medium-ethernet proto-ipv4 proto-igmp socket-raw)",
"test (1.53.0, std medium-ethernet proto-ipv4 socket-udp socket-tcp)",
"test (1.53.0, std medium-ethernet proto-ipv4 proto-dhcpv4 socket-udp)",
"test (1.53.0, std medium-ethernet proto-ipv6 socket-udp)",
"test (1.53.0, std medium-ethernet proto-ipv6 socket-tcp)",
"test (1.53.0, std medium-ethernet proto-ipv4 socket-icmp socket-tcp)",
"test (1.53.0, std medium-ethernet proto-ipv6 socket-icmp socket-tcp)",
"test (1.53.0, std medium-ethernet proto-ipv4 proto-ipv6 socket-raw socket-udp socket-tcp socket-i...",
"test (nightly, default)",
"test (nightly, std proto-ipv4)",
"test (nightly, std medium-ethernet phy-raw_socket proto-ipv6 socket-udp)",
"test (nightly, std medium-ethernet phy-tuntap_interface proto-ipv6 socket-udp)",
"test (nightly, std medium-ethernet proto-ipv4 proto-igmp socket-raw)",
"test (nightly, std medium-ethernet proto-ipv4 socket-udp socket-tcp)",
"test (nightly, std medium-ethernet proto-ipv4 proto-dhcpv4 socket-udp)",
"test (nightly, std medium-ethernet proto-ipv6 socket-udp)",
"test (nightly, std medium-ethernet proto-ipv6 socket-tcp)",
"test (nightly, std medium-ethernet proto-ipv4 socket-icmp socket-tcp)",
"test (nightly, std medium-ethernet proto-ipv6 socket-icmp socket-tcp)",
"test (nightly, std medium-ethernet proto-ipv4 proto-ipv6 socket-raw socket-udp socket-tcp socket-...",
"test (nightly, alloc medium-ethernet proto-ipv4 proto-ipv6 socket-raw socket-udp socket-tcp socke...",
"check (stable, medium-ip medium-ethernet proto-ipv6 proto-ipv6 proto-igmp proto-dhcpv4 socket-raw...",
"check (stable, defmt defmt-trace medium-ip medium-ethernet proto-ipv6 proto-ipv6 proto-igmp proto...",
"check (1.53.0, medium-ip medium-ethernet proto-ipv6 proto-ipv6 proto-igmp proto-dhcpv4 socket-raw...",
"check (1.53.0, defmt defmt-trace medium-ip medium-ethernet proto-ipv6 proto-ipv6 proto-igmp proto...",
"check (nightly, medium-ip medium-ethernet proto-ipv6 proto-ipv6 proto-igmp proto-dhcpv4 socket-ra...",
"check (nightly, defmt defmt-trace medium-ip medium-ethernet proto-ipv6 proto-ipv6 proto-igmp prot...",
]

View File

@ -854,7 +854,7 @@ where
Context {
now,
caps: self.device.capabilities(),
#[cfg(feature = "medium-ethernet")]
#[cfg(all(feature = "medium-ethernet", feature = "socket-dhcpv4"))]
ethernet_address: self.inner.ethernet_addr,
}
}

View File

@ -63,6 +63,7 @@ impl Answer {
pub struct Cache<'a> {
storage: ManagedMap<'a, IpAddress, Neighbor>,
silent_until: Instant,
#[cfg(any(feature = "std", feature = "alloc"))]
gc_threshold: usize,
}
@ -74,6 +75,7 @@ impl<'a> Cache<'a> {
pub(crate) const ENTRY_LIFETIME: Duration = Duration { millis: 60_000 };
/// Default number of entries in the cache before GC kicks in
#[cfg(any(feature = "std", feature = "alloc"))]
pub(crate) const GC_THRESHOLD: usize = 1024;
/// Create a cache. The backing storage is cleared upon creation.
@ -84,9 +86,18 @@ impl<'a> Cache<'a> {
where
T: Into<ManagedMap<'a, IpAddress, Neighbor>>,
{
Cache::new_with_limit(storage, Cache::GC_THRESHOLD)
let mut storage = storage.into();
storage.clear();
Cache {
storage,
#[cfg(any(feature = "std", feature = "alloc"))]
gc_threshold: Self::GC_THRESHOLD,
silent_until: Instant::from_millis(0),
}
}
#[cfg(any(feature = "std", feature = "alloc"))]
pub fn new_with_limit<T>(storage: T, gc_threshold: usize) -> Cache<'a>
where
T: Into<ManagedMap<'a, IpAddress, Neighbor>>,

View File

@ -23,7 +23,6 @@ const MTU: usize = 1536;
struct Config {
corrupt_pct: u8,
drop_pct: u8,
reorder_pct: u8,
max_size: usize,
max_tx_rate: u64,
max_rx_rate: u64,

View File

@ -281,7 +281,7 @@ impl Dhcpv4Socket {
}
};
let prefix_len = match IpAddress::Ipv4(subnet_mask).to_prefix_len() {
let prefix_len = match IpAddress::Ipv4(subnet_mask).prefix_len() {
Some(prefix_len) => prefix_len,
None => {
net_debug!("DHCP ignoring ACK because subnet_mask is not a valid mask");

View File

@ -187,7 +187,7 @@ from_socket!(Dhcpv4Socket, Dhcpv4);
#[derive(Clone, Debug)]
pub(crate) struct Context {
pub now: Instant,
#[cfg(feature = "medium-ethernet")]
#[cfg(all(feature = "medium-ethernet", feature = "socket-dhcpv4"))]
pub ethernet_address: Option<crate::wire::EthernetAddress>,
pub caps: DeviceCapabilities,
}
@ -215,6 +215,7 @@ impl Context {
#[cfg(not(feature = "medium-ethernet"))]
max_transmission_unit: 1500,
},
#[cfg(all(feature = "medium-ethernet", feature = "socket-dhcpv4"))]
ethernet_address: None,
now: Instant { millis: 0 },
};

View File

@ -732,7 +732,7 @@ impl<'a> TcpSocket<'a> {
// This lets us lower IpRepr later to determine IP header size and calculate MSS,
// but without committing to a specific address right away.
let local_addr = match local_endpoint.addr {
IpAddress::Unspecified => remote_endpoint.addr.to_unspecified(),
IpAddress::Unspecified => remote_endpoint.addr.as_unspecified(),
ip => ip,
};
let local_endpoint = IpEndpoint {

View File

@ -167,7 +167,7 @@ impl Address {
}
/// Return an unspecified address that has the same IP version as `self`.
pub fn to_unspecified(&self) -> Address {
pub fn as_unspecified(&self) -> Address {
match *self {
Address::Unspecified => Address::Unspecified,
#[cfg(feature = "proto-ipv4")]
@ -179,7 +179,7 @@ impl Address {
/// If `self` is a CIDR-compatible subnet mask, return `Some(prefix_len)`,
/// where `prefix_len` is the number of leading zeroes. Return `None` otherwise.
pub fn to_prefix_len(&self) -> Option<u8> {
pub fn prefix_len(&self) -> Option<u8> {
let mut ones = true;
let mut prefix_len = 0;
for byte in self.as_bytes() {
@ -1216,7 +1216,7 @@ pub(crate) mod test {
#[cfg(feature = "proto-ipv4")]
fn to_prefix_len_ipv4() {
fn test_eq<A: Into<Address>>(prefix_len: u8, mask: A) {
assert_eq!(Some(prefix_len), mask.into().to_prefix_len());
assert_eq!(Some(prefix_len), mask.into().prefix_len());
}
test_eq(0, Ipv4Address::new(0, 0, 0, 0));
@ -1258,7 +1258,7 @@ pub(crate) mod test {
fn to_prefix_len_ipv4_error() {
assert_eq!(
None,
IpAddress::from(Ipv4Address::new(255, 255, 255, 1)).to_prefix_len()
IpAddress::from(Ipv4Address::new(255, 255, 255, 1)).prefix_len()
);
}
@ -1266,7 +1266,7 @@ pub(crate) mod test {
#[cfg(feature = "proto-ipv6")]
fn to_prefix_len_ipv6() {
fn test_eq<A: Into<Address>>(prefix_len: u8, mask: A) {
assert_eq!(Some(prefix_len), mask.into().to_prefix_len());
assert_eq!(Some(prefix_len), mask.into().prefix_len());
}
test_eq(0, Ipv6Address::new(0, 0, 0, 0, 0, 0, 0, 0));
@ -1285,7 +1285,7 @@ pub(crate) mod test {
IpAddress::from(Ipv6Address::new(
0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0xffff, 0, 1
))
.to_prefix_len()
.prefix_len()
);
}
}