From 640ef73885a4bd2ab2a4398c473a8224bc98eb46 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 19 May 2024 10:59:22 -0700 Subject: [PATCH 1/2] chore: Fix nightly clippy warning Signed-off-by: John Nunley --- src/sources/futures.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/sources/futures.rs b/src/sources/futures.rs index 65e3fc30..0bf7c552 100644 --- a/src/sources/futures.rs +++ b/src/sources/futures.rs @@ -111,9 +111,9 @@ impl Scheduler { /// Sends the given future to the executor associated to this scheduler /// /// Returns an error if the the executor not longer exists. - pub fn schedule(&self, future: Fut) -> Result<(), ExecutorDestroyed> + pub fn schedule(&self, future: Fut) -> Result<(), ExecutorDestroyed> where - Fut: Future, + Fut: Future + 'static, T: 'static, { /// Store this future's result in the executor. From aaa4afd26f3f0a0d046750c8d6155c15a0227e48 Mon Sep 17 00:00:00 2001 From: John Nunley Date: Sun, 19 May 2024 14:21:54 -0700 Subject: [PATCH 2/2] tests: Avoid free-ing a random FD in OwnedFd drop In the insert_bad_source test, we drop the FD "420", which doesn't exist. Previously the error was ignored, but in the latest nightly it now aborts the program. This commit fixes this by leaking the bad "OwnedFd" instead of leaving it to be dropped. Signed-off-by: John Nunley --- src/loop_logic.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/loop_logic.rs b/src/loop_logic.rs index 1b246814..a4e89085 100644 --- a/src/loop_logic.rs +++ b/src/loop_logic.rs @@ -1153,10 +1153,21 @@ mod tests { #[cfg(unix)] #[test] fn insert_bad_source() { - use std::os::unix::io::FromRawFd; + use std::mem::ManuallyDrop; + use std::os::unix::io::{AsFd, FromRawFd, OwnedFd}; + + struct LeakedFd(ManuallyDrop); + + impl AsFd for LeakedFd { + fn as_fd(&self) -> std::os::unix::prelude::BorrowedFd<'_> { + self.0.as_fd() + } + } let event_loop = EventLoop::<()>::try_new().unwrap(); - let fd = unsafe { std::os::unix::io::OwnedFd::from_raw_fd(420) }; + let fd = LeakedFd(ManuallyDrop::new(unsafe { + std::os::unix::io::OwnedFd::from_raw_fd(420) + })); let ret = event_loop.handle().insert_source( crate::sources::generic::Generic::new(fd, Interest::READ, Mode::Level), |_, _, _| Ok(PostAction::Continue),