Skip to content

Commit 3cd2885

Browse files
committed
Fix some clippy lints.
1 parent 6a5c902 commit 3cd2885

File tree

9 files changed

+15
-18
lines changed

9 files changed

+15
-18
lines changed

cap-net-ext/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl TcpListenerExt for TcpListener {
154154
}
155155

156156
fn accept_with(&self, blocking: Blocking) -> io::Result<(TcpStream, SocketAddr)> {
157-
let (stream, addr) = rustix::net::acceptfrom_with(&self, socket_flags(blocking))?;
157+
let (stream, addr) = rustix::net::acceptfrom_with(self, socket_flags(blocking))?;
158158
set_socket_flags(&stream, blocking)?;
159159

160160
// We know have a TCP socket, so we know we'll get an IP address.

cap-primitives/src/fs/manually/open.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,7 @@ pub(crate) fn stat(start: &fs::File, path: &Path, follow: FollowSymlinks) -> io:
522522

523523
// If the path ended in `.` or `..`, we already have it open, so just do
524524
// `.metadata()` on it.
525-
Metadata::from_file(&*ctx.base)
525+
Metadata::from_file(&ctx.base)
526526
}
527527

528528
/// Test whether the given options imply that we should treat an open file as

cap-primitives/src/fs/via_parent/create_dir.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub(crate) fn create_dir(start: &fs::File, path: &Path, options: &DirOptions) ->
1313
// slashes.
1414
let path = strip_dir_suffix(path);
1515

16-
let (dir, basename) = open_parent(start, &*path)?;
16+
let (dir, basename) = open_parent(start, &path)?;
1717

1818
create_dir_unchecked(&dir, basename.as_ref(), options)
1919
}

cap-primitives/src/fs/via_parent/rename.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ pub(crate) fn rename(
2727
let old_path = strip_dir_suffix(old_path);
2828
let new_path = strip_dir_suffix(new_path);
2929

30-
let (old_dir, old_basename) = open_parent(old_start, &*old_path)?;
31-
let (new_dir, new_basename) = open_parent(new_start, &*new_path)?;
30+
let (old_dir, old_basename) = open_parent(old_start, &old_path)?;
31+
let (new_dir, new_basename) = open_parent(new_start, &new_path)?;
3232

3333
// On Unix, re-append a slash if needed.
3434
#[cfg(unix)]

cap-primitives/src/rustix/fs/dir_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ pub(crate) fn open_ambient_dir_impl(
118118
#[cfg(target_os = "wasi")]
119119
options.directory(true);
120120

121-
options.open(&path)
121+
options.open(path)
122122
}
123123

124124
/// Use `O_PATH` on platforms which have it, or none otherwise.

cap-primitives/src/rustix/fs/times.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,5 @@ pub(crate) fn set_times_follow_unchecked(
5858
last_access: to_timespec(atime)?,
5959
last_modification: to_timespec(mtime)?,
6060
};
61-
Ok(utimensat(&start, path, &times, AtFlags::empty())?)
61+
Ok(utimensat(start, path, &times, AtFlags::empty())?)
6262
}

cap-primitives/src/rustix/linux/fs/procfs.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pub(crate) fn set_permissions_through_proc_self_fd(
4646

4747
let dirfd = proc_self_fd()?;
4848
let mode = Mode::from_bits(perm.mode() as RawMode).ok_or_else(errors::invalid_flags)?;
49-
Ok(chmodat(&dirfd, DecInt::from_fd(&opath), mode)?)
49+
Ok(chmodat(dirfd, DecInt::from_fd(&opath), mode)?)
5050
}
5151

5252
pub(crate) fn set_times_through_proc_self_fd(

cap-tempfile/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ impl TempDir {
8383
pub fn new_in(dir: &Dir) -> io::Result<Self> {
8484
for _ in 0..Self::num_iterations() {
8585
let name = &Self::new_name();
86-
match dir.create_dir(&name) {
86+
match dir.create_dir(name) {
8787
Ok(()) => {
88-
let dir = match dir.open_dir(&name) {
88+
let dir = match dir.open_dir(name) {
8989
Ok(dir) => dir,
9090
Err(e) => {
9191
dir.remove_dir(name).ok();
@@ -203,7 +203,7 @@ where
203203
Err(e) => return Err(e),
204204
}
205205
}
206-
return Err(std::io::Error::new(err, "too many temporary files exist"));
206+
Err(std::io::Error::new(err, "too many temporary files exist"))
207207
}
208208

209209
#[test]

cap-tempfile/src/tempfile.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,6 @@ impl<'d> Debug for TempFile<'d> {
6161

6262
#[cfg(any(target_os = "android", target_os = "linux"))]
6363
fn new_tempfile_linux(d: &Dir, anonymous: bool) -> io::Result<Option<File>> {
64-
use cap_std::io_lifetimes::OwnedFd;
6564
use rustix::fs::{Mode, OFlags};
6665
// openat's API uses WRONLY. There may be use cases for reading too, so let's
6766
// support it.
@@ -74,15 +73,13 @@ fn new_tempfile_linux(d: &Dir, anonymous: bool) -> io::Result<Option<File>> {
7473
let mode = Mode::from_raw_mode(0o666);
7574
// Happy path - Linux with O_TMPFILE
7675
match rustix::fs::openat(d, ".", oflags, mode) {
77-
Ok(r) => return Ok(Some(File::from(OwnedFd::from(r)))),
76+
Ok(r) => Ok(Some(File::from(r))),
7877
// See <https://github.com/Stebalien/tempfile/blob/1a40687e06eb656044e3d2dffa1379f04b3ef3fd/src/file/imp/unix.rs#L81>
7978
// TODO: With newer Rust versions, this could be simplied to only write `Err` once.
8079
Err(rustix::io::Errno::OPNOTSUPP)
8180
| Err(rustix::io::Errno::ISDIR)
8281
| Err(rustix::io::Errno::NOENT) => Ok(None),
83-
Err(e) => {
84-
return Err(e.into());
85-
}
82+
Err(e) => Err(e.into()),
8683
}
8784
}
8885

@@ -92,10 +89,10 @@ fn generate_name_in(subdir: &Dir, f: &File) -> io::Result<String> {
9289
use rustix::fd::AsFd;
9390
use rustix::fs::AtFlags;
9491
let procself_fd = rustix::io::proc_self_fd()?;
95-
let fdnum = rustix::path::DecInt::from_fd(&f.as_fd());
92+
let fdnum = rustix::path::DecInt::from_fd(f.as_fd());
9693
let fdnum = fdnum.as_c_str();
9794
super::retry_with_name_ignoring(io::ErrorKind::AlreadyExists, |name| {
98-
rustix::fs::linkat(&procself_fd, fdnum, subdir, name, AtFlags::SYMLINK_FOLLOW)
95+
rustix::fs::linkat(procself_fd, fdnum, subdir, name, AtFlags::SYMLINK_FOLLOW)
9996
.map_err(Into::into)
10097
})
10198
.map(|(_, name)| name)

0 commit comments

Comments
 (0)