From 2bc8d51a60821504abdbd52f9ca7873c31ccdac2 Mon Sep 17 00:00:00 2001 From: Jinank Jain Date: Mon, 9 Jun 2025 15:23:59 +0530 Subject: [PATCH] misc: Fix missing lifetime syntax clippy warning This was caught by the nightly compiler during cargo fuzz build. error: lifetime flowing from input to output with different syntax can be confusing --> /home/runner/work/cloud-hypervisor/cloud-hypervisor/hypervisor/src/arch/x86/emulator/mod.rs:493:26 | 493 | pub fn new(platform: &mut dyn PlatformEmulator) -> Emulator { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ----------- the lifetime gets resolved as `'_` | | | this lifetime flows to the output | = note: `-D mismatched-lifetime-syntaxes` implied by `-D warnings` = help: to override `-D warnings` add `#[allow(mismatched_lifetime_syntaxes)]` help: one option is to remove the lifetime for references and use the anonymous lifetime for paths | 493 | pub fn new(platform: &mut dyn PlatformEmulator) -> Emulator<'_, T> { Signed-off-by: Jinank Jain --- block/src/fixed_vhd_async.rs | 2 +- block/src/fixed_vhd_sync.rs | 2 +- block/src/qcow/vec_cache.rs | 2 +- block/src/qcow_sync.rs | 4 ++-- block/src/raw_async.rs | 2 +- block/src/raw_async_aio.rs | 2 +- block/src/raw_sync.rs | 2 +- block/src/vhdx_sync.rs | 4 ++-- hypervisor/src/arch/x86/emulator/mod.rs | 2 +- virtio-devices/src/vsock/mod.rs | 2 +- vmm/src/device_tree.rs | 4 ++-- vmm/src/gdb.rs | 6 +++--- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/block/src/fixed_vhd_async.rs b/block/src/fixed_vhd_async.rs index dd12a7291..6b51d070f 100644 --- a/block/src/fixed_vhd_async.rs +++ b/block/src/fixed_vhd_async.rs @@ -34,7 +34,7 @@ impl DiskFile for FixedVhdDiskAsync { ) as Box) } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { BorrowedDiskFd::new(self.0.as_raw_fd()) } } diff --git a/block/src/fixed_vhd_sync.rs b/block/src/fixed_vhd_sync.rs index 107a805bd..b1f2118f1 100644 --- a/block/src/fixed_vhd_sync.rs +++ b/block/src/fixed_vhd_sync.rs @@ -34,7 +34,7 @@ impl DiskFile for FixedVhdDiskSync { ) as Box) } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { BorrowedDiskFd::new(self.0.as_raw_fd()) } } diff --git a/block/src/qcow/vec_cache.rs b/block/src/qcow/vec_cache.rs index 752d0ad6c..67068fdde 100644 --- a/block/src/qcow/vec_cache.rs +++ b/block/src/qcow/vec_cache.rs @@ -111,7 +111,7 @@ impl CacheMap { self.map.get_mut(&index) } - pub fn iter_mut(&mut self) -> IterMut { + pub fn iter_mut(&mut self) -> IterMut<'_, usize, T> { self.map.iter_mut() } diff --git a/block/src/qcow_sync.rs b/block/src/qcow_sync.rs index d17d26ca7..f07e245e0 100644 --- a/block/src/qcow_sync.rs +++ b/block/src/qcow_sync.rs @@ -39,7 +39,7 @@ impl DiskFile for QcowDiskSync { Ok(Box::new(QcowSync::new(self.qcow_file.clone())) as Box) } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { let lock = self.qcow_file.lock().unwrap(); BorrowedDiskFd::new(lock.as_raw_fd()) } @@ -63,7 +63,7 @@ impl QcowSync { } impl AsyncAdaptor for Arc> { - fn file(&mut self) -> MutexGuard { + fn file(&mut self) -> MutexGuard<'_, QcowFile> { self.lock().unwrap() } } diff --git a/block/src/raw_async.rs b/block/src/raw_async.rs index 889d47057..496445c6a 100644 --- a/block/src/raw_async.rs +++ b/block/src/raw_async.rs @@ -47,7 +47,7 @@ impl DiskFile for RawFileDisk { } } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { BorrowedDiskFd::new(self.file.as_raw_fd()) } } diff --git a/block/src/raw_async_aio.rs b/block/src/raw_async_aio.rs index e203593e5..9ef0c6261 100644 --- a/block/src/raw_async_aio.rs +++ b/block/src/raw_async_aio.rs @@ -50,7 +50,7 @@ impl DiskFile for RawFileDiskAio { } } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { BorrowedDiskFd::new(self.file.as_raw_fd()) } } diff --git a/block/src/raw_sync.rs b/block/src/raw_sync.rs index 4de40c544..54ba1acca 100644 --- a/block/src/raw_sync.rs +++ b/block/src/raw_sync.rs @@ -44,7 +44,7 @@ impl DiskFile for RawFileDiskSync { } } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { BorrowedDiskFd::new(self.file.as_raw_fd()) } } diff --git a/block/src/vhdx_sync.rs b/block/src/vhdx_sync.rs index 5d12f2ab5..d832f5e3c 100644 --- a/block/src/vhdx_sync.rs +++ b/block/src/vhdx_sync.rs @@ -39,7 +39,7 @@ impl DiskFile for VhdxDiskSync { ) } - fn fd(&mut self) -> BorrowedDiskFd { + fn fd(&mut self) -> BorrowedDiskFd<'_> { let lock = self.vhdx_file.lock().unwrap(); BorrowedDiskFd::new(lock.as_raw_fd()) } @@ -62,7 +62,7 @@ impl VhdxSync { } impl AsyncAdaptor for Arc> { - fn file(&mut self) -> MutexGuard { + fn file(&mut self) -> MutexGuard<'_, Vhdx> { self.lock().unwrap() } } diff --git a/hypervisor/src/arch/x86/emulator/mod.rs b/hypervisor/src/arch/x86/emulator/mod.rs index 2a3125eb8..61bbd56fd 100644 --- a/hypervisor/src/arch/x86/emulator/mod.rs +++ b/hypervisor/src/arch/x86/emulator/mod.rs @@ -490,7 +490,7 @@ macro_rules! gen_handler_match { } impl Emulator<'_, T> { - pub fn new(platform: &mut dyn PlatformEmulator) -> Emulator { + pub fn new(platform: &mut dyn PlatformEmulator) -> Emulator<'_, T> { Emulator { platform } } diff --git a/virtio-devices/src/vsock/mod.rs b/virtio-devices/src/vsock/mod.rs index 0ada35f73..ecd523d1c 100644 --- a/virtio-devices/src/vsock/mod.rs +++ b/virtio-devices/src/vsock/mod.rs @@ -286,7 +286,7 @@ pub mod tests { } } - pub fn create_epoll_handler_context(&self) -> EpollHandlerContext { + pub fn create_epoll_handler_context(&self) -> EpollHandlerContext<'_> { const QSIZE: u16 = 2; let guest_rxvq = GuestQ::new(GuestAddress(0x0010_0000), &self.mem, QSIZE); diff --git a/vmm/src/device_tree.rs b/vmm/src/device_tree.rs index 6814903f8..f83788687 100644 --- a/vmm/src/device_tree.rs +++ b/vmm/src/device_tree.rs @@ -74,10 +74,10 @@ impl DeviceTree { pub fn remove(&mut self, k: &str) -> Option { self.0.remove(k) } - pub fn iter(&self) -> std::collections::hash_map::Iter { + pub fn iter(&self) -> std::collections::hash_map::Iter<'_, String, DeviceNode> { self.0.iter() } - pub fn breadth_first_traversal(&self) -> BftIter { + pub fn breadth_first_traversal(&self) -> BftIter<'_> { BftIter::new(&self.0) } pub fn pci_devices(&self) -> Vec<&DeviceNode> { diff --git a/vmm/src/gdb.rs b/vmm/src/gdb.rs index 6f06277b8..955372aee 100644 --- a/vmm/src/gdb.rs +++ b/vmm/src/gdb.rs @@ -184,12 +184,12 @@ impl Target for GdbStub { type Error = String; #[inline(always)] - fn base_ops(&mut self) -> BaseOps { + fn base_ops(&mut self) -> BaseOps<'_, Self::Arch, Self::Error> { BaseOps::MultiThread(self) } #[inline(always)] - fn support_breakpoints(&mut self) -> Option> { + fn support_breakpoints(&mut self) -> Option> { Some(self) } @@ -388,7 +388,7 @@ impl MultiThreadSingleStep for GdbStub { impl Breakpoints for GdbStub { #[inline(always)] - fn support_hw_breakpoint(&mut self) -> Option> { + fn support_hw_breakpoint(&mut self) -> Option> { Some(self) } }