From 559ce94aba80cf5b7d61dab42f4a0fb76b4173bb Mon Sep 17 00:00:00 2001 From: Zhang Junyang Date: Mon, 8 Dec 2025 21:46:45 +0800 Subject: [PATCH] Fix elided lifetimes in return values --- kernel/comps/console/src/font.rs | 2 +- kernel/comps/framebuffer/src/framebuffer.rs | 2 +- kernel/comps/mlsdisk/src/layers/4-lsm/mem_table.rs | 2 +- kernel/comps/mlsdisk/src/layers/5-disk/bio.rs | 2 +- kernel/libs/aster-bigtcp/src/iface/poll_iface.rs | 2 +- .../libs/aster-bigtcp/src/socket/bound/tcp_conn.rs | 2 +- kernel/libs/typeflags/src/type_flag.rs | 2 +- kernel/libs/xarray/src/cursor.rs | 2 +- kernel/libs/xarray/src/lib.rs | 4 ++-- kernel/src/context.rs | 2 +- kernel/src/fs/cgroupfs/controller/mod.rs | 2 +- kernel/src/fs/epoll/entry.rs | 2 +- kernel/src/fs/exfat/fs.rs | 2 +- kernel/src/fs/ext2/fs.rs | 2 +- kernel/src/fs/pipe/anony_pipe.rs | 4 ++-- kernel/src/fs/utils/inode.rs | 2 +- kernel/src/ipc/semaphore/system_v/sem.rs | 2 +- kernel/src/ipc/semaphore/system_v/sem_set.rs | 2 +- kernel/src/net/socket/ip/stream/mod.rs | 4 ++-- kernel/src/process/credentials/credentials_.rs | 4 ++-- kernel/src/process/credentials/static_cap.rs | 4 ++-- kernel/src/process/posix_thread/mod.rs | 2 +- kernel/src/process/posix_thread/thread_local.rs | 8 ++++---- kernel/src/process/process/mod.rs | 4 ++-- kernel/src/process/process/process_group.rs | 4 ++-- kernel/src/process/process/session.rs | 2 +- kernel/src/process/process_table.rs | 2 +- kernel/src/process/process_vm/mod.rs | 2 +- kernel/src/syscall/setxattr.rs | 2 +- kernel/src/util/ring_buffer.rs | 4 ++-- kernel/src/vm/vmar/mod.rs | 2 +- osdk/deps/test-kernel/src/path.rs | 2 +- ostd/libs/linux-bzimage/setup/src/sync.rs | 2 +- ostd/src/sync/mutex.rs | 4 ++-- ostd/src/sync/rwarc.rs | 6 +++--- ostd/src/sync/rwlock.rs | 12 ++++++------ ostd/src/sync/rwmutex.rs | 12 ++++++------ ostd/src/util/range_alloc.rs | 2 +- 38 files changed, 62 insertions(+), 62 deletions(-) diff --git a/kernel/comps/console/src/font.rs b/kernel/comps/console/src/font.rs index 484264db6..873dc0cf1 100644 --- a/kernel/comps/console/src/font.rs +++ b/kernel/comps/console/src/font.rs @@ -127,7 +127,7 @@ impl BitmapFont { /// /// This method will return [`None`] if the font does not contain a bitmap for the specified /// character. - pub fn char(&self, ch: u8) -> Option { + pub fn char(&self, ch: u8) -> Option> { let pos = (ch as usize) * self.char_size; let data = self.bitmap.get(pos..pos + self.char_size)?; diff --git a/kernel/comps/framebuffer/src/framebuffer.rs b/kernel/comps/framebuffer/src/framebuffer.rs index b064c4a20..f99f45a86 100644 --- a/kernel/comps/framebuffer/src/framebuffer.rs +++ b/kernel/comps/framebuffer/src/framebuffer.rs @@ -155,7 +155,7 @@ impl FrameBuffer { } /// Calculates the offset of a pixel at the specified position. - pub fn calc_offset(&self, x: usize, y: usize) -> PixelOffset { + pub fn calc_offset(&self, x: usize, y: usize) -> PixelOffset<'_> { PixelOffset { fb: self, offset: (x * self.pixel_format.nbytes() + y * self.line_size) as isize, diff --git a/kernel/comps/mlsdisk/src/layers/4-lsm/mem_table.rs b/kernel/comps/mlsdisk/src/layers/4-lsm/mem_table.rs index 254e9ca40..ec5b78893 100644 --- a/kernel/comps/mlsdisk/src/layers/4-lsm/mem_table.rs +++ b/kernel/comps/mlsdisk/src/layers/4-lsm/mem_table.rs @@ -136,7 +136,7 @@ impl, V: RecordValue> MemTableManager { } /// Gets the immutable `MemTable` instance (read-only). - pub fn immutable_memtable(&self) -> RwLockReadGuard> { + pub fn immutable_memtable(&self) -> RwLockReadGuard<'_, MemTable> { self.immutable.read() } } diff --git a/kernel/comps/mlsdisk/src/layers/5-disk/bio.rs b/kernel/comps/mlsdisk/src/layers/5-disk/bio.rs index c8675f393..4b771f806 100644 --- a/kernel/comps/mlsdisk/src/layers/5-disk/bio.rs +++ b/kernel/comps/mlsdisk/src/layers/5-disk/bio.rs @@ -159,7 +159,7 @@ impl BioReq { /// or accessed by block devices and their users. Each of the extension objects /// must have a different type. To avoid conflicts, it is recommended to use only /// private types for the extension objects. - pub fn ext(&self) -> MutexGuard>> { + pub fn ext(&self) -> MutexGuard<'_, HashMap>> { self.ext.lock() } diff --git a/kernel/libs/aster-bigtcp/src/iface/poll_iface.rs b/kernel/libs/aster-bigtcp/src/iface/poll_iface.rs index ea4184ef8..4015de437 100644 --- a/kernel/libs/aster-bigtcp/src/iface/poll_iface.rs +++ b/kernel/libs/aster-bigtcp/src/iface/poll_iface.rs @@ -28,7 +28,7 @@ impl PollableIface { } } - pub(super) fn as_mut(&mut self) -> PollableIfaceMut { + pub(super) fn as_mut(&mut self) -> PollableIfaceMut<'_, E> { PollableIfaceMut { context: self.interface.context(), pending_conns: &mut self.pending_conns, diff --git a/kernel/libs/aster-bigtcp/src/socket/bound/tcp_conn.rs b/kernel/libs/aster-bigtcp/src/socket/bound/tcp_conn.rs index 9b0ee1bb2..8a1788eb5 100644 --- a/kernel/libs/aster-bigtcp/src/socket/bound/tcp_conn.rs +++ b/kernel/libs/aster-bigtcp/src/socket/bound/tcp_conn.rs @@ -244,7 +244,7 @@ impl TcpConnectionInner { } } - pub(super) fn lock(&self) -> SpinLockGuard, BottomHalfDisabled> { + pub(super) fn lock(&self) -> SpinLockGuard<'_, RawTcpSocketExt, BottomHalfDisabled> { self.socket.lock() } } diff --git a/kernel/libs/typeflags/src/type_flag.rs b/kernel/libs/typeflags/src/type_flag.rs index 400c660de..89114559c 100644 --- a/kernel/libs/typeflags/src/type_flag.rs +++ b/kernel/libs/typeflags/src/type_flag.rs @@ -96,7 +96,7 @@ impl TypeFlagDef { } /// return the items iter - pub fn items_iter(&self) -> syn::punctuated::Iter { + pub fn items_iter(&self) -> syn::punctuated::Iter<'_, TypeFlagItem> { self.items.iter() } diff --git a/kernel/libs/xarray/src/cursor.rs b/kernel/libs/xarray/src/cursor.rs index 4112b3445..0e189b99c 100644 --- a/kernel/libs/xarray/src/cursor.rs +++ b/kernel/libs/xarray/src/cursor.rs @@ -271,7 +271,7 @@ impl<'a, P: NonNullPtr + Send + Sync, M> CursorMut<'a, P, M> { } /// Returns an `XLockGuard` that marks the `XArray` is locked. - fn lock_guard(&self) -> XLockGuard { + fn lock_guard(&self) -> XLockGuard<'_> { // Having a `CursorMut` means that the `XArray` is locked. XLockGuard(self.guard) } diff --git a/kernel/libs/xarray/src/lib.rs b/kernel/libs/xarray/src/lib.rs index 9f39c6dad..f62d48d51 100644 --- a/kernel/libs/xarray/src/lib.rs +++ b/kernel/libs/xarray/src/lib.rs @@ -133,7 +133,7 @@ impl XArray { } /// Acquires the lock to perform mutable operations. - pub fn lock(&self) -> LockedXArray { + pub fn lock(&self) -> LockedXArray<'_, P, M> { LockedXArray { xa: self, guard: self.xlock.lock(), @@ -142,7 +142,7 @@ impl XArray { } /// Acquires the lock with local IRQs disabled to perform mutable operations. - pub fn lock_irq_disabled(&self) -> LockedXArray { + pub fn lock_irq_disabled(&self) -> LockedXArray<'_, P, M, LocalIrqDisabled> { LockedXArray { xa: self, guard: self.xlock.disable_irq().lock(), diff --git a/kernel/src/context.rs b/kernel/src/context.rs index c7a4bc1a5..dd90ddb27 100644 --- a/kernel/src/context.rs +++ b/kernel/src/context.rs @@ -32,7 +32,7 @@ pub struct Context<'a> { impl Context<'_> { /// Gets the userspace of the current task. - pub fn user_space(&self) -> CurrentUserSpace { + pub fn user_space(&self) -> CurrentUserSpace<'_> { CurrentUserSpace(self.thread_local.vmar().borrow()) } } diff --git a/kernel/src/fs/cgroupfs/controller/mod.rs b/kernel/src/fs/cgroupfs/controller/mod.rs index df3e5f7e8..d09224577 100644 --- a/kernel/src/fs/cgroupfs/controller/mod.rs +++ b/kernel/src/fs/cgroupfs/controller/mod.rs @@ -208,7 +208,7 @@ impl Controller { PidsController::init_attr_set(builder, is_root); } - pub(super) fn lock(&self) -> LockedController { + pub(super) fn lock(&self) -> LockedController<'_> { LockedController { active_set: self.active_set.lock(), controller: self, diff --git a/kernel/src/fs/epoll/entry.rs b/kernel/src/fs/epoll/entry.rs index d44e43671..05c632dee 100644 --- a/kernel/src/fs/epoll/entry.rs +++ b/kernel/src/fs/epoll/entry.rs @@ -330,7 +330,7 @@ impl ReadySet { self.pollee.notify(IoEvents::IN); } - pub(super) fn lock_pop(&self) -> ReadySetPopIter { + pub(super) fn lock_pop(&self) -> ReadySetPopIter<'_> { ReadySetPopIter { ready_set: self, _pop_guard: self.pop_guard.lock(), diff --git a/kernel/src/fs/exfat/fs.rs b/kernel/src/fs/exfat/fs.rs index 5c165c94b..1c488672d 100644 --- a/kernel/src/fs/exfat/fs.rs +++ b/kernel/src/fs/exfat/fs.rs @@ -334,7 +334,7 @@ impl ExfatFs { self.super_block.cluster_size as usize * self.super_block.num_clusters as usize } - pub(super) fn lock(&self) -> MutexGuard<()> { + pub(super) fn lock(&self) -> MutexGuard<'_, ()> { self.mutex.lock() } diff --git a/kernel/src/fs/ext2/fs.rs b/kernel/src/fs/ext2/fs.rs index cfef6d331..76ad34818 100644 --- a/kernel/src/fs/ext2/fs.rs +++ b/kernel/src/fs/ext2/fs.rs @@ -131,7 +131,7 @@ impl Ext2 { } /// Returns the super block. - pub fn super_block(&self) -> RwMutexReadGuard> { + pub fn super_block(&self) -> RwMutexReadGuard<'_, Dirty> { self.super_block.read() } diff --git a/kernel/src/fs/pipe/anony_pipe.rs b/kernel/src/fs/pipe/anony_pipe.rs index e097cdfc8..7540aebca 100644 --- a/kernel/src/fs/pipe/anony_pipe.rs +++ b/kernel/src/fs/pipe/anony_pipe.rs @@ -380,11 +380,11 @@ mod test { ); } - fn reader_from(buf: &[u8]) -> VmReader { + fn reader_from(buf: &[u8]) -> VmReader<'_> { VmReader::from(buf).to_fallible() } - fn writer_from(buf: &mut [u8]) -> VmWriter { + fn writer_from(buf: &mut [u8]) -> VmWriter<'_> { VmWriter::from(buf).to_fallible() } } diff --git a/kernel/src/fs/utils/inode.rs b/kernel/src/fs/utils/inode.rs index b738e175a..2242c566f 100644 --- a/kernel/src/fs/utils/inode.rs +++ b/kernel/src/fs/utils/inode.rs @@ -509,7 +509,7 @@ impl dyn Inode { (self as &dyn Any).downcast_ref::() } - pub fn writer(&self, from_offset: usize) -> InodeWriter { + pub fn writer(&self, from_offset: usize) -> InodeWriter<'_> { InodeWriter { inner: self, offset: from_offset, diff --git a/kernel/src/ipc/semaphore/system_v/sem.rs b/kernel/src/ipc/semaphore/system_v/sem.rs index c089f46d5..2b76b7062 100644 --- a/kernel/src/ipc/semaphore/system_v/sem.rs +++ b/kernel/src/ipc/semaphore/system_v/sem.rs @@ -61,7 +61,7 @@ pub(super) struct PendingOp { } impl PendingOp { - pub(super) fn sops_iter(&self) -> Iter { + pub(super) fn sops_iter(&self) -> Iter<'_, SemBuf> { self.sops.iter() } diff --git a/kernel/src/ipc/semaphore/system_v/sem_set.rs b/kernel/src/ipc/semaphore/system_v/sem_set.rs index 2a5e141bc..47d7a99d0 100644 --- a/kernel/src/ipc/semaphore/system_v/sem_set.rs +++ b/kernel/src/ipc/semaphore/system_v/sem_set.rs @@ -199,7 +199,7 @@ impl SemaphoreSet { ); } - pub(super) fn inner(&self) -> SpinLockGuard { + pub(super) fn inner(&self) -> SpinLockGuard<'_, SemSetInner, PreemptDisabled> { self.inner.lock() } diff --git a/kernel/src/net/socket/ip/stream/mod.rs b/kernel/src/net/socket/ip/stream/mod.rs index 3d3a4369a..7c90dfb9e 100644 --- a/kernel/src/net/socket/ip/stream/mod.rs +++ b/kernel/src/net/socket/ip/stream/mod.rs @@ -144,7 +144,7 @@ impl StreamSocket { /// Ensures that the socket state is up to date and obtains a read lock on it. /// /// For a description of what "up-to-date" means, see [`Self::write_updated_state`]. - fn read_updated_state(&self) -> RwLockReadGuard, PreemptDisabled> { + fn read_updated_state(&self) -> RwLockReadGuard<'_, Takeable, PreemptDisabled> { loop { let state = self.state.read(); match state.as_ref() { @@ -166,7 +166,7 @@ impl StreamSocket { /// /// This method performs the delayed state transition to ensure that the state is up to date /// and returns the guard of the write-locked state. - fn write_updated_state(&self) -> RwLockWriteGuard, PreemptDisabled> { + fn write_updated_state(&self) -> RwLockWriteGuard<'_, Takeable, PreemptDisabled> { let mut state = self.state.write(); match state.as_ref() { diff --git a/kernel/src/process/credentials/credentials_.rs b/kernel/src/process/credentials/credentials_.rs index 76ca9b50c..bffa0c8c4 100644 --- a/kernel/src/process/credentials/credentials_.rs +++ b/kernel/src/process/credentials/credentials_.rs @@ -482,11 +482,11 @@ impl Credentials_ { // ******* Supplementary groups methods ******* - pub(super) fn groups(&self) -> RwLockReadGuard, PreemptDisabled> { + pub(super) fn groups(&self) -> RwLockReadGuard<'_, BTreeSet, PreemptDisabled> { self.supplementary_gids.read() } - pub(super) fn groups_mut(&self) -> RwLockWriteGuard, PreemptDisabled> { + pub(super) fn groups_mut(&self) -> RwLockWriteGuard<'_, BTreeSet, PreemptDisabled> { self.supplementary_gids.write() } diff --git a/kernel/src/process/credentials/static_cap.rs b/kernel/src/process/credentials/static_cap.rs index 6bc3c6ded..c54f9dce3 100644 --- a/kernel/src/process/credentials/static_cap.rs +++ b/kernel/src/process/credentials/static_cap.rs @@ -276,7 +276,7 @@ impl Credentials { /// /// This method requires the `Read` right. #[require(R > Read)] - pub fn groups(&self) -> RwLockReadGuard, PreemptDisabled> { + pub fn groups(&self) -> RwLockReadGuard<'_, BTreeSet, PreemptDisabled> { self.0.groups() } @@ -284,7 +284,7 @@ impl Credentials { /// /// This method requires the `Write` right. #[require(R > Write)] - pub fn groups_mut(&self) -> RwLockWriteGuard, PreemptDisabled> { + pub fn groups_mut(&self) -> RwLockWriteGuard<'_, BTreeSet, PreemptDisabled> { self.0.groups_mut() } diff --git a/kernel/src/process/posix_thread/mod.rs b/kernel/src/process/posix_thread/mod.rs index dc4dadd27..e23970adc 100644 --- a/kernel/src/process/posix_thread/mod.rs +++ b/kernel/src/process/posix_thread/mod.rs @@ -114,7 +114,7 @@ impl PosixThread { } /// Returns a read guard to the filesystem information of the thread. - pub fn read_fs(&self) -> RwMutexReadGuard> { + pub fn read_fs(&self) -> RwMutexReadGuard<'_, Arc> { self.fs.read() } diff --git a/kernel/src/process/posix_thread/thread_local.rs b/kernel/src/process/posix_thread/thread_local.rs index fcc3ca585..68473ad7a 100644 --- a/kernel/src/process/posix_thread/thread_local.rs +++ b/kernel/src/process/posix_thread/thread_local.rs @@ -134,11 +134,11 @@ impl ThreadLocal { &self.robust_list } - pub fn borrow_file_table(&self) -> FileTableRef { + pub fn borrow_file_table(&self) -> FileTableRef<'_> { ThreadLocalOptionRef(self.file_table.borrow()) } - pub fn borrow_file_table_mut(&self) -> FileTableRefMut { + pub fn borrow_file_table_mut(&self) -> FileTableRefMut<'_> { ThreadLocalOptionRefMut(self.file_table.borrow_mut()) } @@ -172,11 +172,11 @@ impl ThreadLocal { self.user_ns.borrow() } - pub fn borrow_ns_proxy(&self) -> NsProxyRef { + pub fn borrow_ns_proxy(&self) -> NsProxyRef<'_> { ThreadLocalOptionRef(self.ns_proxy.borrow()) } - pub(in crate::process) fn borrow_ns_proxy_mut(&self) -> NsProxyRefMut { + pub(in crate::process) fn borrow_ns_proxy_mut(&self) -> NsProxyRefMut<'_> { ThreadLocalOptionRefMut(self.ns_proxy.borrow_mut()) } } diff --git a/kernel/src/process/process/mod.rs b/kernel/src/process/process/mod.rs index 8c83ffe9c..13d61e59d 100644 --- a/kernel/src/process/process/mod.rs +++ b/kernel/src/process/process/mod.rs @@ -615,7 +615,7 @@ impl Process { // ************** Virtual Memory ************* - pub fn lock_vmar(&self) -> ProcessVmarGuard { + pub fn lock_vmar(&self) -> ProcessVmarGuard<'_> { ProcessVmarGuard::new(self.vmar.lock()) } @@ -794,7 +794,7 @@ impl Process { /// a lock to prevent the cgroup from being changed. /// /// [`lock_cgroup_membership`]: crate::fs::cgroupfs::lock_cgroup_membership - pub fn cgroup(&self) -> RcuOptionReadGuard> { + pub fn cgroup(&self) -> RcuOptionReadGuard<'_, Arc> { self.cgroup.read() } diff --git a/kernel/src/process/process/process_group.rs b/kernel/src/process/process/process_group.rs index 429fcd796..438a86e7c 100644 --- a/kernel/src/process/process/process_group.rs +++ b/kernel/src/process/process/process_group.rs @@ -53,7 +53,7 @@ impl ProcessGroup { } /// Acquires a lock on the process group. - pub fn lock(&self) -> ProcessGroupGuard { + pub fn lock(&self) -> ProcessGroupGuard<'_> { ProcessGroupGuard { inner: self.inner.lock(), } @@ -82,7 +82,7 @@ pub struct ProcessGroupGuard<'a> { impl ProcessGroupGuard<'_> { /// Returns an iterator over the processes in the process group. - pub fn iter(&self) -> ProcessGroupIter { + pub fn iter(&self) -> ProcessGroupIter<'_> { ProcessGroupIter { inner: self.inner.processes.values(), } diff --git a/kernel/src/process/process/session.rs b/kernel/src/process/process/session.rs index e6f6ba451..92d91b4e7 100644 --- a/kernel/src/process/process/session.rs +++ b/kernel/src/process/process/session.rs @@ -70,7 +70,7 @@ impl Session { } /// Acquires a lock on the session. - pub fn lock(&self) -> SessionGuard { + pub fn lock(&self) -> SessionGuard<'_> { SessionGuard { inner: self.inner.lock(), } diff --git a/kernel/src/process/process_table.rs b/kernel/src/process/process_table.rs index 3dbde5e8d..0d05d7405 100644 --- a/kernel/src/process/process_table.rs +++ b/kernel/src/process/process_table.rs @@ -61,7 +61,7 @@ impl ProcessTable { } /// Returns an iterator over the processes in the table. - pub fn iter(&self) -> ProcessTableIter { + pub fn iter(&self) -> ProcessTableIter<'_> { ProcessTableIter { inner: self.inner.values(), } diff --git a/kernel/src/process/process_vm/mod.rs b/kernel/src/process/process_vm/mod.rs index 414e2fa2f..8730b6ab0 100644 --- a/kernel/src/process/process_vm/mod.rs +++ b/kernel/src/process/process_vm/mod.rs @@ -194,7 +194,7 @@ impl<'a> ProcessVmarGuard<'a> { /// the initial portion of the main stack of a process. /// /// Returns `None` if the process has exited and its VMAR has been dropped. - pub fn init_stack_reader(&self) -> Option { + pub fn init_stack_reader(&self) -> Option> { self.as_ref() .map(|vmar| vmar.process_vm().init_stack.reader(vmar)) } diff --git a/kernel/src/syscall/setxattr.rs b/kernel/src/syscall/setxattr.rs index 22138217b..e9d51439b 100644 --- a/kernel/src/syscall/setxattr.rs +++ b/kernel/src/syscall/setxattr.rs @@ -170,7 +170,7 @@ pub(super) fn read_xattr_name_cstr_from_user( }) } -pub(super) fn parse_xattr_name(name_str: &str) -> Result { +pub(super) fn parse_xattr_name(name_str: &str) -> Result> { if name_str.is_empty() || name_str.len() > XATTR_NAME_MAX_LEN { return_errno_with_message!(Errno::ERANGE, "xattr name empty or too long"); } diff --git a/kernel/src/util/ring_buffer.rs b/kernel/src/util/ring_buffer.rs index fee9705b9..186224453 100644 --- a/kernel/src/util/ring_buffer.rs +++ b/kernel/src/util/ring_buffer.rs @@ -618,11 +618,11 @@ mod test { assert!(prod.is_empty()); } - fn reader_from(buf: &[u8]) -> VmReader { + fn reader_from(buf: &[u8]) -> VmReader<'_> { VmReader::from(buf).to_fallible() } - fn writer_from(buf: &mut [u8]) -> VmWriter { + fn writer_from(buf: &mut [u8]) -> VmWriter<'_> { VmWriter::from(buf).to_fallible() } } diff --git a/kernel/src/vm/vmar/mod.rs b/kernel/src/vm/vmar/mod.rs index 1450eac7e..d89673da0 100644 --- a/kernel/src/vm/vmar/mod.rs +++ b/kernel/src/vm/vmar/mod.rs @@ -89,7 +89,7 @@ impl Vmar { /// ``` /// /// For more details on the available options, see `VmarMapOptions`. - pub fn new_map(&self, size: usize, perms: VmPerms) -> Result { + pub fn new_map(&self, size: usize, perms: VmPerms) -> Result> { Ok(VmarMapOptions::new(self, size, perms)) } diff --git a/osdk/deps/test-kernel/src/path.rs b/osdk/deps/test-kernel/src/path.rs index f8134884d..95e672133 100644 --- a/osdk/deps/test-kernel/src/path.rs +++ b/osdk/deps/test-kernel/src/path.rs @@ -88,7 +88,7 @@ impl KtestPath { true } - pub fn iter(&self) -> KtestPathIter { + pub fn iter(&self) -> KtestPathIter<'_> { self.path.iter() } } diff --git a/ostd/libs/linux-bzimage/setup/src/sync.rs b/ostd/libs/linux-bzimage/setup/src/sync.rs index 5e372b754..d3612acc3 100644 --- a/ostd/libs/linux-bzimage/setup/src/sync.rs +++ b/ostd/libs/linux-bzimage/setup/src/sync.rs @@ -21,7 +21,7 @@ impl Mutex { } /// Locks the mutex. - pub fn lock(&self) -> MutexGuard { + pub fn lock(&self) -> MutexGuard<'_, T> { self.0.borrow_mut() } } diff --git a/ostd/src/sync/mutex.rs b/ostd/src/sync/mutex.rs index 54732e477..9f7ae1ff1 100644 --- a/ostd/src/sync/mutex.rs +++ b/ostd/src/sync/mutex.rs @@ -32,12 +32,12 @@ impl Mutex { /// /// This method runs in a block way until the mutex can be acquired. #[track_caller] - pub fn lock(&self) -> MutexGuard { + pub fn lock(&self) -> MutexGuard<'_, T> { self.queue.wait_until(|| self.try_lock()) } /// Tries Acquire the mutex immedidately. - pub fn try_lock(&self) -> Option> { + pub fn try_lock(&self) -> Option> { // Cannot be reduced to `then_some`, or the possible dropping of the temporary // guard will cause an unexpected unlock. // SAFETY: The lock is successfully acquired when creating the guard. diff --git a/ostd/src/sync/rwarc.rs b/ostd/src/sync/rwarc.rs index f6448da46..36334360a 100644 --- a/ostd/src/sync/rwarc.rs +++ b/ostd/src/sync/rwarc.rs @@ -41,12 +41,12 @@ impl RwArc { } /// Acquires the read lock for immutable access. - pub fn read(&self) -> RwLockReadGuard { + pub fn read(&self) -> RwLockReadGuard<'_, T, PreemptDisabled> { self.0.data.read() } /// Acquires the write lock for mutable access. - pub fn write(&self) -> RwLockWriteGuard { + pub fn write(&self) -> RwLockWriteGuard<'_, T, PreemptDisabled> { self.0.data.write() } @@ -108,7 +108,7 @@ impl RwArc { impl RoArc { /// Acquires the read lock for immutable access. - pub fn read(&self) -> RwLockReadGuard { + pub fn read(&self) -> RwLockReadGuard<'_, T, PreemptDisabled> { self.0.data.read() } } diff --git a/ostd/src/sync/rwlock.rs b/ostd/src/sync/rwlock.rs index af5b81faf..2e88242b7 100644 --- a/ostd/src/sync/rwlock.rs +++ b/ostd/src/sync/rwlock.rs @@ -130,7 +130,7 @@ impl RwLock { /// upgrading upreaders present. There is no guarantee for the order /// in which other readers or writers waiting simultaneously will /// obtain the lock. - pub fn read(&self) -> RwLockReadGuard { + pub fn read(&self) -> RwLockReadGuard<'_, T, G> { loop { if let Some(readguard) = self.try_read() { return readguard; @@ -146,7 +146,7 @@ impl RwLock { /// upreaders or readers present. There is no guarantee for the order /// in which other readers or writers waiting simultaneously will /// obtain the lock. - pub fn write(&self) -> RwLockWriteGuard { + pub fn write(&self) -> RwLockWriteGuard<'_, T, G> { loop { if let Some(writeguard) = self.try_write() { return writeguard; @@ -166,7 +166,7 @@ impl RwLock { /// and reader do not differ before invoking the upgread method. However, /// only one upreader can exist at any time to avoid deadlock in the /// upgread method. - pub fn upread(&self) -> RwLockUpgradeableGuard { + pub fn upread(&self) -> RwLockUpgradeableGuard<'_, T, G> { loop { if let Some(guard) = self.try_upread() { return guard; @@ -179,7 +179,7 @@ impl RwLock { /// Attempts to acquire a read lock. /// /// This function will never spin-wait and will return immediately. - pub fn try_read(&self) -> Option> { + pub fn try_read(&self) -> Option> { let guard = G::read_guard(); let lock = self.lock.fetch_add(READER, Acquire); if lock & (WRITER | MAX_READER | BEING_UPGRADED) == 0 { @@ -193,7 +193,7 @@ impl RwLock { /// Attempts to acquire a write lock. /// /// This function will never spin-wait and will return immediately. - pub fn try_write(&self) -> Option> { + pub fn try_write(&self) -> Option> { let guard = G::guard(); if self .lock @@ -209,7 +209,7 @@ impl RwLock { /// Attempts to acquire an upread lock. /// /// This function will never spin-wait and will return immediately. - pub fn try_upread(&self) -> Option> { + pub fn try_upread(&self) -> Option> { let guard = G::guard(); let lock = self.lock.fetch_or(UPGRADEABLE_READER, Acquire) & (WRITER | UPGRADEABLE_READER); if lock == 0 { diff --git a/ostd/src/sync/rwmutex.rs b/ostd/src/sync/rwmutex.rs index 3f63c8c5b..1fd908252 100644 --- a/ostd/src/sync/rwmutex.rs +++ b/ostd/src/sync/rwmutex.rs @@ -121,7 +121,7 @@ impl RwMutex { /// order in which other concurrent readers or writers waiting simultaneously /// will acquire the mutex. #[track_caller] - pub fn read(&self) -> RwMutexReadGuard { + pub fn read(&self) -> RwMutexReadGuard<'_, T> { self.queue.wait_until(|| self.try_read()) } @@ -132,7 +132,7 @@ impl RwMutex { /// order in which other concurrent readers or writers waiting simultaneously /// will acquire the mutex. #[track_caller] - pub fn write(&self) -> RwMutexWriteGuard { + pub fn write(&self) -> RwMutexWriteGuard<'_, T> { self.queue.wait_until(|| self.try_write()) } @@ -147,14 +147,14 @@ impl RwMutex { /// only one upreader can exist at any time to avoid deadlock in the /// upgread method. #[track_caller] - pub fn upread(&self) -> RwMutexUpgradeableGuard { + pub fn upread(&self) -> RwMutexUpgradeableGuard<'_, T> { self.queue.wait_until(|| self.try_upread()) } /// Attempts to acquire a read mutex. /// /// This function will never sleep and will return immediately. - pub fn try_read(&self) -> Option> { + pub fn try_read(&self) -> Option> { let lock = self.lock.fetch_add(READER, Acquire); if lock & (WRITER | BEING_UPGRADED | MAX_READER) == 0 { Some(RwMutexReadGuard { inner: self }) @@ -167,7 +167,7 @@ impl RwMutex { /// Attempts to acquire a write mutex. /// /// This function will never sleep and will return immediately. - pub fn try_write(&self) -> Option> { + pub fn try_write(&self) -> Option> { if self .lock .compare_exchange(0, WRITER, Acquire, Relaxed) @@ -182,7 +182,7 @@ impl RwMutex { /// Attempts to acquire a upread mutex. /// /// This function will never sleep and will return immediately. - pub fn try_upread(&self) -> Option> { + pub fn try_upread(&self) -> Option> { let lock = self.lock.fetch_or(UPGRADEABLE_READER, Acquire) & (WRITER | UPGRADEABLE_READER); if lock == 0 { return Some(RwMutexUpgradeableGuard { inner: self }); diff --git a/ostd/src/util/range_alloc.rs b/ostd/src/util/range_alloc.rs index 09af7eaed..ba04e38f5 100644 --- a/ostd/src/util/range_alloc.rs +++ b/ostd/src/util/range_alloc.rs @@ -142,7 +142,7 @@ impl RangeAllocator { fn get_freelist_guard( &self, - ) -> SpinLockGuard>, PreemptDisabled> { + ) -> SpinLockGuard<'_, Option>, PreemptDisabled> { let mut lock_guard = self.freelist.lock(); if lock_guard.is_none() { let mut freelist: BTreeMap = BTreeMap::new();