]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: allow `clippy::disallowed_names` for doctests
authorMiguel Ojeda <ojeda@kernel.org>
Mon, 17 Nov 2025 08:07:13 +0000 (09:07 +0100)
committerMiguel Ojeda <ojeda@kernel.org>
Mon, 17 Nov 2025 21:53:27 +0000 (22:53 +0100)
Examples (i.e. doctests) may want to use names such as `foo`, thus the
`clippy::disallowed_names` lint [1] gets in the way.

Thus allow it for all doctests.

In addition, remove it from the existing `expect`s we have in a few
doctests.

This does not mean that we should stop trying to find good names for
our examples, though.

Link: https://rust-lang.github.io/rust-clippy/stable/index.html#disallowed_names
Suggested-by: Alice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/rust-for-linux/aRHSLChi5HYXW4-9@google.com/
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Acked-by: Benno Lossin <lossin@kernel.org>
Link: https://patch.msgid.link/20251117080714.876978-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/init.rs
rust/kernel/types.rs
scripts/rustdoc_test_gen.rs

index e476d81c1a27d00c88b87041c6b0abc6e5489bb4..899b9a96276235c770e5d4061598eefc19157d71 100644 (file)
@@ -30,7 +30,7 @@
 //! ## General Examples
 //!
 //! ```rust
-//! # #![expect(clippy::disallowed_names, clippy::undocumented_unsafe_blocks)]
+//! # #![expect(clippy::undocumented_unsafe_blocks)]
 //! use kernel::types::Opaque;
 //! use pin_init::pin_init_from_closure;
 //!
@@ -67,7 +67,6 @@
 //! ```
 //!
 //! ```rust
-//! # #![expect(clippy::disallowed_names)]
 //! use kernel::{prelude::*, types::Opaque};
 //! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
 //! # mod bindings {
index 8358247885065abc1fa888f06c566d37bb92fc56..9c5e7dbf16323f63ebdbb33bee26440cff5bef43 100644 (file)
@@ -289,7 +289,6 @@ impl<T, F: FnOnce(T)> Drop for ScopeGuard<T, F> {
 /// # Examples
 ///
 /// ```
-/// # #![expect(clippy::disallowed_names)]
 /// use kernel::types::Opaque;
 /// # // Emulate a C struct binding which is from C, maybe uninitialized or not, only the C side
 /// # // knows.
index 0e6a0542d1bdc2b0dbca0abda7a6a1dcc87b2557..be05610496605bc5de33007f1f92fb3b6e429a35 100644 (file)
@@ -208,7 +208,7 @@ pub extern "C" fn {kunit_name}(__kunit_test: *mut ::kernel::bindings::kunit) {{
     #[allow(unused)]
     static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1;
     {{
-        #![allow(unreachable_pub)]
+        #![allow(unreachable_pub, clippy::disallowed_names)]
         {body}
         main();
     }}