Skip to content

Commit 9da4f71

Browse files
committed
rust: deny rust_2018_idioms warnings
Signed-off-by: Gary Guo <[email protected]>
1 parent d9d49cb commit 9da4f71

File tree

6 files changed

+7
-6
lines changed

6 files changed

+7
-6
lines changed

rust/kernel/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#![deny(clippy::correctness)]
2828
#![deny(clippy::perf)]
2929
#![deny(clippy::style)]
30+
#![deny(rust_2018_idioms)]
3031

3132
// Ensure conditional compilation based on the kernel configuration works;
3233
// otherwise we may silently break things like initcall handling.

rust/kernel/pages.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ impl<const ORDER: u32> Pages<ORDER> {
132132
}
133133

134134
/// Maps the page at index `index`.
135-
fn kmap(&self, index: usize) -> Option<PageMapping> {
135+
fn kmap(&self, index: usize) -> Option<PageMapping<'_>> {
136136
if index >= 1usize << ORDER {
137137
return None;
138138
}

rust/kernel/sync/condvar.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ impl CondVar {
6565
///
6666
/// Returns whether there is a signal pending.
6767
#[must_use = "wait returns if a signal is pending, so the caller must check the return value"]
68-
pub fn wait<L: Lock>(&self, guard: &mut Guard<L>) -> bool {
68+
pub fn wait<L: Lock>(&self, guard: &mut Guard<'_, L>) -> bool {
6969
let lock = guard.lock;
7070
let mut wait = MaybeUninit::<bindings::wait_queue_entry>::uninit();
7171

rust/kernel/sync/locked_by.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<T, L: Lock + ?Sized> LockedBy<T, L> {
7878
impl<T: ?Sized, L: Lock + ?Sized> LockedBy<T, L> {
7979
/// Returns a reference to the protected data when the caller provides evidence (via a
8080
/// [`Guard`]) that the owner is locked.
81-
pub fn access<'a>(&'a self, guard: &'a Guard<L>) -> &'a T {
81+
pub fn access<'a>(&'a self, guard: &'a Guard<'_, L>) -> &'a T {
8282
if !ptr::eq(guard.deref(), self.owner) {
8383
panic!("guard does not match owner");
8484
}
@@ -89,7 +89,7 @@ impl<T: ?Sized, L: Lock + ?Sized> LockedBy<T, L> {
8989

9090
/// Returns a mutable reference to the protected data when the caller provides evidence (via a
9191
/// mutable [`Guard`]) that the owner is locked mutably.
92-
pub fn access_mut<'a>(&'a self, guard: &'a mut Guard<L>) -> &'a mut T {
92+
pub fn access_mut<'a>(&'a self, guard: &'a mut Guard<'_, L>) -> &'a mut T {
9393
if !ptr::eq(guard.deref().deref(), self.owner) {
9494
panic!("guard does not match owner");
9595
}

rust/kernel/sync/mutex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ impl<T> Mutex<T> {
6464
impl<T: ?Sized> Mutex<T> {
6565
/// Locks the mutex and gives the caller access to the data protected by it. Only one thread at
6666
/// a time is allowed to access the protected data.
67-
pub fn lock(&self) -> Guard<Self> {
67+
pub fn lock(&self) -> Guard<'_, Self> {
6868
self.lock_noguard();
6969
// SAFETY: The mutex was just acquired.
7070
unsafe { Guard::new(self) }

rust/kernel/sync/spinlock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ impl<T> SpinLock<T> {
7878
impl<T: ?Sized> SpinLock<T> {
7979
/// Locks the spinlock and gives the caller access to the data protected by it. Only one thread
8080
/// at a time is allowed to access the protected data.
81-
pub fn lock(&self) -> Guard<Self> {
81+
pub fn lock(&self) -> Guard<'_, Self> {
8282
self.lock_noguard();
8383
// SAFETY: The spinlock was just acquired.
8484
unsafe { Guard::new(self) }

0 commit comments

Comments
 (0)