Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

rust: allow `unreachable_pub` for doctests

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 <aliceryhl@google.com>
Link: https://lore.kernel.org/rust-for-linux/aRG9VjsaCjsvAwUn@google.com/
Reviewed-by: David Gow <davidgow@google.com>
Acked-by: Benno Lossin <lossin@kernel.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251110113528.1658238-1-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

+3 -2
+1 -1
rust/kernel/init.rs
··· 67 67 //! ``` 68 68 //! 69 69 //! ```rust 70 - //! # #![expect(unreachable_pub, clippy::disallowed_names)] 70 + //! # #![expect(clippy::disallowed_names)] 71 71 //! use kernel::{prelude::*, types::Opaque}; 72 72 //! use core::{ptr::addr_of_mut, marker::PhantomPinned, pin::Pin}; 73 73 //! # mod bindings {
+1 -1
rust/kernel/types.rs
··· 289 289 /// # Examples 290 290 /// 291 291 /// ``` 292 - /// # #![expect(unreachable_pub, clippy::disallowed_names)] 292 + /// # #![expect(clippy::disallowed_names)] 293 293 /// use kernel::types::Opaque; 294 294 /// # // Emulate a C struct binding which is from C, maybe uninitialized or not, only the C side 295 295 /// # // knows.
+1
scripts/rustdoc_test_gen.rs
··· 208 208 #[allow(unused)] 209 209 static __DOCTEST_ANCHOR: i32 = ::core::line!() as i32 + {body_offset} + 1; 210 210 {{ 211 + #![allow(unreachable_pub)] 211 212 {body} 212 213 main(); 213 214 }}