Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Clippy warnings #1696

Merged
merged 7 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/event/source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ where
token: Token,
interests: Interest,
) -> io::Result<()> {
(&mut **self).register(registry, token, interests)
(**self).register(registry, token, interests)
}

fn reregister(
Expand All @@ -130,10 +130,10 @@ where
token: Token,
interests: Interest,
) -> io::Result<()> {
(&mut **self).reregister(registry, token, interests)
(**self).reregister(registry, token, interests)
}

fn deregister(&mut self, registry: &Registry) -> io::Result<()> {
(&mut **self).deregister(registry)
(**self).deregister(registry)
}
}
2 changes: 1 addition & 1 deletion src/interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl fmt::Debug for Interest {
one = true
}
}
#[cfg(any(target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
{
if self.is_lio() {
if one {
Expand Down
6 changes: 3 additions & 3 deletions src/io_source.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ impl SelectorId {
/// Associate an I/O source with `registry`, returning an error if its
/// already registered.
fn associate(&self, registry: &Registry) -> io::Result<()> {
let registry_id = poll::selector(&registry).id();
let registry_id = poll::selector(registry).id();
let previous_id = self.id.swap(registry_id, Ordering::AcqRel);

if previous_id == Self::UNASSOCIATED {
Expand All @@ -247,7 +247,7 @@ impl SelectorId {
/// error if its registered with a different `Registry` or not registered at
/// all.
fn check_association(&self, registry: &Registry) -> io::Result<()> {
let registry_id = poll::selector(&registry).id();
let registry_id = poll::selector(registry).id();
let id = self.id.load(Ordering::Acquire);

if id == registry_id {
Expand All @@ -268,7 +268,7 @@ impl SelectorId {
/// Remove a previously made association from `registry`, returns an error
/// if it was not previously associated with `registry`.
fn remove_association(&self, registry: &Registry) -> io::Result<()> {
let registry_id = poll::selector(&registry).id();
let registry_id = poll::selector(registry).id();
let previous_id = self.id.swap(Self::UNASSOCIATED, Ordering::AcqRel);

if previous_id == registry_id {
Expand Down
20 changes: 10 additions & 10 deletions src/net/tcp/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,49 +174,49 @@ impl TcpStream {

impl Read for TcpStream {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read(buf))
self.inner.do_io(|mut inner| inner.read(buf))
}

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read_vectored(bufs))
self.inner.do_io(|mut inner| inner.read_vectored(bufs))
}
}

impl<'a> Read for &'a TcpStream {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read(buf))
self.inner.do_io(|mut inner| inner.read(buf))
}

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read_vectored(bufs))
self.inner.do_io(|mut inner| inner.read_vectored(bufs))
}
}

impl Write for TcpStream {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write(buf))
self.inner.do_io(|mut inner| inner.write(buf))
}

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write_vectored(bufs))
self.inner.do_io(|mut inner| inner.write_vectored(bufs))
}

fn flush(&mut self) -> io::Result<()> {
self.inner.do_io(|inner| (&*inner).flush())
self.inner.do_io(|mut inner| inner.flush())
}
}

impl<'a> Write for &'a TcpStream {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write(buf))
self.inner.do_io(|mut inner| inner.write(buf))
}

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write_vectored(bufs))
self.inner.do_io(|mut inner| inner.write_vectored(bufs))
}

fn flush(&mut self) -> io::Result<()> {
self.inner.do_io(|inner| (&*inner).flush())
self.inner.do_io(|mut inner| inner.flush())
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/net/uds/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,49 +73,49 @@ impl UnixStream {

impl Read for UnixStream {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read(buf))
self.inner.do_io(|mut inner| inner.read(buf))
}

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read_vectored(bufs))
self.inner.do_io(|mut inner| inner.read_vectored(bufs))
}
}

impl<'a> Read for &'a UnixStream {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read(buf))
self.inner.do_io(|mut inner| inner.read(buf))
}

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).read_vectored(bufs))
self.inner.do_io(|mut inner| inner.read_vectored(bufs))
}
}

impl Write for UnixStream {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write(buf))
self.inner.do_io(|mut inner| inner.write(buf))
}

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write_vectored(bufs))
self.inner.do_io(|mut inner| inner.write_vectored(bufs))
}

fn flush(&mut self) -> io::Result<()> {
self.inner.do_io(|inner| (&*inner).flush())
self.inner.do_io(|mut inner| inner.flush())
}
}

impl<'a> Write for &'a UnixStream {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write(buf))
self.inner.do_io(|mut inner| inner.write(buf))
}

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
self.inner.do_io(|inner| (&*inner).write_vectored(bufs))
self.inner.do_io(|mut inner| inner.write_vectored(bufs))
}

fn flush(&mut self) -> io::Result<()> {
self.inner.do_io(|inner| (&*inner).flush())
self.inner.do_io(|mut inner| inner.flush())
}
}

Expand Down
20 changes: 10 additions & 10 deletions src/sys/unix/pipe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,29 +244,29 @@ impl event::Source for Sender {

impl Write for Sender {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).write(buf))
self.inner.do_io(|mut inner| inner.write(buf))
}

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).write_vectored(bufs))
self.inner.do_io(|mut inner| inner.write_vectored(bufs))
}

fn flush(&mut self) -> io::Result<()> {
self.inner.do_io(|sender| (&*sender).flush())
self.inner.do_io(|mut inner| inner.flush())
}
}

impl Write for &Sender {
fn write(&mut self, buf: &[u8]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).write(buf))
self.inner.do_io(|mut inner| inner.write(buf))
}

fn write_vectored(&mut self, bufs: &[IoSlice<'_>]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).write_vectored(bufs))
self.inner.do_io(|mut inner| inner.write_vectored(bufs))
}

fn flush(&mut self) -> io::Result<()> {
self.inner.do_io(|sender| (&*sender).flush())
self.inner.do_io(|mut inner| inner.flush())
}
}

Expand Down Expand Up @@ -341,21 +341,21 @@ impl event::Source for Receiver {

impl Read for Receiver {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).read(buf))
self.inner.do_io(|mut inner| inner.read(buf))
}

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).read_vectored(bufs))
self.inner.do_io(|mut inner| inner.read_vectored(bufs))
}
}

impl Read for &Receiver {
fn read(&mut self, buf: &mut [u8]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).read(buf))
self.inner.do_io(|mut inner| inner.read(buf))
}

fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> io::Result<usize> {
self.inner.do_io(|sender| (&*sender).read_vectored(bufs))
self.inner.do_io(|mut inner| inner.read_vectored(bufs))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/sys/unix/selector/kqueue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ fn kevent_register(
Err(err)
}
})
.and_then(|()| check_errors(&changes, ignored_errors))
.and_then(|()| check_errors(changes, ignored_errors))
}

/// Check all events for possible errors, it returns the first error found.
Expand Down
4 changes: 2 additions & 2 deletions src/sys/unix/uds/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ cfg_os_poll! {
sockaddr.sun_family = libc::AF_UNIX as libc::sa_family_t;

let bytes = path.as_os_str().as_bytes();
match (bytes.get(0), bytes.len().cmp(&sockaddr.sun_path.len())) {
match (bytes.first(), bytes.len().cmp(&sockaddr.sun_path.len())) {
// Abstract paths don't need a null terminator
(Some(&0), Ordering::Greater) => {
return Err(io::Error::new(
Expand All @@ -64,7 +64,7 @@ cfg_os_poll! {
let offset = path_offset(&sockaddr);
let mut socklen = offset + bytes.len();

match bytes.get(0) {
match bytes.first() {
// The struct has already been zeroes so the null byte for pathname
// addresses is already there.
Some(&0) | None => {}
Expand Down
2 changes: 1 addition & 1 deletion src/waker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ impl Waker {
pub fn new(registry: &Registry, token: Token) -> io::Result<Waker> {
#[cfg(debug_assertions)]
registry.register_waker();
sys::Waker::new(poll::selector(&registry), token).map(|inner| Waker { inner })
sys::Waker::new(poll::selector(registry), token).map(|inner| Waker { inner })
}

/// Wake up the [`Poll`] associated with this `Waker`.
Expand Down
2 changes: 1 addition & 1 deletion tests/interest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn fmt_debug() {
{
assert_eq!(format!("{:?}", Interest::AIO), "AIO");
}
#[cfg(any(target_os = "freebsd"))]
#[cfg(target_os = "freebsd")]
{
assert_eq!(format!("{:?}", Interest::LIO), "LIO");
}
Expand Down