Commit ab844cf3 authored by Miguel Ojeda's avatar Miguel Ojeda
Browse files

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: default avatarAlice Ryhl <aliceryhl@google.com>
Link: https://lore.kernel.org/rust-for-linux/aRG9VjsaCjsvAwUn@google.com/


Reviewed-by: default avatarDavid Gow <davidgow@google.com>
Acked-by: default avatarBenno Lossin <lossin@kernel.org>
Reviewed-by: default avatarAlice Ryhl <aliceryhl@google.com>
Link: https://patch.msgid.link/20251110113528.1658238-1-ojeda@kernel.org


Signed-off-by: default avatarMiguel Ojeda <ojeda@kernel.org>
parent bf724be7
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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 {
+1 −1
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -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();
    }}