From a77b2fbab25f947942acd3fd1e9c97ec43814822 Mon Sep 17 00:00:00 2001 From: Axel Forsman Date: Tue, 23 Nov 2021 13:56:31 +0100 Subject: [PATCH] io: extend `AsyncFdReadyGuard` method lifetimes (#4267) The implicit elided lifetimes of the `AsyncFd` references in return types of methods on `AsyncFdReadyGuard` resolved to that of `&self`. However that lifetime is smaller than `'a` since `self` contains an `&'a AsyncFd` reference. This will not change so the change also does not lessen future proofing. --- tokio/src/io/async_fd.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tokio/src/io/async_fd.rs b/tokio/src/io/async_fd.rs index e35284339..3d5bc6325 100644 --- a/tokio/src/io/async_fd.rs +++ b/tokio/src/io/async_fd.rs @@ -525,7 +525,7 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> { #[cfg_attr(docsrs, doc(alias = "with_io"))] pub fn try_io( &mut self, - f: impl FnOnce(&AsyncFd) -> io::Result, + f: impl FnOnce(&'a AsyncFd) -> io::Result, ) -> Result, TryIoError> { let result = f(self.async_fd); @@ -542,12 +542,12 @@ impl<'a, Inner: AsRawFd> AsyncFdReadyGuard<'a, Inner> { } /// Returns a shared reference to the inner [`AsyncFd`]. - pub fn get_ref(&self) -> &AsyncFd { + pub fn get_ref(&self) -> &'a AsyncFd { self.async_fd } /// Returns a shared reference to the backing object of the inner [`AsyncFd`]. - pub fn get_inner(&self) -> &Inner { + pub fn get_inner(&self) -> &'a Inner { self.get_ref().get_ref() } }