Fix elided lifetimes in return values

This commit is contained in:
Zhang Junyang 2025-12-08 21:46:45 +08:00 committed by Tate, Hongliang Tian
parent ad6b5ed856
commit 559ce94aba
38 changed files with 62 additions and 62 deletions

View File

@ -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<BitmapChar> {
pub fn char(&self, ch: u8) -> Option<BitmapChar<'_>> {
let pos = (ch as usize) * self.char_size;
let data = self.bitmap.get(pos..pos + self.char_size)?;

View File

@ -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,

View File

@ -136,7 +136,7 @@ impl<K: RecordKey<K>, V: RecordValue> MemTableManager<K, V> {
}
/// Gets the immutable `MemTable` instance (read-only).
pub fn immutable_memtable(&self) -> RwLockReadGuard<MemTable<K, V>> {
pub fn immutable_memtable(&self) -> RwLockReadGuard<'_, MemTable<K, V>> {
self.immutable.read()
}
}

View File

@ -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<HashMap<TypeId, Box<dyn Any + Send + Sync>>> {
pub fn ext(&self) -> MutexGuard<'_, HashMap<TypeId, Box<dyn Any + Send + Sync>>> {
self.ext.lock()
}

View File

@ -28,7 +28,7 @@ impl<E: Ext> PollableIface<E> {
}
}
pub(super) fn as_mut(&mut self) -> PollableIfaceMut<E> {
pub(super) fn as_mut(&mut self) -> PollableIfaceMut<'_, E> {
PollableIfaceMut {
context: self.interface.context(),
pending_conns: &mut self.pending_conns,

View File

@ -244,7 +244,7 @@ impl<E: Ext> TcpConnectionInner<E> {
}
}
pub(super) fn lock(&self) -> SpinLockGuard<RawTcpSocketExt<E>, BottomHalfDisabled> {
pub(super) fn lock(&self) -> SpinLockGuard<'_, RawTcpSocketExt<E>, BottomHalfDisabled> {
self.socket.lock()
}
}

View File

@ -96,7 +96,7 @@ impl TypeFlagDef {
}
/// return the items iter
pub fn items_iter(&self) -> syn::punctuated::Iter<TypeFlagItem> {
pub fn items_iter(&self) -> syn::punctuated::Iter<'_, TypeFlagItem> {
self.items.iter()
}

View File

@ -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)
}

View File

@ -133,7 +133,7 @@ impl<P: NonNullPtr + Send + Sync, M> XArray<P, M> {
}
/// Acquires the lock to perform mutable operations.
pub fn lock(&self) -> LockedXArray<P, M> {
pub fn lock(&self) -> LockedXArray<'_, P, M> {
LockedXArray {
xa: self,
guard: self.xlock.lock(),
@ -142,7 +142,7 @@ impl<P: NonNullPtr + Send + Sync, M> XArray<P, M> {
}
/// Acquires the lock with local IRQs disabled to perform mutable operations.
pub fn lock_irq_disabled(&self) -> LockedXArray<P, M, LocalIrqDisabled> {
pub fn lock_irq_disabled(&self) -> LockedXArray<'_, P, M, LocalIrqDisabled> {
LockedXArray {
xa: self,
guard: self.xlock.disable_irq().lock(),

View File

@ -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())
}
}

View File

@ -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,

View File

@ -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(),

View File

@ -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()
}

View File

@ -131,7 +131,7 @@ impl Ext2 {
}
/// Returns the super block.
pub fn super_block(&self) -> RwMutexReadGuard<Dirty<SuperBlock>> {
pub fn super_block(&self) -> RwMutexReadGuard<'_, Dirty<SuperBlock>> {
self.super_block.read()
}

View File

@ -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()
}
}

View File

@ -509,7 +509,7 @@ impl dyn Inode {
(self as &dyn Any).downcast_ref::<T>()
}
pub fn writer(&self, from_offset: usize) -> InodeWriter {
pub fn writer(&self, from_offset: usize) -> InodeWriter<'_> {
InodeWriter {
inner: self,
offset: from_offset,

View File

@ -61,7 +61,7 @@ pub(super) struct PendingOp {
}
impl PendingOp {
pub(super) fn sops_iter(&self) -> Iter<SemBuf> {
pub(super) fn sops_iter(&self) -> Iter<'_, SemBuf> {
self.sops.iter()
}

View File

@ -199,7 +199,7 @@ impl SemaphoreSet {
);
}
pub(super) fn inner(&self) -> SpinLockGuard<SemSetInner, PreemptDisabled> {
pub(super) fn inner(&self) -> SpinLockGuard<'_, SemSetInner, PreemptDisabled> {
self.inner.lock()
}

View File

@ -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<Takeable<State>, PreemptDisabled> {
fn read_updated_state(&self) -> RwLockReadGuard<'_, Takeable<State>, 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<Takeable<State>, PreemptDisabled> {
fn write_updated_state(&self) -> RwLockWriteGuard<'_, Takeable<State>, PreemptDisabled> {
let mut state = self.state.write();
match state.as_ref() {

View File

@ -482,11 +482,11 @@ impl Credentials_ {
// ******* Supplementary groups methods *******
pub(super) fn groups(&self) -> RwLockReadGuard<BTreeSet<Gid>, PreemptDisabled> {
pub(super) fn groups(&self) -> RwLockReadGuard<'_, BTreeSet<Gid>, PreemptDisabled> {
self.supplementary_gids.read()
}
pub(super) fn groups_mut(&self) -> RwLockWriteGuard<BTreeSet<Gid>, PreemptDisabled> {
pub(super) fn groups_mut(&self) -> RwLockWriteGuard<'_, BTreeSet<Gid>, PreemptDisabled> {
self.supplementary_gids.write()
}

View File

@ -276,7 +276,7 @@ impl<R: TRights> Credentials<R> {
///
/// This method requires the `Read` right.
#[require(R > Read)]
pub fn groups(&self) -> RwLockReadGuard<BTreeSet<Gid>, PreemptDisabled> {
pub fn groups(&self) -> RwLockReadGuard<'_, BTreeSet<Gid>, PreemptDisabled> {
self.0.groups()
}
@ -284,7 +284,7 @@ impl<R: TRights> Credentials<R> {
///
/// This method requires the `Write` right.
#[require(R > Write)]
pub fn groups_mut(&self) -> RwLockWriteGuard<BTreeSet<Gid>, PreemptDisabled> {
pub fn groups_mut(&self) -> RwLockWriteGuard<'_, BTreeSet<Gid>, PreemptDisabled> {
self.0.groups_mut()
}

View File

@ -114,7 +114,7 @@ impl PosixThread {
}
/// Returns a read guard to the filesystem information of the thread.
pub fn read_fs(&self) -> RwMutexReadGuard<Arc<ThreadFsInfo>> {
pub fn read_fs(&self) -> RwMutexReadGuard<'_, Arc<ThreadFsInfo>> {
self.fs.read()
}

View File

@ -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())
}
}

View File

@ -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<Arc<CgroupNode>> {
pub fn cgroup(&self) -> RcuOptionReadGuard<'_, Arc<CgroupNode>> {
self.cgroup.read()
}

View File

@ -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(),
}

View File

@ -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(),
}

View File

@ -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(),
}

View File

@ -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<InitStackReader> {
pub fn init_stack_reader(&self) -> Option<InitStackReader<'_>> {
self.as_ref()
.map(|vmar| vmar.process_vm().init_stack.reader(vmar))
}

View File

@ -170,7 +170,7 @@ pub(super) fn read_xattr_name_cstr_from_user(
})
}
pub(super) fn parse_xattr_name(name_str: &str) -> Result<XattrName> {
pub(super) fn parse_xattr_name(name_str: &str) -> Result<XattrName<'_>> {
if name_str.is_empty() || name_str.len() > XATTR_NAME_MAX_LEN {
return_errno_with_message!(Errno::ERANGE, "xattr name empty or too long");
}

View File

@ -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()
}
}

View File

@ -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<VmarMapOptions> {
pub fn new_map(&self, size: usize, perms: VmPerms) -> Result<VmarMapOptions<'_>> {
Ok(VmarMapOptions::new(self, size, perms))
}

View File

@ -88,7 +88,7 @@ impl KtestPath {
true
}
pub fn iter(&self) -> KtestPathIter {
pub fn iter(&self) -> KtestPathIter<'_> {
self.path.iter()
}
}

View File

@ -21,7 +21,7 @@ impl<T> Mutex<T> {
}
/// Locks the mutex.
pub fn lock(&self) -> MutexGuard<T> {
pub fn lock(&self) -> MutexGuard<'_, T> {
self.0.borrow_mut()
}
}

View File

@ -32,12 +32,12 @@ impl<T: ?Sized> Mutex<T> {
///
/// This method runs in a block way until the mutex can be acquired.
#[track_caller]
pub fn lock(&self) -> MutexGuard<T> {
pub fn lock(&self) -> MutexGuard<'_, T> {
self.queue.wait_until(|| self.try_lock())
}
/// Tries Acquire the mutex immedidately.
pub fn try_lock(&self) -> Option<MutexGuard<T>> {
pub fn try_lock(&self) -> Option<MutexGuard<'_, T>> {
// 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.

View File

@ -41,12 +41,12 @@ impl<T> RwArc<T> {
}
/// Acquires the read lock for immutable access.
pub fn read(&self) -> RwLockReadGuard<T, PreemptDisabled> {
pub fn read(&self) -> RwLockReadGuard<'_, T, PreemptDisabled> {
self.0.data.read()
}
/// Acquires the write lock for mutable access.
pub fn write(&self) -> RwLockWriteGuard<T, PreemptDisabled> {
pub fn write(&self) -> RwLockWriteGuard<'_, T, PreemptDisabled> {
self.0.data.write()
}
@ -108,7 +108,7 @@ impl<T: Clone> RwArc<T> {
impl<T> RoArc<T> {
/// Acquires the read lock for immutable access.
pub fn read(&self) -> RwLockReadGuard<T, PreemptDisabled> {
pub fn read(&self) -> RwLockReadGuard<'_, T, PreemptDisabled> {
self.0.data.read()
}
}

View File

@ -130,7 +130,7 @@ impl<T: ?Sized, G: SpinGuardian> RwLock<T, G> {
/// 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<T, G> {
pub fn read(&self) -> RwLockReadGuard<'_, T, G> {
loop {
if let Some(readguard) = self.try_read() {
return readguard;
@ -146,7 +146,7 @@ impl<T: ?Sized, G: SpinGuardian> RwLock<T, G> {
/// 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<T, G> {
pub fn write(&self) -> RwLockWriteGuard<'_, T, G> {
loop {
if let Some(writeguard) = self.try_write() {
return writeguard;
@ -166,7 +166,7 @@ impl<T: ?Sized, G: SpinGuardian> RwLock<T, G> {
/// 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<T, G> {
pub fn upread(&self) -> RwLockUpgradeableGuard<'_, T, G> {
loop {
if let Some(guard) = self.try_upread() {
return guard;
@ -179,7 +179,7 @@ impl<T: ?Sized, G: SpinGuardian> RwLock<T, G> {
/// Attempts to acquire a read lock.
///
/// This function will never spin-wait and will return immediately.
pub fn try_read(&self) -> Option<RwLockReadGuard<T, G>> {
pub fn try_read(&self) -> Option<RwLockReadGuard<'_, T, G>> {
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<T: ?Sized, G: SpinGuardian> RwLock<T, G> {
/// Attempts to acquire a write lock.
///
/// This function will never spin-wait and will return immediately.
pub fn try_write(&self) -> Option<RwLockWriteGuard<T, G>> {
pub fn try_write(&self) -> Option<RwLockWriteGuard<'_, T, G>> {
let guard = G::guard();
if self
.lock
@ -209,7 +209,7 @@ impl<T: ?Sized, G: SpinGuardian> RwLock<T, G> {
/// Attempts to acquire an upread lock.
///
/// This function will never spin-wait and will return immediately.
pub fn try_upread(&self) -> Option<RwLockUpgradeableGuard<T, G>> {
pub fn try_upread(&self) -> Option<RwLockUpgradeableGuard<'_, T, G>> {
let guard = G::guard();
let lock = self.lock.fetch_or(UPGRADEABLE_READER, Acquire) & (WRITER | UPGRADEABLE_READER);
if lock == 0 {

View File

@ -121,7 +121,7 @@ impl<T: ?Sized> RwMutex<T> {
/// order in which other concurrent readers or writers waiting simultaneously
/// will acquire the mutex.
#[track_caller]
pub fn read(&self) -> RwMutexReadGuard<T> {
pub fn read(&self) -> RwMutexReadGuard<'_, T> {
self.queue.wait_until(|| self.try_read())
}
@ -132,7 +132,7 @@ impl<T: ?Sized> RwMutex<T> {
/// order in which other concurrent readers or writers waiting simultaneously
/// will acquire the mutex.
#[track_caller]
pub fn write(&self) -> RwMutexWriteGuard<T> {
pub fn write(&self) -> RwMutexWriteGuard<'_, T> {
self.queue.wait_until(|| self.try_write())
}
@ -147,14 +147,14 @@ impl<T: ?Sized> RwMutex<T> {
/// only one upreader can exist at any time to avoid deadlock in the
/// upgread method.
#[track_caller]
pub fn upread(&self) -> RwMutexUpgradeableGuard<T> {
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<RwMutexReadGuard<T>> {
pub fn try_read(&self) -> Option<RwMutexReadGuard<'_, T>> {
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<T: ?Sized> RwMutex<T> {
/// Attempts to acquire a write mutex.
///
/// This function will never sleep and will return immediately.
pub fn try_write(&self) -> Option<RwMutexWriteGuard<T>> {
pub fn try_write(&self) -> Option<RwMutexWriteGuard<'_, T>> {
if self
.lock
.compare_exchange(0, WRITER, Acquire, Relaxed)
@ -182,7 +182,7 @@ impl<T: ?Sized> RwMutex<T> {
/// Attempts to acquire a upread mutex.
///
/// This function will never sleep and will return immediately.
pub fn try_upread(&self) -> Option<RwMutexUpgradeableGuard<T>> {
pub fn try_upread(&self) -> Option<RwMutexUpgradeableGuard<'_, T>> {
let lock = self.lock.fetch_or(UPGRADEABLE_READER, Acquire) & (WRITER | UPGRADEABLE_READER);
if lock == 0 {
return Some(RwMutexUpgradeableGuard { inner: self });

View File

@ -142,7 +142,7 @@ impl RangeAllocator {
fn get_freelist_guard(
&self,
) -> SpinLockGuard<Option<BTreeMap<usize, FreeRange>>, PreemptDisabled> {
) -> SpinLockGuard<'_, Option<BTreeMap<usize, FreeRange>>, PreemptDisabled> {
let mut lock_guard = self.freelist.lock();
if lock_guard.is_none() {
let mut freelist: BTreeMap<usize, FreeRange> = BTreeMap::new();