From 80f4bfac00785ee3d5b330d99cbb9fff4db0a0f2 Mon Sep 17 00:00:00 2001 From: Yi Wang Date: Sun, 15 Jun 2025 18:43:33 +0800 Subject: [PATCH] block: keep lifetime consistent from input to output Cargo fuzz build report an error: error: lifetime flowing from input to output with different syntax can be confusing --> /home/runner/work/cloud-hypervisor/cloud-hypervisor/block/src/lib.rs:747:13 | 747 | fn file(&mut self) -> MutexGuard; | ^^^^^^^^^ ------------- the lifetime gets resolved as `'_` | | | this lifetime flows to the output error: lifetime flowing from input to output with different syntax can be confusing --> /home/runner/work/cloud-hypervisor/cloud-hypervisor/block/src/async_io.rs:68:11 | 68 | fn fd(&mut self) -> BorrowedDiskFd; | ^^^^^^^^^ -------------- the lifetime gets resolved as `'_` | | | this lifetime flows to the output Signed-off-by: Yi Wang --- block/src/async_io.rs | 2 +- block/src/lib.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/src/async_io.rs b/block/src/async_io.rs index 6b77d6a9c..3f37bd6e3 100644 --- a/block/src/async_io.rs +++ b/block/src/async_io.rs @@ -65,7 +65,7 @@ pub trait DiskFile: Send { /// /// The file descriptor is supposed to be used for `fcntl()` calls but no /// other operation. - fn fd(&mut self) -> BorrowedDiskFd; + fn fd(&mut self) -> BorrowedDiskFd<'_>; } #[derive(Error, Debug)] diff --git a/block/src/lib.rs b/block/src/lib.rs index 2ffd13a44..83b115af2 100644 --- a/block/src/lib.rs +++ b/block/src/lib.rs @@ -744,7 +744,7 @@ where Ok(()) } - fn file(&mut self) -> MutexGuard; + fn file(&mut self) -> MutexGuard<'_, F>; } pub enum ImageType {