Skip to content

Commit b2516f7

Browse files
nbdd0121ojeda
authored andcommitted
rust: kernel: remove #[allow(clippy::new_ret_no_self)]
Clippy triggered a false positive on its `new_ret_no_self` lint when using the `pin_init!` macro. Since Rust 1.67.0, that does not happen anymore, since Clippy learnt to not warn about `-> impl Trait<Self>` [1][2]. The kernel nowadays uses Rust 1.72.1, thus remove the `#[allow]`. Signed-off-by: Gary Guo <[email protected]> Reviewed-by: Alice Ryhl <[email protected]> Reviewed-by: Benno Lossin <[email protected]> Reviewed-by: Finn Behrens <[email protected]> Reviewed-by: Martin Rodriguez Reboredo <[email protected]> Link: rust-lang/rust-clippy#7344 [1] Link: rust-lang/rust-clippy#9733 [2] Link: https://lore.kernel.org/r/[email protected] [ Reworded slightly and added a couple `Link`s. ] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent fc388be commit b2516f7

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

rust/kernel/init.rs

+10-10
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
//! that you need to write `<-` instead of `:` for fields that you want to initialize in-place.
3636
//!
3737
//! ```rust
38-
//! # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
38+
//! # #![allow(clippy::disallowed_names)]
3939
//! use kernel::{prelude::*, sync::Mutex, new_mutex};
4040
//! # use core::pin::Pin;
4141
//! #[pin_data]
@@ -55,7 +55,7 @@
5555
//! (or just the stack) to actually initialize a `Foo`:
5656
//!
5757
//! ```rust
58-
//! # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
58+
//! # #![allow(clippy::disallowed_names)]
5959
//! # use kernel::{prelude::*, sync::Mutex, new_mutex};
6060
//! # use core::pin::Pin;
6161
//! # #[pin_data]
@@ -86,7 +86,7 @@
8686
//! To declare an init macro/function you just return an [`impl PinInit<T, E>`]:
8787
//!
8888
//! ```rust
89-
//! # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
89+
//! # #![allow(clippy::disallowed_names)]
9090
//! # use kernel::{sync::Mutex, prelude::*, new_mutex, init::PinInit, try_pin_init};
9191
//! #[pin_data]
9292
//! struct DriverData {
@@ -236,7 +236,7 @@ pub mod macros;
236236
/// # Examples
237237
///
238238
/// ```rust
239-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
239+
/// # #![allow(clippy::disallowed_names)]
240240
/// # use kernel::{init, macros::pin_data, pin_init, stack_pin_init, init::*, sync::Mutex, new_mutex};
241241
/// # use core::pin::Pin;
242242
/// #[pin_data]
@@ -288,7 +288,7 @@ macro_rules! stack_pin_init {
288288
/// # Examples
289289
///
290290
/// ```rust,ignore
291-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
291+
/// # #![allow(clippy::disallowed_names)]
292292
/// # use kernel::{init, pin_init, stack_try_pin_init, init::*, sync::Mutex, new_mutex};
293293
/// # use macros::pin_data;
294294
/// # use core::{alloc::AllocError, pin::Pin};
@@ -314,7 +314,7 @@ macro_rules! stack_pin_init {
314314
/// ```
315315
///
316316
/// ```rust,ignore
317-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
317+
/// # #![allow(clippy::disallowed_names)]
318318
/// # use kernel::{init, pin_init, stack_try_pin_init, init::*, sync::Mutex, new_mutex};
319319
/// # use macros::pin_data;
320320
/// # use core::{alloc::AllocError, pin::Pin};
@@ -366,7 +366,7 @@ macro_rules! stack_try_pin_init {
366366
/// The syntax is almost identical to that of a normal `struct` initializer:
367367
///
368368
/// ```rust
369-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
369+
/// # #![allow(clippy::disallowed_names)]
370370
/// # use kernel::{init, pin_init, macros::pin_data, init::*};
371371
/// # use core::pin::Pin;
372372
/// #[pin_data]
@@ -411,7 +411,7 @@ macro_rules! stack_try_pin_init {
411411
/// To create an initializer function, simply declare it like this:
412412
///
413413
/// ```rust
414-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
414+
/// # #![allow(clippy::disallowed_names)]
415415
/// # use kernel::{init, pin_init, prelude::*, init::*};
416416
/// # use core::pin::Pin;
417417
/// # #[pin_data]
@@ -438,7 +438,7 @@ macro_rules! stack_try_pin_init {
438438
/// Users of `Foo` can now create it like this:
439439
///
440440
/// ```rust
441-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
441+
/// # #![allow(clippy::disallowed_names)]
442442
/// # use kernel::{init, pin_init, macros::pin_data, init::*};
443443
/// # use core::pin::Pin;
444444
/// # #[pin_data]
@@ -466,7 +466,7 @@ macro_rules! stack_try_pin_init {
466466
/// They can also easily embed it into their own `struct`s:
467467
///
468468
/// ```rust
469-
/// # #![allow(clippy::disallowed_names, clippy::new_ret_no_self)]
469+
/// # #![allow(clippy::disallowed_names)]
470470
/// # use kernel::{init, pin_init, macros::pin_data, init::*};
471471
/// # use core::pin::Pin;
472472
/// # #[pin_data]

rust/kernel/sync/condvar.rs

-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ unsafe impl Sync for CondVar {}
9191

9292
impl CondVar {
9393
/// Constructs a new condvar initialiser.
94-
#[allow(clippy::new_ret_no_self)]
9594
pub fn new(name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self> {
9695
pin_init!(Self {
9796
_pin: PhantomPinned,

rust/kernel/sync/lock.rs

-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ unsafe impl<T: ?Sized + Send, B: Backend> Sync for Lock<T, B> {}
9999

100100
impl<T, B: Backend> Lock<T, B> {
101101
/// Constructs a new lock initialiser.
102-
#[allow(clippy::new_ret_no_self)]
103102
pub fn new(t: T, name: &'static CStr, key: &'static LockClassKey) -> impl PinInit<Self> {
104103
pin_init!(Self {
105104
data: UnsafeCell::new(t),

0 commit comments

Comments
 (0)