Skip to content

Commit b1b4372

Browse files
bors[bot]asomers
andauthored
Merge #1757
1757: Clippy cleanup in the tests. r=rtzoeller a=asomers * Remove a redundant closure. Co-authored-by: Alan Somers <[email protected]>
2 parents d09c297 + dc1a34b commit b1b4372

File tree

4 files changed

+11
-14
lines changed

4 files changed

+11
-14
lines changed

.cirrus.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ build: &BUILD
2020
- rustc +$TOOLCHAIN -Vv
2121
- $TOOL +$TOOLCHAIN $BUILD $ZFLAGS --target $TARGET --all-targets
2222
- $TOOL +$TOOLCHAIN doc $ZFLAGS --no-deps --target $TARGET
23-
- $TOOL +$TOOLCHAIN clippy $ZFLAGS --target $TARGET -- -D warnings
23+
- $TOOL +$TOOLCHAIN clippy $ZFLAGS --target $TARGET --all-targets -- -D warnings
2424
- if [ -z "$NOHACK" ]; then $TOOL +$TOOLCHAIN install cargo-hack; fi
2525
- if [ -z "$NOHACK" ]; then $TOOL +$TOOLCHAIN hack $ZFLAGS check --target $TARGET --each-feature; fi
2626

@@ -327,4 +327,4 @@ task:
327327
container:
328328
image: rust:latest
329329
setup_script: rustup +$TOOLCHAIN component add rustfmt
330-
test_script: $TOOL +$TOOLCHAIN fmt --all -- --check
330+
test_script: $TOOL +$TOOLCHAIN fmt --all -- --check

test/sys/test_pthread.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use nix::sys::pthread::*;
44
#[test]
55
fn test_pthread_self() {
66
let tid = pthread_self();
7-
assert!(tid != ::std::ptr::null_mut());
7+
assert!(!tid.is_null());
88
}
99

1010
#[cfg(not(any(target_env = "musl", target_os = "redox")))]

test/sys/test_socket.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ mod recvfrom {
345345
)
346346
.unwrap();
347347
// Ignore from for stream sockets
348-
let _ = sendrecv(fd1, fd2, |s, m, flags| send(s, m, flags), |_, _| {});
348+
let _ = sendrecv(fd1, fd2, send, |_, _| {});
349349
}
350350

351351
#[test]
@@ -1472,7 +1472,7 @@ fn loopback_address(
14721472
use std::io;
14731473
use std::io::Write;
14741474

1475-
let addrs = match getifaddrs() {
1475+
let mut addrs = match getifaddrs() {
14761476
Ok(iter) => iter,
14771477
Err(e) => {
14781478
let stdioerr = io::stderr();
@@ -1482,15 +1482,11 @@ fn loopback_address(
14821482
}
14831483
};
14841484
// return first address matching family
1485-
for ifaddr in addrs {
1486-
if ifaddr.flags.contains(InterfaceFlags::IFF_LOOPBACK)
1485+
addrs.find(|ifaddr| {
1486+
ifaddr.flags.contains(InterfaceFlags::IFF_LOOPBACK)
14871487
&& ifaddr.address.as_ref().and_then(SockaddrLike::family)
14881488
== Some(family)
1489-
{
1490-
return Some(ifaddr);
1491-
}
1492-
}
1493-
None
1489+
})
14941490
}
14951491

14961492
#[cfg(any(

test/test_unistd.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,6 +1169,8 @@ fn test_access_file_exists() {
11691169
assert!(access(&path, AccessFlags::R_OK | AccessFlags::W_OK).is_ok());
11701170
}
11711171

1172+
//Clippy false positive https://github.com/rust-lang/rust-clippy/issues/9111
1173+
#[allow(clippy::needless_borrow)]
11721174
#[cfg(not(target_os = "redox"))]
11731175
#[test]
11741176
fn test_user_into_passwd() {
@@ -1198,8 +1200,7 @@ fn test_setfsuid() {
11981200
// create a temporary file with permissions '-rw-r-----'
11991201
let file = tempfile::NamedTempFile::new_in("/var/tmp").unwrap();
12001202
let temp_path = file.into_temp_path();
1201-
dbg!(&temp_path);
1202-
let temp_path_2 = (&temp_path).to_path_buf();
1203+
let temp_path_2 = temp_path.to_path_buf();
12031204
let mut permissions = fs::metadata(&temp_path).unwrap().permissions();
12041205
permissions.set_mode(0o640);
12051206

0 commit comments

Comments
 (0)