Miguel Ojeda
unread,Nov 10, 2025, 6:35:43 AMNov 10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Greg Kroah-Hartman, Rafael J. Wysocki, Danilo Krummrich, Brendan Higgins, David Gow, Miguel Ojeda, Alex Gaynor, Rae Moar, linux-k...@vger.kernel.org, kuni...@googlegroups.com, Boqun Feng, Gary Guo, Björn Roy Baron, Benno Lossin, Andreas Hindborg, Alice Ryhl, Trevor Gross, rust-fo...@vger.kernel.org, linux-...@vger.kernel.org, pat...@lists.linux.dev
Examples (i.e. doctests) may want to show public items such as structs,
thus the `unreachable_pub` warning is not very helpful.
Thus allow it for all doctests.
In addition, remove it from the existing `expect`s we have in a couple
doctests.
Suggested-by: Alice Ryhl <
alic...@google.com>
Link:
https://lore.kernel.org/rust-for-linux/aRG9Vjsa...@google.com/
Signed-off-by: Miguel Ojeda <
oj...@kernel.org>
---
rust/kernel/
init.rs | 2 +-
rust/kernel/
types.rs | 2 +-
scripts/
rustdoc_test_gen.rs | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/rust/kernel/
init.rs b/rust/kernel/
init.rs
index 4949047af8d7..e476d81c1a27 100644
--- a/rust/kernel/
init.rs
+++ b/rust/kernel/
init.rs
@@ -67,7 +67,7 @@
//! ```
//!
//! ```rust
-//! # #![expect(unreachable_pub, clippy::disallowed_names)]
+//! # #![expect(clippy::disallowed_names)]
//! use kernel::{prelude::*, types::Opaque};
//! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin};
//! # mod bindings {
diff --git a/rust/kernel/
types.rs b/rust/kernel/
types.rs
index dc0a02f5c3cf..835824788506 100644
--- a/rust/kernel/
types.rs
+++ b/rust/kernel/
types.rs
@@ -289,7 +289,7 @@ fn drop(&mut self) {
/// # Examples
///
/// ```
-/// # #![expect(unreachable_pub, clippy::disallowed_names)]
+/// # #![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.
diff --git a/scripts/
rustdoc_test_gen.rs b/scripts/
rustdoc_test_gen.rs
index c8f9dc2ab976..0e6a0542d1bd 100644
--- a/scripts/
rustdoc_test_gen.rs
+++ b/scripts/
rustdoc_test_gen.rs
@@ -208,6 +208,7 @@ macro_rules! assert_eq {{
#[allow(unused)]
static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1;
{{
+ #![allow(unreachable_pub)]
{body}
main();
}}
base-commit: e9a6fb0bcdd7609be6969112f3fbfcce3b1d4a7c
--
2.51.2