From a9f8c4a2f3008f1e17329a487e69817387083161 Mon Sep 17 00:00:00 2001 From: Wedson Almeida Filho Date: Fri, 26 Nov 2021 22:30:17 +0000 Subject: [PATCH] rust: add `?Sized` bound to revocable wrapped type. It is not required to be sized anyway. Signed-off-by: Wedson Almeida Filho --- rust/kernel/revocable.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/rust/kernel/revocable.rs b/rust/kernel/revocable.rs index 0e77df848b7686..9cc65ca3a1b638 100644 --- a/rust/kernel/revocable.rs +++ b/rust/kernel/revocable.rs @@ -65,7 +65,9 @@ impl Revocable { data: ManuallyDrop::new(UnsafeCell::new(data)), } } +} +impl Revocable { /// Tries to access the \[revocable\] wrapped object. /// /// Returns `None` if the object has been revoked and is therefore no longer accessible. @@ -125,12 +127,12 @@ impl Drop for Revocable { /// # Invariants /// /// The RCU read-side lock is held while the guard is alive. -pub struct RevocableGuard<'a, T> { +pub struct RevocableGuard<'a, T: ?Sized> { data_ref: *const T, _p: PhantomData<&'a ()>, } -impl RevocableGuard<'_, T> { +impl RevocableGuard<'_, T> { fn new(data_ref: *const T) -> Self { // SAFETY: Just an FFI call, there are no further requirements. unsafe { bindings::rcu_read_lock() }; @@ -143,14 +145,14 @@ impl RevocableGuard<'_, T> { } } -impl Drop for RevocableGuard<'_, T> { +impl Drop for RevocableGuard<'_, T> { fn drop(&mut self) { // SAFETY: By the type invariants, we know that we hold the RCU read-side lock. unsafe { bindings::rcu_read_unlock() }; } } -impl Deref for RevocableGuard<'_, T> { +impl Deref for RevocableGuard<'_, T> { type Target = T; fn deref(&self) -> &Self::Target {