maint: fix warnings related to new rustc

This commit is contained in:
2025-06-16 09:42:43 +03:00
parent 10d0b45371
commit a67841988f
33 changed files with 63 additions and 65 deletions
+1 -1
View File
@@ -93,7 +93,7 @@ fn locate_rsdp(st: &SystemTable<Boot>) -> Option<u64> {
fn boot_partition(
image: Handle,
bs: &BootServices,
) -> Result<ScopedProtocol<SimpleFileSystem>, Error> {
) -> Result<ScopedProtocol<'_, SimpleFileSystem>, Error> {
let loaded_image = bs.open_protocol_exclusive::<LoadedImage>(image)?;
let device_handle = loaded_image.device();
+1 -1
View File
@@ -66,7 +66,7 @@ impl MemoryDescriptorExt for MemoryDescriptor {
}
}
pub fn memory_map(bs: &BootServices) -> Result<MemoryMap, Error> {
pub fn memory_map(bs: &BootServices) -> Result<MemoryMap<'_>, Error> {
bs.memory_map(unsafe { &mut MMAP_BUFFER.data })
}
+2 -2
View File
@@ -42,7 +42,7 @@ impl<A: Architecture, T> Spinlock<A, T> {
}
}
pub fn lock(&self) -> SpinlockGuard<A, T> {
pub fn lock(&self) -> SpinlockGuard<'_, A, T> {
// Loop until the lock can be acquired
if LOCK_HACK.load(Ordering::Acquire) {
return SpinlockGuard { lock: self };
@@ -103,7 +103,7 @@ impl<A: Architecture, T> IrqSafeSpinlock<A, T> {
}
/// Attempts to acquire a lock. IRQs will be disabled until the lock is released.
pub fn lock(&self) -> IrqSafeSpinlockGuard<A, T> {
pub fn lock(&self) -> IrqSafeSpinlockGuard<'_, A, T> {
// Disable IRQs to avoid IRQ handler trying to acquire the same lock
let irq_guard = IrqGuard::acquire();
+1 -1
View File
@@ -235,7 +235,7 @@ impl AhciPort {
.await
}
async fn submit<C: AtaCommand>(&self, command: &C) -> Result<SubmittedCommand, AhciError> {
async fn submit<C: AtaCommand>(&self, command: &C) -> Result<SubmittedCommand<'_>, AhciError> {
if command.prd_count() > 2 {
log::warn!("TODO: AHCI doesn't like 3+ PRD transfers");
return Err(AhciError::RegionTooLarge);
+1 -1
View File
@@ -349,7 +349,7 @@ pub trait PciConfigurationSpace {
}
/// Returns an iterator over the PCI capabilities
fn capability_iter(&self) -> CapabilityIterator<Self> {
fn capability_iter(&self) -> CapabilityIterator<'_, Self> {
let status = PciStatusRegister::from_bits_retain(self.status());
let current = if status.contains(PciStatusRegister::CAPABILITIES_LIST) {
+1 -1
View File
@@ -166,7 +166,7 @@ impl UsbDeviceAccess {
pub fn read_current_configuration(
&self,
) -> IrqSafeRwLockReadGuard<Option<UsbConfigurationInfo>> {
) -> IrqSafeRwLockReadGuard<'_, Option<UsbConfigurationInfo>> {
self.current_configuration.read()
}
+2 -2
View File
@@ -127,7 +127,7 @@ impl<'a> DirentIter<'a> {
self.offset
}
pub fn next_record(&mut self) -> Option<Record<&[u8]>> {
pub fn next_record(&mut self) -> Option<Record<'_, &[u8]>> {
if self.offset + size_of::<Dirent>() > self.block.len() {
return None;
}
@@ -183,7 +183,7 @@ impl<'a> DirentIterMut<'a> {
Self { fs, block, offset }
}
pub fn next_record(&mut self) -> Option<Record<&mut [u8]>> {
pub fn next_record(&mut self) -> Option<Record<'_, &mut [u8]>> {
if self.offset + size_of::<Dirent>() > self.block.len() {
return None;
}
+1 -1
View File
@@ -1,4 +1,4 @@
#![feature(map_try_insert, let_chains, result_flattening)]
#![feature(map_try_insert, let_chains)]
#![allow(clippy::type_complexity, clippy::new_without_default)]
#![no_std]
@@ -15,7 +15,7 @@ enum OwnedAddress {
Anonymous(u64),
}
pub fn load_address(bytes: &[u8]) -> Result<LocalSocketAddress, Error> {
pub fn load_address(bytes: &[u8]) -> Result<LocalSocketAddress<'_>, Error> {
Ok(wire::from_slice(bytes)?)
}
@@ -76,7 +76,7 @@ pub fn write_ancillary(
}
impl OwnedAddress {
fn to_borrowed(&self) -> LocalSocketAddress {
fn to_borrowed(&self) -> LocalSocketAddress<'_> {
match self {
Self::Path(path) => LocalSocketAddress::Path(path.as_ref()),
Self::Anonymous(anon) => LocalSocketAddress::Anonymous(*anon),
@@ -70,7 +70,7 @@ impl TcpListener {
pub(super) fn poll_accept(
&self,
cx: &mut Context<'_>,
) -> Poll<IrqSafeSpinlockGuard<Vec<Arc<TcpStream>>>> {
) -> Poll<IrqSafeSpinlockGuard<'_, Vec<Arc<TcpStream>>>> {
let lock = self.pending_accept.lock();
self.accept_notify.register(cx.waker());
if !lock.is_empty() {
@@ -214,7 +214,7 @@ impl TcpStream {
pub(super) fn poll_receive(
&self,
cx: &mut Context<'_>,
) -> Poll<Result<IrqSafeRwLockWriteGuard<TcpConnection>, Error>> {
) -> Poll<Result<IrqSafeRwLockWriteGuard<'_, TcpConnection>, Error>> {
let lock = self.connection.write();
match lock.poll_receive(cx) {
Poll::Ready(Ok(())) => Poll::Ready(Ok(lock)),
+1 -1
View File
@@ -94,7 +94,7 @@ impl TransferRing {
})
}
pub fn transaction_builder(self: &Arc<Self>) -> Result<TransactionBuilder, UsbError> {
pub fn transaction_builder(self: &Arc<Self>) -> Result<TransactionBuilder<'_>, UsbError> {
if self.shutdown.load(Ordering::Acquire) {
return Err(UsbError::DeviceDisconnected);
}
@@ -40,7 +40,7 @@ impl Transport for PciTransport {
true
}
fn device_cfg(&self) -> Option<&DeviceMemoryIo<[u8]>> {
fn device_cfg(&self) -> Option<&DeviceMemoryIo<'_, [u8]>> {
Some(&self.device_cfg)
}
+1 -1
View File
@@ -161,7 +161,7 @@ impl<T: Transport + 'static> VirtioGpu<T> {
Ok(())
}
fn begin_command(&self) -> CommandExecution<T> {
fn begin_command(&self) -> CommandExecution<'_, T> {
CommandExecution {
transport: &self.transport,
control: &self.queues.get().control,
+3 -3
View File
@@ -78,7 +78,7 @@ impl<'a> DeviceTree<'a> {
}
/// Returns the root node of this device tree
pub fn root(&self) -> TNode {
pub fn root(&self) -> TNode<'_> {
self.index.root()
}
@@ -172,12 +172,12 @@ impl<'a> DeviceTree<'a> {
}
/// Returns an iterator over the memory regions specified by this device tree
pub fn memory_regions(&self) -> DeviceTreeMemoryRegionIter {
pub fn memory_regions(&self) -> DeviceTreeMemoryRegionIter<'_> {
DeviceTreeMemoryRegionIter::new(self)
}
/// Returns an iterator over the reserved memory regions specified by this device tree
pub fn reserved_regions(&self) -> DeviceTreeReservedRegionIter {
pub fn reserved_regions(&self) -> DeviceTreeReservedRegionIter<'_> {
DeviceTreeReservedRegionIter::new(self)
}
+1 -1
View File
@@ -524,7 +524,7 @@ impl<TA: TableAllocator> ProcessAddressSpace<TA> {
/// Same as [ProcessAddressSpace::translate], except the lock on the address space is held
/// until the resulting [TranslateGuard] is dropped.
pub fn translate_lock(&self, address: usize) -> Result<TranslateGuard<TA>, Error> {
pub fn translate_lock(&self, address: usize) -> Result<TranslateGuard<'_, TA>, Error> {
let guard = self.inner.lock();
let address = guard.table.translate(address).map(|e| e.0)?;
Ok(TranslateGuard {
+2 -2
View File
@@ -51,7 +51,7 @@ impl<K, V> LruCacheBucket<K, V> {
}
impl<K: Eq, V> LruCacheBucket<K, V> {
pub fn entry_mut(&mut self, key: &K) -> EntryMut<K, V> {
pub fn entry_mut(&mut self, key: &K) -> EntryMut<'_, K, V> {
let mut cursor = self.data.cursor_front_mut();
loop {
@@ -125,7 +125,7 @@ impl<K, V, H: BuildHasher> LruCache<K, V, H> {
.find_map(|bucket| bucket.pop_front())
}
pub fn flush(&mut self) -> FlushIter<K, V, H> {
pub fn flush(&mut self) -> FlushIter<'_, K, V, H> {
FlushIter { cache: self }
}
}
+6 -6
View File
@@ -203,7 +203,7 @@ impl<T: Copy> LossyRingQueue<T> {
}
#[inline]
pub fn try_read_lock(&self) -> Option<IrqSafeSpinlockGuard<RingBuffer<T>>> {
pub fn try_read_lock(&self) -> Option<IrqSafeSpinlockGuard<'_, RingBuffer<T>>> {
let lock = self.ring.lock();
lock.is_readable().then_some(lock)
}
@@ -214,12 +214,12 @@ impl<T: Copy> LossyRingQueue<T> {
unsafe { lock.read_single_unchecked() }
}
pub async fn read_lock(&self) -> IrqSafeSpinlockGuard<RingBuffer<T>> {
pub async fn read_lock(&self) -> IrqSafeSpinlockGuard<'_, RingBuffer<T>> {
poll_fn(|cx| self.poll_lock(cx)).await
}
#[inline]
pub fn poll_lock(&self, cx: &mut Context<'_>) -> Poll<IrqSafeSpinlockGuard<RingBuffer<T>>> {
pub fn poll_lock(&self, cx: &mut Context<'_>) -> Poll<IrqSafeSpinlockGuard<'_, RingBuffer<T>>> {
self.read_notify.register(cx.waker());
if let Some(lock) = self.try_read_lock() {
self.read_notify.remove(cx.waker());
@@ -284,7 +284,7 @@ impl<T: Copy> BlockingRingQueue<T> {
true
}
pub async fn read_lock(&self) -> IrqSafeSpinlockGuard<RingBuffer<T>> {
pub async fn read_lock(&self) -> IrqSafeSpinlockGuard<'_, RingBuffer<T>> {
poll_fn(|cx| self.poll_read_lock(cx)).await
}
@@ -292,7 +292,7 @@ impl<T: Copy> BlockingRingQueue<T> {
pub fn poll_read_lock(
&self,
cx: &mut Context<'_>,
) -> Poll<IrqSafeSpinlockGuard<RingBuffer<T>>> {
) -> Poll<IrqSafeSpinlockGuard<'_, RingBuffer<T>>> {
if let Some(lock) = self.try_read_lock() {
self.read_notify.remove(cx.waker());
Poll::Ready(lock)
@@ -303,7 +303,7 @@ impl<T: Copy> BlockingRingQueue<T> {
}
#[inline]
pub fn try_read_lock(&self) -> Option<IrqSafeSpinlockGuard<RingBuffer<T>>> {
pub fn try_read_lock(&self) -> Option<IrqSafeSpinlockGuard<'_, RingBuffer<T>>> {
let lock = self.ring.lock();
lock.is_readable().then_some(lock)
}
+1 -1
View File
@@ -28,7 +28,7 @@ impl Utf16LeStr {
core::mem::transmute(raw)
}
pub fn chars(&self) -> Utf16LeIter {
pub fn chars(&self) -> Utf16LeIter<'_> {
Utf16LeIter {
chars: self.raw.chunks_exact(size_of::<u16>()),
}
@@ -131,7 +131,7 @@ impl<T> IrqSafeRwLock<T> {
}
}
pub fn read(&self) -> IrqSafeRwLockReadGuard<T> {
pub fn read(&self) -> IrqSafeRwLockReadGuard<'_, T> {
let guard = IrqGuard::acquire();
self.inner.acquire_read();
IrqSafeRwLockReadGuard {
@@ -140,7 +140,7 @@ impl<T> IrqSafeRwLock<T> {
}
}
pub fn write(&self) -> IrqSafeRwLockWriteGuard<T> {
pub fn write(&self) -> IrqSafeRwLockWriteGuard<'_, T> {
let guard = IrqGuard::acquire();
self.inner.acquire_write();
IrqSafeRwLockWriteGuard {
+1 -1
View File
@@ -284,7 +284,7 @@ impl ConsoleBuffer {
}
/// Returns an iterator over dirty rows, while clearing dirty flag for them
pub fn flush_rows(&mut self) -> RowIter {
pub fn flush_rows(&mut self) -> RowIter<'_> {
RowIter {
buffer: self,
index: 0,
+2 -2
View File
@@ -198,7 +198,7 @@ impl<T> DmaBuffer<[T]> {
assert!(range.start <= range.end, "Invalid DMA slice range");
}
pub fn slice(&self, range: Range<usize>) -> DmaSlice<T> {
pub fn slice(&self, range: Range<usize>) -> DmaSlice<'_, T> {
self.slice_range_check(&range);
DmaSlice {
buffer: self,
@@ -206,7 +206,7 @@ impl<T> DmaBuffer<[T]> {
}
}
pub fn slice_mut(&mut self, range: Range<usize>) -> DmaSliceMut<T> {
pub fn slice_mut(&mut self, range: Range<usize>) -> DmaSliceMut<'_, T> {
self.slice_range_check(&range);
DmaSliceMut {
buffer: self,
-1
View File
@@ -18,7 +18,6 @@
arbitrary_self_types,
slice_split_once,
arbitrary_self_types_pointers,
result_flattening,
negative_impls,
decl_macro,
optimize_attribute
+3 -1
View File
@@ -464,7 +464,9 @@ impl Process {
}
}
fn poll_any_child_exit(&self) -> Option<(Arc<Process>, IrqSafeRwLockWriteGuard<ProcessInner>)> {
fn poll_any_child_exit(
&self,
) -> Option<(Arc<Process>, IrqSafeRwLockWriteGuard<'_, ProcessInner>)> {
let read = self.inner.read();
if let Some(child) = read.any_exited_child() {
let write = IrqSafeRwLockReadGuard::upgrade(read);
+2 -2
View File
@@ -59,7 +59,7 @@ impl<T> AsyncMutex<T> {
.is_ok()
}
pub fn poll_lock(&self, cx: &mut Context<'_>) -> Poll<AsyncMutexGuard<T>> {
pub fn poll_lock(&self, cx: &mut Context<'_>) -> Poll<AsyncMutexGuard<'_, T>> {
self.waker.register(cx.waker());
if self.try_lock() {
@@ -70,7 +70,7 @@ impl<T> AsyncMutex<T> {
Poll::Pending
}
pub async fn lock(&self) -> AsyncMutexGuard<T> {
pub async fn lock(&self) -> AsyncMutexGuard<'_, T> {
poll_fn(|cx| self.poll_lock(cx)).await
}
+1 -1
View File
@@ -552,7 +552,7 @@ impl Thread {
self.enqueue();
}
pub fn hold_suspended(&self) -> Result<SuspendGuard, Error> {
pub fn hold_suspended(&self) -> Result<SuspendGuard<'_>, Error> {
let sched = self.sched.lock();
if sched.state == ThreadState::Running {
return Err(Error::InvalidOperation);
+3 -1
View File
@@ -23,7 +23,9 @@ pub enum FilesystemMountOption<'a> {
FsSpecific(&'a str),
}
pub fn parse_mount_options(options: Option<&str>) -> impl Iterator<Item = FilesystemMountOption> {
pub fn parse_mount_options(
options: Option<&str>,
) -> impl Iterator<Item = FilesystemMountOption<'_>> {
options
.unwrap_or("")
.trim()
+1
View File
@@ -9,6 +9,7 @@
generic_const_exprs,
maybe_uninit_array_assume_init
)]
#![allow(stable_features)] // TODO sync userspace rustc with cross-rustc
#![no_std]
#![warn(missing_docs)]
#![allow(nonstandard_style, clippy::new_without_default, incomplete_features)]
@@ -1,11 +1,18 @@
use core::ffi::c_int;
pub type __jmp_buf = [usize; 8];
pub type __sigjmp_buf = [usize; 8];
// TODO
#[no_mangle]
#[unsafe(naked)]
unsafe extern "C" fn sigsetjmp(buf: *mut __sigjmp_buf, savesigs: c_int) -> c_int {
// TODO: I don't yet have signal masking
core::arch::naked_asm!("j setjmp")
}
#[no_mangle]
#[naked]
#[unsafe(naked)]
unsafe extern "C" fn setjmp(buf: *mut __jmp_buf) -> c_int {
core::arch::naked_asm!(
r#"
@@ -15,13 +22,13 @@ unsafe extern "C" fn setjmp(buf: *mut __jmp_buf) -> c_int {
}
#[no_mangle]
#[naked]
#[unsafe(naked)]
unsafe extern "C" fn _setjmp(buf: *mut __jmp_buf) -> c_int {
core::arch::naked_asm!("j .");
}
#[no_mangle]
#[naked]
#[unsafe(naked)]
unsafe extern "C" fn longjmp(buf: *mut __jmp_buf, val: c_int) -> c_int {
core::arch::naked_asm!(
r#"
@@ -31,7 +38,13 @@ unsafe extern "C" fn longjmp(buf: *mut __jmp_buf, val: c_int) -> c_int {
}
#[no_mangle]
#[naked]
#[unsafe(naked)]
unsafe extern "C" fn siglongjmp(buf: *mut __sigjmp_buf, val: c_int) -> ! {
core::arch::naked_asm!("j longjmp")
}
#[no_mangle]
#[unsafe(naked)]
unsafe extern "C" fn _longjmp(buf: *mut __jmp_buf, val: c_int) -> c_int {
core::arch::naked_asm!("j .")
}
@@ -1,7 +1,6 @@
use core::{
ffi::{
c_char, c_double, c_int, c_long, c_longlong, c_short, c_uchar, c_uint, c_ulong,
c_ulonglong, c_ushort, CStr, VaList,
c_char, c_double, c_int, c_long, c_longlong, c_uint, c_ulong, c_ulonglong, CStr, VaList,
},
fmt,
};
@@ -142,8 +142,6 @@ enum Radix {
trait StrToInt {
type Unsigned: StrToUint;
const ZERO: Self;
fn from_unsigned(value: Self::Unsigned, sign: bool) -> Self;
}
@@ -173,7 +171,6 @@ impl Radix {
impl StrToInt for i32 {
type Unsigned = u32;
const ZERO: Self = 0;
fn from_unsigned(value: Self::Unsigned, sign: bool) -> Self {
match sign {
@@ -185,7 +182,6 @@ impl StrToInt for i32 {
impl StrToInt for i64 {
type Unsigned = u64;
const ZERO: Self = 0;
fn from_unsigned(value: Self::Unsigned, sign: bool) -> Self {
match sign {
-12
View File
@@ -29,7 +29,6 @@ pub trait FileWriter: Write {
fn is_line_buffered(&self) -> bool;
fn capacity(&self) -> usize;
fn pending_bytes(&self) -> usize;
fn reset(&mut self);
}
pub struct UnbufferedWriter<W: Write> {
@@ -131,8 +130,6 @@ impl<W: Write> Write for UnbufferedWriter<W> {
}
impl<W: Write> FileWriter for UnbufferedWriter<W> {
fn reset(&mut self) {}
fn pending_bytes(&self) -> usize {
0
}
@@ -192,10 +189,6 @@ impl<W: Write> Write for FullBufferedWriter<W> {
}
impl<W: Write> FileWriter for FullBufferedWriter<W> {
fn reset(&mut self) {
self.buffer.clear();
}
fn pending_bytes(&self) -> usize {
self.buffer.len()
}
@@ -249,11 +242,6 @@ impl<W: Write> Write for LineBufferedWriter<W> {
}
impl<W: Write> FileWriter for LineBufferedWriter<W> {
fn reset(&mut self) {
self.inner.reset();
self.need_flush = false;
}
fn pending_bytes(&self) -> usize {
self.inner.pending_bytes()
}
-2
View File
@@ -8,8 +8,6 @@
slice_internals,
linkage,
rustc_private,
naked_functions,
non_null_from_ref,
thread_local,
let_chains,
int_roundings,