commit b4cc2c96aea71a95daf0f7e4cece045bfce9a6ad
Author: John Nunley <dev@notgull.net>
Date:   Sun May 19 14:21:54 2024 -0700

    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 <dev@notgull.net>

diff --git a/src/loop_logic.rs b/src/loop_logic.rs
index 1b246814fb..a4e89085c1 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<OwnedFd>);
+
+        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),
