Skip to content

Commit 4d0d4ae

Browse files
authored
Merge pull request #407 from crawford/clippy
Pin clippy check to 1.49.0
2 parents 318ad8a + 0b0f96e commit 4d0d4ae

File tree

13 files changed

+31
-28
lines changed

13 files changed

+31
-28
lines changed

.github/workflows/clippy.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ jobs:
1717
- uses: actions-rs/toolchain@v1
1818
with:
1919
profile: minimal
20-
toolchain: stable
20+
toolchain: 1.49.0
2121
override: true
2222
components: clippy
2323
- uses: actions-rs/clippy-check@v1
2424
with:
2525
token: ${{ secrets.GITHUB_TOKEN }}
26-
args: -- -D warnings
26+
args: --tests --examples -- -D warnings

examples/dhcp_client.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#![allow(clippy::option_map_unit_fn)]
12
mod utils;
23

34
use std::collections::BTreeMap;
@@ -57,22 +58,21 @@ fn main() {
5758
});
5859
config.map(|config| {
5960
println!("DHCP config: {:?}", config);
60-
match config.address {
61-
Some(cidr) => if cidr != prev_cidr {
61+
if let Some(cidr) = config.address {
62+
if cidr != prev_cidr {
6263
iface.update_ip_addrs(|addrs| {
63-
addrs.iter_mut().nth(0)
64+
addrs.iter_mut().next()
6465
.map(|addr| {
6566
*addr = IpCidr::Ipv4(cidr);
6667
});
6768
});
6869
prev_cidr = cidr;
6970
println!("Assigned a new IPv4 address: {}", cidr);
7071
}
71-
_ => {}
7272
}
7373

7474
config.router.map(|router| iface.routes_mut()
75-
.add_default_ipv4_route(router.into())
75+
.add_default_ipv4_route(router)
7676
.unwrap()
7777
);
7878
iface.routes_mut()

examples/loopback.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@ fn main() {
7676
utils::add_middleware_options(&mut opts, &mut free);
7777

7878
let mut matches = utils::parse_options(&opts, free);
79-
let device = utils::parse_middleware_options(&mut matches, device, /*loopback=*/true);
80-
81-
device
79+
utils::parse_middleware_options(&mut matches, device, /*loopback=*/true)
8280
};
8381

8482
let mut neighbor_cache_entries = [None; 8];

examples/multicast.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ fn main() {
8383
// For display purposes only - normally we wouldn't process incoming IGMP packets
8484
// in the application layer
8585
socket.recv()
86-
.and_then(|payload| Ipv4Packet::new_checked(payload))
86+
.and_then(Ipv4Packet::new_checked)
8787
.and_then(|ipv4_packet| IgmpPacket::new_checked(ipv4_packet.payload()))
8888
.and_then(|igmp_packet| IgmpRepr::parse(&igmp_packet))
8989
.map(|igmp_repr| println!("IGMP packet: {:?}", igmp_repr))

examples/ping.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ fn main() {
7474
let count = matches.opt_str("count").map(|s| usize::from_str(&s).unwrap()).unwrap_or(4);
7575
let interval = matches.opt_str("interval")
7676
.map(|s| Duration::from_secs(u64::from_str(&s).unwrap()))
77-
.unwrap_or(Duration::from_secs(1));
77+
.unwrap_or_else(|| Duration::from_secs(1));
7878
let timeout = Duration::from_secs(
7979
matches.opt_str("timeout").map(|s| u64::from_str(&s).unwrap()).unwrap_or(5)
8080
);

examples/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ fn main() {
109109

110110
if socket.can_send() {
111111
debug!("tcp:6969 send greeting");
112-
write!(socket, "hello\n").unwrap();
112+
writeln!(socket, "hello").unwrap();
113113
debug!("tcp:6969 close");
114114
socket.close();
115115
}

examples/utils.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ pub fn setup_logging_with_clock<F>(filter: &str, since_startup: F)
4242
})
4343
.filter(None, LevelFilter::Trace)
4444
.parse(filter)
45-
.parse(&env::var("RUST_LOG").unwrap_or("".to_owned()))
45+
.parse(&env::var("RUST_LOG").unwrap_or_else(|_| "".to_owned()))
4646
.init();
4747
}
4848

@@ -68,7 +68,7 @@ pub fn parse_options(options: &Options, free: Vec<&str>) -> Matches {
6868
Ok(matches) => {
6969
if matches.opt_present("h") || matches.free.len() != free.len() {
7070
let brief = format!("Usage: {} [OPTION]... {}",
71-
env::args().nth(0).unwrap(), free.join(" "));
71+
env::args().next().unwrap(), free.join(" "));
7272
print!("{}", options.usage(&brief));
7373
process::exit(if matches.free.len() != free.len() { 1 } else { 0 })
7474
}

src/iface/ethernet.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1757,7 +1757,7 @@ mod test {
17571757
let mut pkts = Vec::new();
17581758
while let Some((rx, _tx)) = iface.device.receive() {
17591759
rx.consume(timestamp, |pkt| {
1760-
pkts.push(pkt.iter().cloned().collect());
1760+
pkts.push(pkt.to_vec());
17611761
Ok(())
17621762
}).unwrap();
17631763
}
@@ -2567,7 +2567,7 @@ mod test {
25672567
// Leave multicast groups
25682568
let timestamp = Instant::now();
25692569
for group in &groups {
2570-
iface.leave_multicast_group(group.clone(), timestamp)
2570+
iface.leave_multicast_group(*group, timestamp)
25712571
.unwrap();
25722572
}
25732573

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ compile_error!("at least one socket needs to be enabled"); */
9494
#![allow(clippy::redundant_field_names)]
9595
#![allow(clippy::identity_op)]
9696
#![allow(clippy::option_map_unit_fn)]
97+
#![allow(clippy::unit_arg)]
9798

9899
#[cfg(feature = "alloc")]
99100
extern crate alloc;

src/phy/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ pub struct DeviceCapabilities {
217217

218218
/// Only present to prevent people from trying to initialize every field of DeviceLimits,
219219
/// which would not let us add new fields in the future.
220-
dummy: ()
220+
pub(crate) dummy: ()
221221
}
222222

223223
/// An interface for sending and receiving raw network frames.

0 commit comments

Comments
 (0)